Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| elearning:workbooks:kubernetes:k8s02 [2022/07/13 12:54] – admin | elearning:workbooks:kubernetes:k8s02 [2024/12/15 06:47] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version - **2020.02** | + | Version - **2024.01** |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| Ligne 14: | Ligne 14: | ||
| * 1.1 - Obtenir de l'Aide sur les Commandes de kubectl | * 1.1 - Obtenir de l'Aide sur les Commandes de kubectl | ||
| * 1.2 - Obtenir de l' | * 1.2 - Obtenir de l' | ||
| - | | + | * La Commande version |
| - | * LAB #2 - Géstion | + | * La Commande cluster-info |
| + | * La Commande api-versions | ||
| + | * La Commande api-resources | ||
| + | | ||
| + | * La Commande describe node | ||
| + | * La Commande top | ||
| + | * 1.4 - Obtenir de l' | ||
| + | * La Commande describe pod | ||
| + | * La Commande top | ||
| + | * 1.5 - Travailler avec la commande kubectl | ||
| + | * La Commande apply | ||
| + | * La Commande create | ||
| + | * La Commande get | ||
| + | * Utilisation des Options | ||
| + | * La Commande exec | ||
| + | * Commandes Impératives | ||
| + | * LAB #2 - Gestion | ||
| * 2.1 - Installation de krew | * 2.1 - Installation de krew | ||
| * 2.2 - Consultation de la liste des plugins | * 2.2 - Consultation de la liste des plugins | ||
| * 2.3 - Installation et utilisation de plugins | * 2.3 - Installation et utilisation de plugins | ||
| * 2.4 - Mise à jour et suppression de plugins | * 2.4 - Mise à jour et suppression de plugins | ||
| - | * LAB #3 - Géstion | + | * LAB #3 - Gestion |
| + | |||
| + | =====Ressources===== | ||
| + | |||
| + | ====Lab #1===== | ||
| + | |||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ====Lab #2==== | ||
| + | |||
| + | * https:// | ||
| + | |||
| + | ====Lab #3==== | ||
| + | |||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| =====LAB #1 - Utilisation de la Commande kubectl===== | =====LAB #1 - Utilisation de la Commande kubectl===== | ||
| Ligne 32: | Ligne 67: | ||
| kubectl controls the Kubernetes cluster manager. | kubectl controls the Kubernetes cluster manager. | ||
| - | Find more information at: https:// | + | Find more information at: https:// |
| Basic Commands (Beginner): | Basic Commands (Beginner): | ||
| Ligne 82: | Ligne 117: | ||
| label | label | ||
| annotate | annotate | ||
| - | completion | + | completion |
| Other Commands: | Other Commands: | ||
| Ligne 213: | Ligne 248: | ||
| --alsologtostderr=false: | --alsologtostderr=false: | ||
| - | log to standard error as well as files (DEPRECATED: | + | log to standard error as well as files (no effect when -logtostderr=true) |
| + | | ||
| https:// | https:// | ||
| Ligne 255: | Ligne 291: | ||
| --log-dir='': | --log-dir='': | ||
| - | If non-empty, write log files in this directory (DEPRECATED: | + | If non-empty, write log files in this directory |
| + | | ||
| https:// | https:// | ||
| --log-file='': | --log-file='': | ||
| - | If non-empty, use this log file (DEPRECATED: | + | If non-empty, use this log file (no effect when -logtostderr=true) |
| + | | ||
| https:// | https:// | ||
| --log-file-max-size=1800: | --log-file-max-size=1800: | ||
| - | Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size | + | Defines the maximum size a log file can grow to (no effect when -logtostderr=true). Unit is megabytes. If the |
| - | | + | |
| https:// | https:// | ||
| Ligne 281: | Ligne 319: | ||
| --one-output=false: | --one-output=false: | ||
| - | If true, only write logs to their native severity level (vs also writing to each lower severity level) | + | If true, only write logs to their native severity level (vs also writing to each lower severity level; no |
| - | (DEPRECATED: | + | |
| https:// | https:// | ||
| Ligne 306: | Ligne 344: | ||
| --skip-log-headers=false: | --skip-log-headers=false: | ||
| - | If true, avoid headers when opening log files (DEPRECATED: | + | If true, avoid headers when opening log files (no effect when -logtostderr=true) |
| + | | ||
| https:// | https:// | ||
| --stderrthreshold=2: | --stderrthreshold=2: | ||
| - | logs at or above this threshold go to stderr (DEPRECATED: | + | logs at or above this threshold go to stderr when writing to files and stderr |
| + | -logtostderr=true or -alsologtostderr=false) | ||
| https:// | https:// | ||
| Ligne 345: | Ligne 385: | ||
| root@kubemaster: | root@kubemaster: | ||
| Flag --short has been deprecated, and will be removed in the future. The --short output will become the default. | Flag --short has been deprecated, and will be removed in the future. The --short output will become the default. | ||
| - | Client Version: v1.24.2 | + | Client Version: v1.25.0 |
| - | Kustomize Version: v4.5.4 | + | Kustomize Version: v4.5.7 |
| - | Server Version: v1.24.2 | + | Server Version: v1.25.0 |
| </ | </ | ||
| Ligne 376: | Ligne 416: | ||
| autoscaling/ | autoscaling/ | ||
| autoscaling/ | autoscaling/ | ||
| - | autoscaling/ | ||
| autoscaling/ | autoscaling/ | ||
| batch/v1 | batch/v1 | ||
| - | batch/ | ||
| certificates.k8s.io/ | certificates.k8s.io/ | ||
| coordination.k8s.io/ | coordination.k8s.io/ | ||
| crd.projectcalico.org/ | crd.projectcalico.org/ | ||
| discovery.k8s.io/ | discovery.k8s.io/ | ||
| - | discovery.k8s.io/ | ||
| events.k8s.io/ | events.k8s.io/ | ||
| - | events.k8s.io/ | ||
| flowcontrol.apiserver.k8s.io/ | flowcontrol.apiserver.k8s.io/ | ||
| flowcontrol.apiserver.k8s.io/ | flowcontrol.apiserver.k8s.io/ | ||
| networking.k8s.io/ | networking.k8s.io/ | ||
| node.k8s.io/ | node.k8s.io/ | ||
| - | node.k8s.io/ | ||
| policy/v1 | policy/v1 | ||
| - | policy/ | ||
| rbac.authorization.k8s.io/ | rbac.authorization.k8s.io/ | ||
| scheduling.k8s.io/ | scheduling.k8s.io/ | ||
| Ligne 476: | Ligne 510: | ||
| runtimeclasses | runtimeclasses | ||
| poddisruptionbudgets | poddisruptionbudgets | ||
| - | podsecuritypolicies | ||
| clusterrolebindings | clusterrolebindings | ||
| clusterroles | clusterroles | ||
| Ligne 495: | Ligne 528: | ||
| De l' | De l' | ||
| - | * la section **Labels: | + | * la section **Labels: |
| * la ligne **Unschedulable: | * la ligne **Unschedulable: | ||
| Ligne 514: | Ligne 547: | ||
| projectcalico.org/ | projectcalico.org/ | ||
| volumes.kubernetes.io/ | volumes.kubernetes.io/ | ||
| - | CreationTimestamp: | + | CreationTimestamp: |
| Taints: | Taints: | ||
| - | node-role.kubernetes.io/ | ||
| Unschedulable: | Unschedulable: | ||
| Lease: | Lease: | ||
| HolderIdentity: | HolderIdentity: | ||
| AcquireTime: | AcquireTime: | ||
| - | RenewTime: | + | RenewTime: |
| Conditions: | Conditions: | ||
| Type | Type | ||
| ---- | ---- | ||
| - | NetworkUnavailable | + | NetworkUnavailable |
| - | MemoryPressure | + | MemoryPressure |
| - | DiskPressure | + | DiskPressure |
| - | PIDPressure | + | PIDPressure |
| - | Ready True | + | Ready True |
| ... | ... | ||
| </ | </ | ||
| Ligne 546: | Ligne 578: | ||
| ephemeral-storage: | ephemeral-storage: | ||
| hugepages-2Mi: | hugepages-2Mi: | ||
| - | memory: | + | memory: |
| pods: 110 | pods: 110 | ||
| Allocatable: | Allocatable: | ||
| Ligne 552: | Ligne 584: | ||
| ephemeral-storage: | ephemeral-storage: | ||
| hugepages-2Mi: | hugepages-2Mi: | ||
| - | memory: | + | memory: |
| pods: 110 | pods: 110 | ||
| ... | ... | ||
| Ligne 567: | Ligne 599: | ||
| Machine ID: | Machine ID: | ||
| System UUID: 68639C3A-D77A-4C61-B7E8-4F4F70419B8A | System UUID: 68639C3A-D77A-4C61-B7E8-4F4F70419B8A | ||
| - | Boot ID: | + | Boot ID: |
| Kernel Version: | Kernel Version: | ||
| OS Image: | OS Image: | ||
| Ligne 573: | Ligne 605: | ||
| Architecture: | Architecture: | ||
| Container Runtime Version: | Container Runtime Version: | ||
| - | Kubelet Version: | + | Kubelet Version: |
| - | Kube-Proxy Version: | + | Kube-Proxy Version: |
| PodCIDR: | PodCIDR: | ||
| PodCIDRs: | PodCIDRs: | ||
| - | Non-terminated Pods: (8 in total) | + | Non-terminated Pods: (7 in total) |
| Namespace | Namespace | ||
| --------- | --------- | ||
| - | kube-system | + | kube-system |
| - | kube-system | + | kube-system |
| - | kube-system | + | kube-system |
| - | kube-system | + | kube-system |
| - | kube-system | + | kube-system |
| - | kube-system | + | kube-system |
| - | kube-system | + | kube-system |
| - | kube-system | + | |
| ... | ... | ||
| </ | </ | ||
| Ligne 598: | Ligne 629: | ||
| Allocated resources: | Allocated resources: | ||
| (Total limits may be over 100 percent, i.e., overcommitted.) | (Total limits may be over 100 percent, i.e., overcommitted.) | ||
| - | Resource | + | Resource |
| - | -------- | + | -------- |
| - | cpu | + | cpu |
| - | memory | + | memory |
| - | ephemeral-storage | + | ephemeral-storage |
| - | hugepages-2Mi | + | hugepages-2Mi |
| - | Events: | + | Events: |
| + | Type Reason | ||
| + | ---- ------ | ||
| + | Normal | ||
| </ | </ | ||
| Ligne 618: | Ligne 652: | ||
| < | < | ||
| - | root@kubemaster: | + | root@kubemaster: |
| - | root@kubemaster: | + | root@kubemaster: |
| ... | ... | ||
| spec: | spec: | ||
| Ligne 652: | Ligne 686: | ||
| root@kubemaster: | root@kubemaster: | ||
| NAMESPACE | NAMESPACE | ||
| - | kube-system | + | default |
| - | kube-system | + | kube-system |
| - | kube-system | + | kube-system |
| - | </ | + | kube-system |
| + | </ | ||
| Pour connaître l' | Pour connaître l' | ||
| Ligne 661: | Ligne 696: | ||
| < | < | ||
| root@kubemaster: | root@kubemaster: | ||
| - | NAME CPU(cores) | + | NAME CPU(cores) |
| - | kubemaster.ittraining.loc | + | kubemaster.ittraining.loc |
| - | kubenode1.ittraining.loc | + | kubenode1.ittraining.loc |
| - | kubenode2.ittraining.loc | + | kubenode2.ittraining.loc |
| </ | </ | ||
| Ligne 671: | Ligne 706: | ||
| < | < | ||
| root@kubemaster: | root@kubemaster: | ||
| - | Every 2,0s: kubectl top nodes kubemaster.ittraining.loc: | + | Every 2,0s: kubectl top nodes kubemaster.ittraining.loc: |
| NAME CPU(cores) | NAME CPU(cores) | ||
| - | kubemaster.ittraining.loc | + | kubemaster.ittraining.loc |
| - | kubenode1.ittraining.loc | + | kubenode1.ittraining.loc |
| - | kubenode2.ittraining.loc | + | kubenode2.ittraining.loc |
| ... | ... | ||
| ^C | ^C | ||
| - | root@kubemaster: | + | root@kubemaster: |
| </ | </ | ||
| - | <WRAP center round important | + | <WRAP center round important |
| - | **Important** : Notez l' | + | **Important** : Notez l' |
| </ | </ | ||
| + | |||
| + | Il est possible de trier la sortie par ordre décroissant de l' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME CPU(cores) | ||
| + | kubemaster.ittraining.loc | ||
| + | kubenode1.ittraining.loc | ||
| + | kubenode2.ittraining.loc | ||
| + | </ | ||
| + | |||
| + | Dernièrement, | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME CPU(cores) | ||
| + | kubemaster.ittraining.loc | ||
| + | kubenode1.ittraining.loc | ||
| + | kubenode2.ittraining.loc | ||
| + | </ | ||
| + | |||
| + | ====1.4 - Obtenir de l' | ||
| + | |||
| + | ===La Commande describe pod=== | ||
| + | |||
| + | Tout comme avec les noeuds, des informations concernant un pod spécifique peuvent être obtenues en utilisant la commande **kubectl describe** : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | Name: | ||
| + | Namespace: | ||
| + | Priority: | ||
| + | Service Account: | ||
| + | Node: | ||
| + | Start Time: Sun, 04 Sep 2022 13:23:12 +0200 | ||
| + | Labels: | ||
| + | pod-template-hash=689f9d59 | ||
| + | type=front-end | ||
| + | Annotations: | ||
| + | cni.projectcalico.org/ | ||
| + | cni.projectcalico.org/ | ||
| + | Status: | ||
| + | IP: | ||
| + | IPs: | ||
| + | IP: | ||
| + | Controlled By: ReplicaSet/ | ||
| + | Containers: | ||
| + | nginx-container: | ||
| + | Container ID: | ||
| + | Image: | ||
| + | Image ID: | ||
| + | Port: < | ||
| + | Host Port: < | ||
| + | State: | ||
| + | Started: | ||
| + | Ready: | ||
| + | Restart Count: | ||
| + | Environment: | ||
| + | Mounts: | ||
| + | / | ||
| + | Conditions: | ||
| + | Type Status | ||
| + | Initialized | ||
| + | Ready | ||
| + | ContainersReady | ||
| + | PodScheduled | ||
| + | Volumes: | ||
| + | kube-api-access-fjdsw: | ||
| + | Type: Projected (a volume that contains injected data from multiple sources) | ||
| + | TokenExpirationSeconds: | ||
| + | ConfigMapName: | ||
| + | ConfigMapOptional: | ||
| + | DownwardAPI: | ||
| + | QoS Class: | ||
| + | Node-Selectors: | ||
| + | Tolerations: | ||
| + | | ||
| + | Events: | ||
| + | </ | ||
| + | |||
| + | ===La Commande top=== | ||
| + | |||
| + | Il est possible de voir l' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME CPU(cores) | ||
| + | myapp-deployment-689f9d59-c25f9 | ||
| + | myapp-deployment-689f9d59-nn9sw | ||
| + | myapp-deployment-689f9d59-rnc4r | ||
| + | </ | ||
| + | |||
| + | Triez maintenant la sortie par ordre décroissant de l' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME CPU(cores) | ||
| + | myapp-deployment-689f9d59-c25f9 | ||
| + | myapp-deployment-689f9d59-nn9sw | ||
| + | myapp-deployment-689f9d59-rnc4r | ||
| + | </ | ||
| + | |||
| + | Triez maintenant la sortie par ordre décroissant de l' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME CPU(cores) | ||
| + | myapp-deployment-689f9d59-nn9sw | ||
| + | myapp-deployment-689f9d59-rnc4r | ||
| + | myapp-deployment-689f9d59-c25f9 | ||
| + | </ | ||
| + | |||
| + | ====1.5 - Travailler avec la commande kubectl==== | ||
| + | |||
| + | Créez le fichier **pod.yaml** : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | root@kubemaster: | ||
| + | apiVersion: v1 | ||
| + | kind: Pod | ||
| + | metadata: | ||
| + | name: my-pod | ||
| + | spec: | ||
| + | containers: | ||
| + | - name: busybox | ||
| + | image: radial/ | ||
| + | command: [' | ||
| + | </ | ||
| + | |||
| + | ====La Commande apply==== | ||
| + | |||
| + | Créez maintenant le pod en utilisant le fichier **pod.yaml** : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | pod/my-pod created | ||
| + | </ | ||
| + | |||
| + | ====La Commande create==== | ||
| + | |||
| + | La commande **create** ne peut être utilisée que dans le cas où un objet du même nom n' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | Error from server (AlreadyExists): | ||
| + | </ | ||
| + | |||
| + | Pour consulter la liste des objets qui peuvent être créés, utilisez la commande **kubectl create** : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | Error: must specify one of -f and -k | ||
| + | |||
| + | Create a resource from a file or from stdin. | ||
| + | |||
| + | JSON and YAML formats are accepted. | ||
| + | |||
| + | Examples: | ||
| + | # Create a pod using the data in pod.json | ||
| + | kubectl create -f ./pod.json | ||
| + | | ||
| + | # Create a pod based on the JSON passed into stdin | ||
| + | cat pod.json | kubectl create -f - | ||
| + | | ||
| + | # Edit the data in registry.yaml in JSON then create the resource using the edited data | ||
| + | kubectl create -f registry.yaml --edit -o json | ||
| + | |||
| + | Available Commands: | ||
| + | clusterrole | ||
| + | clusterrolebinding | ||
| + | configmap | ||
| + | cronjob | ||
| + | deployment | ||
| + | ingress | ||
| + | job | ||
| + | namespace | ||
| + | poddisruptionbudget | ||
| + | priorityclass | ||
| + | quota | ||
| + | role Create a role with single rule | ||
| + | rolebinding | ||
| + | secret | ||
| + | service | ||
| + | serviceaccount | ||
| + | token | ||
| + | |||
| + | Options: | ||
| + | --allow-missing-template-keys=true: | ||
| + | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to | ||
| + | golang and jsonpath output formats. | ||
| + | |||
| + | --dry-run=' | ||
| + | Must be " | ||
| + | sending it. If server strategy, submit server-side request without persisting the resource. | ||
| + | |||
| + | --edit=false: | ||
| + | Edit the API resource before creating | ||
| + | |||
| + | --field-manager=' | ||
| + | Name of the manager used to track field ownership. | ||
| + | |||
| + | -f, --filename=[]: | ||
| + | Filename, directory, or URL to files to use to create the resource | ||
| + | |||
| + | -k, --kustomize='': | ||
| + | Process the kustomization directory. This flag can't be used together with -f or -R. | ||
| + | |||
| + | -o, --output='': | ||
| + | Output format. One of: (json, yaml, name, go-template, | ||
| + | jsonpath-as-json, | ||
| + | |||
| + | --raw='': | ||
| + | Raw URI to POST to the server. | ||
| + | |||
| + | -R, --recursive=false: | ||
| + | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests | ||
| + | organized within the same directory. | ||
| + | |||
| + | --save-config=false: | ||
| + | If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will | ||
| + | be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. | ||
| + | |||
| + | -l, --selector='': | ||
| + | Selector (label query) to filter on, supports ' | ||
| + | objects must satisfy all of the specified label constraints. | ||
| + | |||
| + | --show-managed-fields=false: | ||
| + | If true, keep the managedFields when printing objects in JSON or YAML format. | ||
| + | |||
| + | --template='': | ||
| + | Template string or path to template file to use when -o=go-template, | ||
| + | is golang templates [http:// | ||
| + | |||
| + | --validate=' | ||
| + | Must be one of: strict (or true), warn, ignore (or false). | ||
| + | the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation | ||
| + | is enabled on the api-server, but will fall back to less reliable client-side validation if not. " | ||
| + | warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled | ||
| + | on the API server, and behave as " | ||
| + | validation, silently dropping any unknown or duplicate fields. | ||
| + | |||
| + | --windows-line-endings=false: | ||
| + | Only relevant if --edit=true. Defaults to the line ending native to your platform. | ||
| + | |||
| + | Usage: | ||
| + | kubectl create -f FILENAME [options] | ||
| + | |||
| + | Use " | ||
| + | Use " | ||
| + | </ | ||
| + | |||
| + | La commande **apply** est ensuite utilisée pour appliquer des modifications apportées au fichier yaml : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | pod/my-pod unchanged | ||
| + | </ | ||
| + | |||
| + | ====La Commande get==== | ||
| + | |||
| + | Constatez le statut du pod : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME READY | ||
| + | my-pod | ||
| + | myapp-deployment-689f9d59-c25f9 | ||
| + | myapp-deployment-689f9d59-nn9sw | ||
| + | myapp-deployment-689f9d59-rnc4r | ||
| + | </ | ||
| + | |||
| + | Rappelez-vous que vous pouvez utiliser une abréviation pour pods : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME READY | ||
| + | my-pod | ||
| + | myapp-deployment-689f9d59-c25f9 | ||
| + | myapp-deployment-689f9d59-nn9sw | ||
| + | myapp-deployment-689f9d59-rnc4r | ||
| + | </ | ||
| + | |||
| + | Pour ne voir qu'un seul pod, il convient de préciser son nom en tant qu' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME | ||
| + | my-pod | ||
| + | </ | ||
| + | |||
| + | ====Utilisation des Options==== | ||
| + | |||
| + | Rappelez-vous que l' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME READY | ||
| + | my-pod | ||
| + | myapp-deployment-689f9d59-c25f9 | ||
| + | myapp-deployment-689f9d59-nn9sw | ||
| + | myapp-deployment-689f9d59-rnc4r | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ": | ||
| + | "while true; do sleep 3600; done\" | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | "while true; do sleep 3600; done" | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | apiVersion: v1 | ||
| + | items: | ||
| + | - apiVersion: v1 | ||
| + | kind: Pod | ||
| + | metadata: | ||
| + | annotations: | ||
| + | cni.projectcalico.org/ | ||
| + | cni.projectcalico.org/ | ||
| + | cni.projectcalico.org/ | ||
| + | kubectl.kubernetes.io/ | ||
| + | {" | ||
| + | ers": | ||
| + | creationTimestamp: | ||
| + | name: my-pod | ||
| + | namespace: default | ||
| + | resourceVersion: | ||
| + | uid: 628ca9e4-2fbe-4fc9-b0fa-9a05ef942a07 | ||
| + | spec: | ||
| + | containers: | ||
| + | - command: | ||
| + | - sh | ||
| + | - -c | ||
| + | - while true; do sleep 3600; done | ||
| + | image: radial/ | ||
| + | imagePullPolicy: | ||
| + | name: busybox | ||
| + | resources: {} | ||
| + | terminationMessagePath: | ||
| + | terminationMessagePolicy: | ||
| + | volumeMounts: | ||
| + | - mountPath: / | ||
| + | name: kube-api-access-qwzzv | ||
| + | readOnly: true | ||
| + | dnsPolicy: ClusterFirst | ||
| + | enableServiceLinks: | ||
| + | nodeName: kubenode2.ittraining.loc | ||
| + | preemptionPolicy: | ||
| + | priority: 0 | ||
| + | restartPolicy: | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME READY | ||
| + | myapp-deployment-689f9d59-c25f9 | ||
| + | myapp-deployment-689f9d59-nn9sw | ||
| + | myapp-deployment-689f9d59-rnc4r | ||
| + | my-pod | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | NAME READY | ||
| + | calico-node-5htrc | ||
| + | calico-node-dc7hd | ||
| + | calico-node-qk5kt | ||
| + | </ | ||
| + | |||
| + | ====La Commande exec==== | ||
| + | |||
| + | La commande **exec** permet d' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | Hello, world! | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : Notez l' | ||
| + | </ | ||
| + | |||
| + | |||
| + | ====5.6 - Commandes Impératives ==== | ||
| + | |||
| + | Avant de poursuivre, supprimez le pod **my-pod** : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | pod " | ||
| + | </ | ||
| + | |||
| + | Créez ensuite un deployment avec une commande impérative : | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | deployment.apps/ | ||
| + | </ | ||
| + | |||
| + | En exécutant la même commande impérative, | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | W0910 15: | ||
| + | apiVersion: apps/v1 | ||
| + | kind: Deployment | ||
| + | metadata: | ||
| + | creationTimestamp: | ||
| + | labels: | ||
| + | app: my-deployment | ||
| + | name: my-deployment | ||
| + | spec: | ||
| + | replicas: 1 | ||
| + | selector: | ||
| + | matchLabels: | ||
| + | app: my-deployment | ||
| + | strategy: {} | ||
| + | template: | ||
| + | metadata: | ||
| + | creationTimestamp: | ||
| + | labels: | ||
| + | app: my-deployment | ||
| + | spec: | ||
| + | containers: | ||
| + | - image: nginx | ||
| + | name: nginx | ||
| + | resources: {} | ||
| + | status: {} | ||
| + | </ | ||
| + | |||
| + | Ces instructions peuvent ensuite être injectées dans un fichier afin d' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | W0910 15: | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| + | apiVersion: apps/v1 | ||
| + | kind: Deployment | ||
| + | metadata: | ||
| + | creationTimestamp: | ||
| + | labels: | ||
| + | app: my-deployment | ||
| + | name: my-deployment | ||
| + | spec: | ||
| + | replicas: 1 | ||
| + | selector: | ||
| + | matchLabels: | ||
| + | app: my-deployment | ||
| + | strategy: {} | ||
| + | template: | ||
| + | metadata: | ||
| + | creationTimestamp: | ||
| + | labels: | ||
| + | app: my-deployment | ||
| + | spec: | ||
| + | containers: | ||
| + | - image: nginx | ||
| + | name: nginx | ||
| + | resources: {} | ||
| + | status: {} | ||
| + | </ | ||
| =====LAB #2 - Géstion les plugins de kubectl avec la Commande krew===== | =====LAB #2 - Géstion les plugins de kubectl avec la Commande krew===== | ||
| Ligne 695: | Ligne 1242: | ||
| < | < | ||
| - | root@debian10:~# apt install git-all | + | root@kubemaster:~# apt install git-all |
| </ | </ | ||
| Ligne 745: | Ligne 1292: | ||
| | | ||
| | | ||
| - | | + | |
| | | ||
| | | ||
| | | ||
| | | ||
| - | | + | |
| | | ||
| - | | + | |
| | | ||
| | | ||
| | | ||
| | | ||
| - | | + | |
| | | ||
| | | ||
| Ligne 1061: | Ligne 1608: | ||
| </ | </ | ||
| - | Le plugin **ns** permet de basculer entre les **namespaces** facilement. | + | Le plugin **ns** permet de basculer entre les **namespaces** facilement. |
| Les Namespaces : | Les Namespaces : | ||
| Ligne 1080: | Ligne 1627: | ||
| </ | </ | ||
| - | Le plugin **view-allocations** permet de visualiser les allocations de ressources telles le CPU, la mémoire, le stockage etc : | + | Le plugin **view-allocations** permet de visualiser les allocations de ressources telles le CPU, la mémoire, le stockage etc : |
| < | < | ||
| root@kubemaster: | root@kubemaster: | ||
| - | | + | |
| - | cpu (13%) 1.6 __ | + | cpu (13%) 1.6 __ |
| - | ├─ kubemaster.ittraining.loc | + | ├─ kubemaster.ittraining.loc |
| - | │ ├─ calico-node-688lw | + | │ ├─ calico-node-688lw |
| - | │ ├─ coredns-6d4b75cb6d-dw4ph | + | │ ├─ coredns-6d4b75cb6d-dw4ph |
| - | │ ├─ coredns-6d4b75cb6d-ms2jm | + | │ ├─ coredns-6d4b75cb6d-ms2jm |
| - | │ ├─ etcd-kubemaster.ittraining.loc | + | │ ├─ etcd-kubemaster.ittraining.loc |
| - | │ ├─ kube-apiserver-kubemaster.ittraining.loc | + | │ ├─ kube-apiserver-kubemaster.ittraining.loc |
| - | │ ├─ kube-controller-manager-kubemaster.ittraining.loc | + | │ ├─ kube-controller-manager-kubemaster.ittraining.loc |
| - | │ └─ kube-scheduler-kubemaster.ittraining.loc | + | │ └─ kube-scheduler-kubemaster.ittraining.loc |
| - | ├─ kubenode1.ittraining.loc | + | ├─ kubenode1.ittraining.loc |
| - | │ └─ calico-node-5mrjl | + | │ └─ calico-node-5mrjl |
| - | └─ kubenode2.ittraining.loc | + | └─ kubenode2.ittraining.loc |
| - | | + | |
| - | ephemeral-storage | + | ephemeral-storage |
| - | ├─ kubemaster.ittraining.loc | + | ├─ kubemaster.ittraining.loc |
| - | ├─ kubenode1.ittraining.loc | + | ├─ kubenode1.ittraining.loc |
| - | └─ kubenode2.ittraining.loc | + | └─ kubenode2.ittraining.loc |
| - | memory | + | memory |
| - | ├─ kubemaster.ittraining.loc | + | ├─ kubemaster.ittraining.loc |
| - | │ ├─ coredns-6d4b75cb6d-dw4ph | + | │ ├─ coredns-6d4b75cb6d-dw4ph |
| - | │ ├─ coredns-6d4b75cb6d-ms2jm | + | │ ├─ coredns-6d4b75cb6d-ms2jm |
| - | │ └─ etcd-kubemaster.ittraining.loc | + | │ └─ etcd-kubemaster.ittraining.loc |
| - | ├─ kubenode1.ittraining.loc | + | ├─ kubenode1.ittraining.loc |
| - | └─ kubenode2.ittraining.loc | + | └─ kubenode2.ittraining.loc |
| - | pods (5%) 17.0 (5%) 17.0 330.0 313.0 | + | pods (5%) 17.0 (5%) 17.0 330.0 |
| - | ├─ kubemaster.ittraining.loc | + | ├─ kubemaster.ittraining.loc |
| - | ├─ kubenode1.ittraining.loc | + | ├─ kubenode1.ittraining.loc |
| - | └─ kubenode2.ittraining.loc | + | └─ kubenode2.ittraining.loc |
| </ | </ | ||
| Ligne 1136: | Ligne 1683: | ||
| 16) kube-scheduler-kubemaster.ittraining.loc | 16) kube-scheduler-kubemaster.ittraining.loc | ||
| 17) metrics-server-7cb867d5dc-g55k5 | 17) metrics-server-7cb867d5dc-g55k5 | ||
| - | Select a Pod: | + | Select a Pod: |
| </ | </ | ||
| Ligne 1153: | Ligne 1700: | ||
| I0713 03: | I0713 03: | ||
| I0713 03: | I0713 03: | ||
| - | I0713 03: | + | I0713 03: |
| - | I0713 03: | + | I0713 03: |
| - | I0713 03: | + | I0713 03: |
| </ | </ | ||
| Ligne 1256: | Ligne 1803: | ||
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| **Important** - le contenu de ce fichier crée un **deployment** de 1 **replica** du pod **nginx** à partir de l' | **Important** - le contenu de ce fichier crée un **deployment** de 1 **replica** du pod **nginx** à partir de l' | ||
| </ | </ | ||
| Ligne 1281: | Ligne 1828: | ||
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| **Important** - le contenu de ce fichier crée un **service** de type **ClusterIP** en utilisant le **deployment** précédent. Le Service ClusterIP permet de regrouper les PODs offrant le même service afin de faciliter la communication. | **Important** - le contenu de ce fichier crée un **service** de type **ClusterIP** en utilisant le **deployment** précédent. Le Service ClusterIP permet de regrouper les PODs offrant le même service afin de faciliter la communication. | ||
| </ | </ | ||
| Ligne 1302: | Ligne 1849: | ||
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| **Important** - le contenu de ce fichier contient un **patch** pour l' | **Important** - le contenu de ce fichier contient un **patch** pour l' | ||
| </ | </ | ||
| Ligne 1371: | Ligne 1918: | ||
| </ | </ | ||
| - | <WRAP center round important | + | <WRAP center round important |
| **Important** - notez que le fichier généré contient les contenus des **deux** fichiers **deployment.yaml** et **service.yaml** séparés par les caractères **---**. Le contenu du fichier **service.yaml** n'a pas été modifié tandis que l' | **Important** - notez que le fichier généré contient les contenus des **deux** fichiers **deployment.yaml** et **service.yaml** séparés par les caractères **---**. Le contenu du fichier **service.yaml** n'a pas été modifié tandis que l' | ||
| </ | </ | ||
| Ligne 1400: | Ligne 1947: | ||
| </ | </ | ||
| - | Créez le fichier **overlays/ | + | Créez le fichier **dev_kustomization.yaml** : |
| < | < | ||
| - | root@debian10: | + | root@kubemaster: |
| - | root@debian10: | + | root@kubemaster: |
| apiVersion: kustomize.config.k8s.io/ | apiVersion: kustomize.config.k8s.io/ | ||
| kind: Kustomization | kind: Kustomization | ||
| Ligne 1422: | Ligne 1969: | ||
| < | < | ||
| - | root@debian10: | + | root@kubemaster: |
| apiVersion: v1 | apiVersion: v1 | ||
| kind: Service | kind: Service | ||
| Ligne 1477: | Ligne 2024: | ||
| </ | </ | ||
| - | Maintenant créez le fichier **overlays/ | + | Maintenant créez le fichier **prod_kustomization.yaml** : |
| < | < | ||
| - | root@debian10: | + | root@kubemaster: |
| - | root@debian10: | + | root@kubemaster: |
| apiVersion: kustomize.config.k8s.io/ | apiVersion: kustomize.config.k8s.io/ | ||
| kind: Kustomization | kind: Kustomization | ||
| Ligne 1503: | Ligne 2050: | ||
| < | < | ||
| - | root@debian10: | + | root@kubemaster: |
| apiVersion: v1 | apiVersion: v1 | ||
| kind: Service | kind: Service | ||
| Ligne 1639: | Ligne 2186: | ||
| ---- | ---- | ||
| - | Copyright © 2020 Hugh Norris | + | Copyright © 2024 Hugh Norris |