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/09/04 11:45] – created admin | elearning:workbooks:kubernetes:k8s02 [2024/12/15 06:47] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version - **2022.03** | + | Version - **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======DOF302 | + | ======DOF303 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **DOF302 | + | * **DOF303 |
* Contenu du Module | * Contenu du Module | ||
- | * LAB #1 - Création d'un POD | + | * LAB #1 - Utilisation de la Commande kubectl |
- | * 1.1 - Présentation d'un POD | + | * 1.1 - Obtenir de l'Aide sur les Commandes de kubectl |
- | * 1.2 - Création Manuelle d'un POD | + | * 1.2 - Obtenir de l'Information sur le Cluster |
- | * 1.3 - Création d'un POD à l'aide d'un fichier YAML | + | * La Commande version |
- | * apiVersion | + | * La Commande cluster-info |
- | * kind | + | * La Commande api-versions |
- | * metadata | + | * La Commande api-resources |
- | * spec | + | * 1.3 - Obtenir |
- | * Utilisation du Fichier YAML | + | * La Commande describe node |
- | * LAB #2 - Utilisation de Contrôleurs de Réplication et ReplicaSets | + | * La Commande top |
- | * 2.1 - Contrôleurs | + | * 1.4 - Obtenir de l' |
- | * Présentation d'un Contrôleur de Réplication | + | * La Commande describe pod |
- | * Mise en Application | + | * La Commande top |
- | * 2.2 - ReplicaSets | + | * 1.5 - Travailler avec la commande kubectl |
- | * Présentation d'un ReplicaSet | + | * La Commande apply |
- | * Mise en Application | + | * La Commande create |
- | * LAB #3 - Gestion des Deployments | + | * La Commande get |
- | * 3.1 - Présentation d'un Deployment | + | * Utilisation des Options |
- | * 3.2 - Mise en Application | + | * La Commande exec |
- | * Rollouts | + | * Commandes Impératives |
- | * Rolling Updates | + | * LAB #2 - Gestion |
- | * Rollbacks | + | * 2.1 - Installation de krew |
- | * LAB #4 - Gestion de la Maintenance d'un Noeud | + | * 2.2 - Consultation de la liste des plugins |
- | | + | * 2.3 - Installation et utilisation |
- | | + | * 2.4 - Mise à jour et suppression |
- | * LAB #5 - Mise-à-jour | + | * LAB #3 - Gestion des patchs avec la Commande kustomize |
- | * 5.1 - Mise-à-jour de kubeadm | + | |
- | =====LAB #1 - Création d'un POD===== | + | =====Ressources===== |
- | ====1.1 - Présentation d'un POD==== | + | ====Lab #1===== |
- | Un POD est un objet qui encapsule un conteneur. Le conteneur est un instance d'une application. La relation entre un POD et un conteneur d' | + | * https://www.dropbox.com/ |
+ | * https:// | ||
- | A l' | + | ====Lab #2==== |
- | Dans ce cas on parle d'un conteneur d' | + | |
- | Un POD permet donc de dispenser l' | + | ====Lab #3==== |
- | Lors da la création d'un POD avec la commande | + | |
+ | | ||
+ | | ||
+ | | ||
+ | * https:// | ||
- | ====1.2 - Création Manuelle d'un POD==== | + | =====LAB #1 - Utilisation de la Commande kubectl===== |
- | Commencez par créer un POD dénommé **nginx** à partir | + | ====1.1 - Obtenir |
- | < | + | Les commandes de **kubectl** |
- | root@kubemaster: | + | |
- | pod/nginx created | + | |
- | </ | + | |
- | + | ||
- | Visualisez le POD avec la commande | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME READY | + | kubectl controls the Kubernetes cluster manager. |
- | nginx | + | |
- | root@kubemaster:~# kubectl get pods | + | Find more information at: https://kubernetes.io/ |
- | NAME READY | + | |
- | nginx 1/1 | + | |
- | </code> | + | |
- | Consultez les informations concernant ce POD : | + | Basic Commands (Beginner): |
+ | create | ||
+ | expose | ||
+ | run Run a particular image on the cluster | ||
+ | set Set specific features on objects | ||
- | < | + | Basic Commands |
- | root@kubemaster: | + | |
- | Name: | + | |
- | Namespace: | + | |
- | Priority: | + | |
- | Node: | + | |
- | Start Time: Wed, 13 Jul 2022 05:09:12 +0200 | + | |
- | Labels: | + | |
- | Annotations: | + | |
- | cni.projectcalico.org/ | + | |
- | cni.projectcalico.org/ | + | |
- | Status: | + | |
- | IP: | + | |
- | IPs: | + | |
- | IP: 192.168.239.1 | + | |
- | Containers: | + | |
- | nginx: | + | |
- | Container ID: | + | |
- | Image: | + | |
- | Image ID: | + | |
- | Port: < | + | |
- | Host Port: < | + | |
- | State: | + | |
- | Started: | + | |
- | Ready: | + | |
- | Restart Count: | + | |
- | Environment: | + | |
- | Mounts: | + | |
- | / | + | |
- | Conditions: | + | |
- | | + | |
- | Initialized | + | |
- | Ready | + | |
- | ContainersReady | + | |
- | PodScheduled | + | |
- | Volumes: | + | |
- | kube-api-access-pmfww: | + | |
- | Type: Projected (a volume that contains injected data from multiple sources) | + | |
- | | + | |
- | ConfigMapName: | + | |
- | ConfigMapOptional: | + | |
- | DownwardAPI: | + | |
- | QoS Class: | + | |
- | Node-Selectors: | + | |
- | Tolerations: | + | |
- | | + | |
- | Events: | + | |
- | Type Reason | + | |
- | ---- ------ | + | |
- | Normal | + | |
- | Normal | + | |
- | | + | |
- | Normal | + | |
- | Normal | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | Deploy Commands: |
- | **Important** | + | rollout |
- | </ | + | |
+ | autoscale | ||
- | Utilisez maintenant le commande kubectl avec l' | + | Cluster Management Commands: |
+ | certificate | ||
+ | cluster-info | ||
+ | top | ||
+ | cordon | ||
+ | uncordon | ||
+ | drain Drain node in preparation for maintenance | ||
+ | taint | ||
- | < | + | Troubleshooting and Debugging Commands: |
- | root@kubemaster:~# kubectl get pods -o wide | + | |
- | NAME READY | + | |
- | nginx | + | attach |
- | </ | + | exec Execute a command in a container |
+ | port-forward | ||
+ | proxy | ||
+ | | ||
+ | auth Inspect authorization | ||
+ | debug | ||
- | <WRAP center round important 60%> | + | Advanced Commands: |
- | **Important** | + | diff Diff the live version against a would-be applied version |
- | </ | + | apply Apply a configuration to a resource by file name or stdin |
+ | patch | ||
+ | replace | ||
+ | | ||
+ | | ||
- | <WRAP center round important 60%> | + | Settings Commands: |
- | **Important** : Notez que dans la colonne **NOMINATED NODE** il est marqué **< | + | |
- | </ | + | annotate |
+ | completion | ||
- | <WRAP center round important 60%> | + | Other Commands: |
- | **Important** : Notez que dans la colonne **READINESS GATES** il est marqué **< | + | |
- | </ | + | api-resources |
+ | api-versions | ||
+ | | ||
+ | plugin | ||
+ | version | ||
- | ====1.3 - Création d'un POD à l'aide d'un fichier YAML==== | + | Usage: |
+ | kubectl [flags] [options] | ||
- | Kubernetes utilise des fichiers YAML pour créer des objets. Par conséquent, | + | Use " |
- | + | Use " | |
- | <code> | + | |
- | root@kubemaster: | + | |
- | root@kubemaster: | + | |
- | --- | + | |
- | apiVersion: v1 | + | |
- | kind: Pod | + | |
- | metadata: | + | |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | - name: nginx-container | + | |
- | image: nginx | + | |
</ | </ | ||
- | Dans ce fichier on trouve les champs suivants | + | Plus d' |
- | ===apiVersion=== | + | < |
+ | root@kubemaster: | ||
+ | Create a resource from a file or from stdin. | ||
- | * Ce champs est **obligatoire**, | + | JSON and YAML formats are accepted. |
- | * La version de l'API diffère selon le type d' | + | |
- | * La valeur du champs est sous la forme d'une chaîne. | + | |
- | ^ kind ^ apiVersion ^ | + | Examples: |
- | | Pod | v1 | | + | # Create a pod using the data in pod.json |
- | | Service | v1 | | + | |
- | | ReplicaSet | apps/v1 | | + | |
- | | Deployment | apps/v1 | | + | # Create a pod based on the JSON passed into stdin |
+ | cat pod.json | ||
+ | |||
+ | # Edit the data in registry.yaml in JSON then create the resource using the edited data | ||
+ | kubectl create -f registry.yaml --edit -o json | ||
- | ===kind=== | + | 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 | ||
- | * Ce champs est **obligatoire**, | + | Options: |
- | * La valeur de l' | + | |
+ | 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. | ||
- | ^ kind ^ apiVersion ^ | + | --dry-run=' |
- | | Pod | v1 | | + | Must be " |
- | | Service | v1 | | + | |
- | | ReplicaSet | apps/v1 | | + | |
- | | Deployment | apps/v1 | | + | |
- | ===metadata=== | + | --edit=false: |
+ | Edit the API resource before creating | ||
- | * Ce champs est **obligatoire**, | + | --field-manager=' |
- | * Il contient des informations telles le nom et les étiquettes, | + | Name of the manager used to track field ownership. |
- | * Les informations sont sous la forme d'un **dictionnaire** YAML : | + | |
- | < | + | |
- | metadata: | + | |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | </ | + | |
- | ===spec=== | + | -k, --kustomize='': |
+ | Process the kustomization directory. This flag can't be used together with -f or -R. | ||
- | * Ce champs est **obligatoire**, | + | -o, --output='': |
- | * Il contient des informations pour Kubernetes spécifiques au type d'objet à créer, | + | Output format. One of: (json, yaml, name, go-template, |
- | * Les informations sont sous la forme d'un **liste** YAML : | + | jsonpath-as-json, |
- | < | + | |
- | spec: | + | Raw URI to POST to the server. |
- | containers: | + | |
- | | + | |
- | image: nginx | + | |
- | </file> | + | |
- | ===Utilisation du Fichier YAML=== | + | -R, --recursive=false: |
+ | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests | ||
+ | organized within the same directory. | ||
- | Utilisez maintenant le fichier YAML afin de créer un POD : | + | --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. | ||
- | < | + | |
- | root@kubemaster: | + | |
- | pod/myapp-pod created | + | |
- | </ | + | |
- | < | + | --show-managed-fields=false: |
- | root@kubemaster:~# kubectl get pods | + | |
- | NAME READY | + | |
- | myapp-pod | + | |
- | nginx | + | |
- | </ | + | |
- | =====LAB #2 - Utilisation de Contrôleurs de Réplication et ReplicaSets===== | + | --template='': |
+ | Template string or path to template file to use when -o=go-template, | ||
+ | is golang templates [http:// | ||
- | ====2.1 - Contrôleurs de Réplication==== | + | --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. | ||
- | ===Présentation d'un Contrôleur de Réplication=== | + | --windows-line-endings=false: |
+ | Only relevant if --edit=true. Defaults to the line ending native to your platform. | ||
- | Un Contrôleur de Réplication permet d' | + | Usage: |
+ | kubectl create -f FILENAME [options] | ||
- | {{ : | + | Use " |
+ | Use " | ||
+ | </ | ||
- | Un Contrôleur de Réplication permet aussi de démarrer de nouveaux PODs en cas d' | + | Dernièrement |
- | {{ :elearning:workbooks: | + | < |
+ | root@kubemaster:~# kubectl options | ||
+ | The following options can be passed to any command: | ||
- | Dans le cas où le premier nœud venait à court de ressources, un Contrôleur de Réplication est capable de démarrer de nouveaux PODs sur un deuxième noeud : | + | --add-dir-header=false: |
+ | If true, adds the file directory to the header of the log messages (DEPRECATED: | ||
+ | release, see | ||
+ | https:// | ||
- | {{ :elearning:workbooks:debian: | + | --alsologtostderr=false: |
+ | log to standard error as well as files (no effect when -logtostderr=true) (DEPRECATED: will be removed in a | ||
+ | future release, see | ||
+ | https://github.com/ | ||
- | ===Mise en Application=== | + | --as='': |
+ | Username to impersonate for the operation. User could be a regular user or a service account in a namespace. | ||
- | Pour créer un Contrôleur de Réplication, | + | |
+ | Group to impersonate for the operation, this flag can be repeated to specify multiple groups. | ||
- | < | + | |
- | root@kubemaster: | + | UID to impersonate for the operation. |
- | root@kubemaster: | + | |
- | --- | + | |
- | apiVersion: v1 | + | |
- | kind: ReplicationController | + | |
- | metadata: | + | |
- | name: myapp-cr | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | template: | + | |
- | | + | --cache-dir='/ |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | | + | |
- | | + | |
- | replicas: 3 | + | --certificate-authority='' |
- | </ | + | Path to a cert file for the certificate authority |
- | Dans ce fichier est placée une section appelée **template**. Cette section est un gabarit pour la création de PODs supplémentaires et est identique au contenu du fichier **pod-definition.yaml** sans les champs apiVersion et kind : | + | |
+ | Path to a client certificate file for TLS | ||
- | < | + | |
- | root@kubemaster: | + | Path to a client key file for TLS |
- | apiVersion: v1 | + | |
- | kind: Pod | + | |
- | metadata: | + | |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | - name: nginx-container | + | |
- | image: nginx | + | |
- | </ | + | |
- | Le champs **replicas** qui se trouve au même niveau de **template** indique le nombre de PODs à créer. | + | --cluster='': |
+ | The name of the kubeconfig cluster to use | ||
- | Utilisez le fichier rc-definition.yaml pour créer le Contrôleur de Réplication | + | |
+ | The name of the kubeconfig context to use | ||
- | < | + | |
- | root@kubemaster: | + | If true, the server' |
- | replicationcontroller/ | + | |
- | </ | + | |
- | Pour visualiser le Contrôleur de Réplication, | + | --kubeconfig='' |
+ | Path to the kubeconfig file to use for CLI requests. | ||
- | < | + | --log-backtrace-at=: |
- | root@kubemaster:~# kubectl get replicationcontroller | + | when logging hits line file:N, emit a stack trace (DEPRECATED: |
- | NAME | + | |
- | myapp-cr | + | |
- | </code> | + | |
- | Pour visualiser les PODs créés par le Contrôleur de Réplication, utilisez la commande suivante | + | --log-dir='': |
+ | If non-empty, write log files in this directory (no effect when -logtostderr=true) (DEPRECATED: | ||
+ | removed in a future release, see | ||
+ | https:// | ||
- | < | + | |
- | root@kubemaster: | + | If non-empty, use this log file (no effect when -logtostderr=true) (DEPRECATED: |
- | NAME | + | |
- | myapp-cr-6gxg6 | + | |
- | myapp-cr-78frz | + | |
- | myapp-pod | + | |
- | nginx 1/1 | + | |
- | </code> | + | |
- | <WRAP center round important 60%> | + | |
- | **Important** : Notez que le Contrôleur de Réplication a créé deux replicas **myapp-cr-6gxg6** et **myapp-cr-78frz** car le premier existait déjà **myapp-pod**. Pour identifier un POD du même type déjà en place, le Contrôleur de Réplication se fie au champ **labels** dans la section **template**. | + | Defines the maximum size a log file can grow to (no effect when -logtostderr=true). Unit is megabytes. If the |
- | </WRAP> | + | value is 0, the maximum file size is unlimited. (DEPRECATED: |
+ | | ||
- | Supprimez maintenant le POD **myapp-pod** : | + | |
+ | Maximum number of seconds between log flushes | ||
- | < | + | --logtostderr=true: |
- | root@kubemaster:~# kubectl delete pod myapp-pod | + | log to standard error instead of files (DEPRECATED: will be removed in a future release, see |
- | pod "myapp-pod" deleted | + | |
- | </code> | + | |
- | Constatez ensuite la réaction du Contrôleur de Réplication | + | --match-server-version=false: |
+ | Require server version to match client version | ||
- | < | + | -n, --namespace='': |
- | root@kubemaster: | + | If present, the namespace scope for this CLI request |
- | NAME | + | |
- | myapp-cr-6gxg6 | + | |
- | myapp-cr-78frz | + | |
- | myapp-cr-pt4zt | + | |
- | nginx 1/1 | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | --one-output=false: |
- | **Important** | + | If true, only write logs to their native severity level (vs also writing to each lower severity level; no |
- | </WRAP> | + | effect when -logtostderr=true) (DEPRECATED: will be removed in a future release, see |
+ | | ||
- | Pour consulter le statut d'un Contrôleur de Réplication, | + | --password=' |
+ | Password for basic authentication to the API server | ||
- | < | + | --profile='none': |
- | root@kubemaster: | + | |
- | Name: | + | |
- | Namespace: | + | |
- | Selector: | + | |
- | Labels: | + | |
- | type=front-end | + | |
- | Annotations: | + | |
- | Replicas: | + | |
- | Pods Status: | + | |
- | Pod Template: | + | |
- | Labels: | + | |
- | | + | |
- | Containers: | + | |
- | | + | |
- | Image: | + | |
- | Port: <none> | + | |
- | Host Port: < | + | |
- | | + | |
- | Mounts: | + | |
- | Volumes: | + | |
- | Events: | + | |
- | Type Reason | + | |
- | ---- ------ | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | </ | + | |
- | Pour supprimer un Contrôleur de Réplication, | + | --profile-output=' |
+ | Name of the file to write the profile to | ||
- | < | + | |
- | root@kubemaster: | + | The length of time to wait before giving up on a single server request. Non-zero values should contain a |
- | replicationcontroller "myapp-cr" deleted | + | |
- | </ | + | |
- | ====2.2 | + | |
+ | The address and port of the Kubernetes API server | ||
- | ===Présentation d'un ReplicaSet=== | + | --skip-headers=false: |
+ | If true, avoid header prefixes in the log messages (DEPRECATED: | ||
+ | https:// | ||
- | Un ReplicaSet remplit la même fonction qu'un Contrôleur de Réplication. ReplicaSets sont la façon la plus récente de gérer la réplication. | + | --skip-log-headers=false: |
+ | If true, avoid headers when opening log files (no effect when -logtostderr=true) (DEPRECATED: | ||
+ | in a future release, see | ||
+ | https:// | ||
- | ===Mise en Application=== | + | --stderrthreshold=2: |
+ | logs at or above this threshold go to stderr when writing to files and stderr (no effect when | ||
+ | -logtostderr=true or -alsologtostderr=false) (DEPRECATED: | ||
+ | https:// | ||
- | Pour créer un ReplicaSet, créez le fichier **replicaset-definition.yaml** | + | |
+ | Server name to use for server certificate validation. If it is not provided, the hostname used to contact the | ||
+ | server is used | ||
- | < | + | |
- | root@kubemaster: | + | |
- | root@kubemaster: | + | |
- | --- | + | |
- | apiVersion: apps/v1 | + | |
- | kind: ReplicaSet | + | |
- | metadata: | + | |
- | name: myapp-replicaset | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | template: | + | |
- | | + | --user='' |
- | name: myapp-pod | + | |
- | labels: | + | |
- | | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | - name: nginx-container | + | |
- | image: nginx | + | |
- | replicas: 3 | + | --username='' |
- | selector: | + | |
- | matchLabels: | + | |
- | type: front-end | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | -v, --v=0: |
- | **Important** : Notez que dans le cas d'un ReplicaSet, celui-ci identifie les PODs sous son contrôle par la valeur du champ **matchLabels**.. | + | |
- | </ | + | |
- | Utilisez le fichier replicaset-definition.yaml pour créer le ReplicaSet | + | |
+ | comma-separated list of pattern=N settings for file-filtered logging | ||
- | < | + | |
- | root@kubemaster: | + | Treat warnings received from the server as errors and exit with a non-zero exit code |
- | replicaset.apps/ | + | |
</ | </ | ||
- | Pour visualiser | + | ====1.2 - Obtenir de l' |
- | < | + | ===La Commande version=== |
- | root@kubemaster: | + | |
- | NAME | + | |
- | myapp-replicaset | + | |
- | </ | + | |
- | Pour visualiser les PODs créés | + | Commencez |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME | + | Flag --short has been deprecated, and will be removed in the future. The --short output will become the default. |
- | myapp-replicaset-56gwv | + | Client Version: v1.25.0 |
- | myapp-replicaset-gh8gl | + | Kustomize Version: v4.5.7 |
- | myapp-replicaset-kz742 | + | Server Version: v1.25.0 |
- | nginx 1/1 | + | |
</ | </ | ||
- | Modifiez maintenant le fichier **replicaset-definition.yaml** en augmentant le nombre de replicas de 3 à **6** : | + | ===La Commande cluster-info=== |
- | < | + | Consultez |
- | root@kubemaster: | + | |
- | root@kubemaster: | + | |
- | --- | + | |
- | apiVersion: apps/v1 | + | |
- | kind: ReplicaSet | + | |
- | metadata: | + | |
- | name: myapp-replicaset | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | template: | + | |
- | + | ||
- | metadata: | + | |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | - name: nginx-container | + | |
- | image: nginx | + | |
- | + | ||
- | replicas: 6 | + | |
- | selector: | + | |
- | matchLabels: | + | |
- | type: front-end | + | |
- | </ | + | |
- | + | ||
- | Exécutez | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | replicaset.apps/myapp-replicaset replaced | + | Kubernetes control plane is running at https://192.168.56.2: |
- | </code> | + | CoreDNS is running at https://192.168.56.2: |
- | Visualiser le ReplicaSet : | + | To further debug and diagnose cluster problems, use 'kubectl |
- | + | ||
- | < | + | |
- | root@kubemaster: | + | |
- | NAME | + | |
- | myapp-replicaset | + | |
- | root@kubemaster: | + | |
- | NAME | + | |
- | myapp-replicaset | + | |
- | root@kubemaster: | + | |
- | NAME | + | |
- | myapp-replicaset | + | |
</ | </ | ||
- | Visualiser les PODs créés par le ReplicaSet : | + | ===La Commande api-versions=== |
- | + | ||
- | < | + | |
- | root@kubemaster: | + | |
- | NAME | + | |
- | myapp-replicaset-56gwv | + | |
- | myapp-replicaset-7g6r4 | + | |
- | myapp-replicaset-7rsnc | + | |
- | myapp-replicaset-gh8gl | + | |
- | myapp-replicaset-kz742 | + | |
- | myapp-replicaset-twcwg | + | |
- | nginx 1/1 | + | |
- | </ | + | |
- | Exécutez ensuite | + | Afin de connaître les versions des API compatibles avec la version de Kubernetes installée, exécutez |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | replicaset.apps/myapp-replicaset scaled | + | admissionregistration.k8s.io/v1 |
+ | apiextensions.k8s.io/v1 | ||
+ | apiregistration.k8s.io/ | ||
+ | apps/v1 | ||
+ | authentication.k8s.io/ | ||
+ | authorization.k8s.io/ | ||
+ | autoscaling/ | ||
+ | autoscaling/ | ||
+ | autoscaling/ | ||
+ | batch/v1 | ||
+ | certificates.k8s.io/ | ||
+ | coordination.k8s.io/ | ||
+ | crd.projectcalico.org/ | ||
+ | discovery.k8s.io/ | ||
+ | events.k8s.io/ | ||
+ | flowcontrol.apiserver.k8s.io/ | ||
+ | flowcontrol.apiserver.k8s.io/ | ||
+ | networking.k8s.io/ | ||
+ | node.k8s.io/ | ||
+ | policy/v1 | ||
+ | rbac.authorization.k8s.io/ | ||
+ | scheduling.k8s.io/ | ||
+ | storage.k8s.io/ | ||
+ | storage.k8s.io/ | ||
+ | v1 | ||
</ | </ | ||
- | Visualiser le ReplicaSet : | + | ===La Commande api-resources=== |
- | < | + | La commande **api-resources** permet de consulter la liste des ressources du cluster, à savoir : |
- | root@kubemaster: | + | |
- | NAME | + | |
- | myapp-replicaset | + | |
- | </ | + | |
- | Visualiser les PODs créés par le ReplicaSet : | + | * le nom de la ressource - **NAME**, |
+ | * le nom court à utiliser avec kubectl - **SHORTNAMES**, | ||
+ | * le groupe API auquel la ressource appartient - **APIVERSION**, | ||
+ | * si oui ou non la ressource est liée à un namespace - **NAMESPACED**, | ||
+ | * le type KIND de la ressource - **KIND**. | ||
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME READY | + | NAME |
- | myapp-replicaset-56gwv | + | bindings |
- | myapp-replicaset-7g6r4 | + | componentstatuses |
- | myapp-replicaset-7rsnc | + | configmaps |
- | myapp-replicaset-gh8gl | + | endpoints |
- | myapp-replicaset-klsvp | + | events |
- | myapp-replicaset-kz742 | + | limitranges |
- | myapp-replicaset-twcwg | + | namespaces |
- | myapp-replicaset-vqsxc | + | nodes |
- | myapp-replicaset-z9l65 | + | persistentvolumeclaims |
- | nginx 1/1 | + | persistentvolumes |
+ | pods po | ||
+ | podtemplates | ||
+ | replicationcontrollers | ||
+ | resourcequotas | ||
+ | secrets | ||
+ | serviceaccounts | ||
+ | services | ||
+ | mutatingwebhookconfigurations | ||
+ | validatingwebhookconfigurations | ||
+ | customresourcedefinitions | ||
+ | apiservices | ||
+ | controllerrevisions | ||
+ | daemonsets | ||
+ | deployments | ||
+ | replicasets | ||
+ | statefulsets | ||
+ | tokenreviews | ||
+ | localsubjectaccessreviews | ||
+ | selfsubjectaccessreviews | ||
+ | selfsubjectrulesreviews | ||
+ | subjectaccessreviews | ||
+ | horizontalpodautoscalers | ||
+ | cronjobs | ||
+ | jobs | ||
+ | certificatesigningrequests | ||
+ | leases | ||
+ | bgpconfigurations | ||
+ | bgppeers | ||
+ | blockaffinities | ||
+ | caliconodestatuses | ||
+ | clusterinformations | ||
+ | felixconfigurations | ||
+ | globalnetworkpolicies | ||
+ | globalnetworksets | ||
+ | hostendpoints | ||
+ | ipamblocks | ||
+ | ipamconfigs | ||
+ | ipamhandles | ||
+ | ippools | ||
+ | ipreservations | ||
+ | kubecontrollersconfigurations | ||
+ | networkpolicies | ||
+ | networksets | ||
+ | endpointslices | ||
+ | events | ||
+ | flowschemas | ||
+ | prioritylevelconfigurations | ||
+ | ingressclasses | ||
+ | ingresses | ||
+ | networkpolicies | ||
+ | runtimeclasses | ||
+ | poddisruptionbudgets | ||
+ | clusterrolebindings | ||
+ | clusterroles | ||
+ | rolebindings | ||
+ | roles rbac.authorization.k8s.io/ | ||
+ | priorityclasses | ||
+ | csidrivers | ||
+ | csinodes | ||
+ | csistoragecapacities | ||
+ | storageclasses | ||
+ | volumeattachments | ||
</ | </ | ||
- | Notez que dans ce cas, la valeur des **replicas** dans le fichier **replicaset-definition.yaml** n'a pas été modifiée : | + | ====1.3 - Obtenir de l'Information sur les Noeuds==== |
- | < | + | ===La Commande describe node=== |
- | root@kubemaster: | + | |
- | --- | + | |
- | apiVersion: apps/v1 | + | |
- | kind: ReplicaSet | + | |
- | metadata: | + | |
- | name: myapp-replicaset | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | template: | + | |
- | metadata: | + | De l' |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | - name: nginx-container | + | |
- | image: nginx | + | |
- | | + | |
- | | + | |
- | matchLabels: | + | |
- | type: front-end | + | |
- | </ | + | |
- | + | ||
- | Dernièrement, | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | replicaset.extensions/myapp-replicaset scaled | + | Name: |
+ | Roles: | ||
+ | Labels: | ||
+ | beta.kubernetes.io/ | ||
+ | kubernetes.io/ | ||
+ | kubernetes.io/ | ||
+ | kubernetes.io/ | ||
+ | node-role.kubernetes.io/ | ||
+ | node.kubernetes.io/ | ||
+ | Annotations: | ||
+ | node.alpha.kubernetes.io/ | ||
+ | projectcalico.org/ | ||
+ | projectcalico.org/ | ||
+ | volumes.kubernetes.io/ | ||
+ | CreationTimestamp: | ||
+ | Taints: | ||
+ | Unschedulable: | ||
+ | Lease: | ||
+ | HolderIdentity: | ||
+ | AcquireTime: | ||
+ | RenewTime: | ||
+ | Conditions: | ||
+ | Type | ||
+ | ---- | ||
+ | NetworkUnavailable | ||
+ | MemoryPressure | ||
+ | DiskPressure | ||
+ | PIDPressure | ||
+ | Ready True Sun, 04 Sep 2022 16:52:48 +0200 Sun, 04 Sep 2022 12:15:32 +0200 | ||
+ | ... | ||
</ | </ | ||
- | Visualiser le ReplicaSet | + | Dans la deuxième partie de la sortie, on peut constater |
- | < | + | * la section **Addresses:** contenant l' |
- | root@kubemaster:~# kubectl get replicaset | + | |
- | NAME | + | |
- | myapp-replicaset | + | |
- | </ | + | |
- | + | ||
- | Visualiser les PODs créés par le ReplicaSet : | + | |
< | < | ||
- | root@kubemaster:~# kubectl get pods | + | ... |
- | NAME | + | Addresses: |
- | myapp-replicaset-56gwv | + | |
- | myapp-replicaset-7g6r4 | + | Hostname: |
- | myapp-replicaset-gh8gl | + | Capacity: |
- | nginx 1/1 | + | cpu: 4 |
+ | ephemeral-storage: | ||
+ | hugepages-2Mi: | ||
+ | | ||
+ | pods: 110 | ||
+ | Allocatable: | ||
+ | cpu: 4 | ||
+ | ephemeral-storage: | ||
+ | | ||
+ | | ||
+ | pods: 110 | ||
+ | ... | ||
</ | </ | ||
- | Créez maintenant un POD en dehors du ReplicaSet | + | Dans la troisième partie de la sortie, on peut constater |
- | < | + | * la section **System Info:** contenant de l' |
- | root@kubemaster:~# kubectl create -f pod-definition.yaml | + | * la section **Non-terminated Pods** contenant de l' |
- | pod/myapp-pod created | + | |
- | </ | + | |
- | + | ||
- | Consultez | + | |
< | < | ||
- | root@kubemaster:~# kubectl get pods | + | ... |
- | NAME | + | System Info: |
- | myapp-pod | + | |
- | myapp-replicaset-56gwv | + | |
- | myapp-replicaset-7g6r4 | + | Boot ID: 9bd56aa5-b94c-40d3-804a-a54bd8daf305 |
- | myapp-replicaset-gh8gl | + | Kernel Version: |
- | nginx 1/1 | + | OS Image: |
+ | Operating System: | ||
+ | Architecture: | ||
+ | Container Runtime Version: | ||
+ | Kubelet Version: | ||
+ | Kube-Proxy Version: | ||
+ | PodCIDR: | ||
+ | PodCIDRs: | ||
+ | Non-terminated Pods: (7 in total) | ||
+ | | ||
+ | | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | ... | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | Dans la dernière partie de la sortie, on peut constater : |
- | **Important** : Notez que **myapp-pod** est dans un état **Terminating**. En effet le ReplicaSet ne permet pas la création d'un POD ayant la même étiquette que celle spécifiée par le champ **matchLabels** du fichier **replicaset-definition.yaml**. | + | |
- | </ | + | |
- | Pour supprimer le ReplicaSet, utilisez | + | * la section **Allocated resources:** qui indique les ressources allouées au noeud. |
< | < | ||
- | root@kubemaster:~# kubectl delete replicaset myapp-replicaset | + | Allocated resources: |
- | replicaset.extensions "myapp-replicaset" | + | |
+ | Resource | ||
+ | | ||
+ | cpu 1 (25%) 0 (0%) | ||
+ | memory | ||
+ | ephemeral-storage | ||
+ | hugepages-2Mi | ||
+ | Events: | ||
+ | Type Reason | ||
+ | ---- ------ | ||
+ | Normal | ||
</ | </ | ||
- | Consultez maintenant tous les objets du cluster : | + | ===La Commande top=== |
+ | |||
+ | La commande **top** nécessite à ce que l'API **Metrics** soit disponible dans le cluster. Pour déployer le serveur Metrics, téléchargez le fichier **components.yaml** | ||
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME READY | + | |
- | pod/nginx 1/1 | + | |
- | + | ||
- | NAME | + | |
- | service/kubernetes | + | |
</ | </ | ||
- | =====LAB #3 - Gestion des Deployments===== | + | Modifiez la section |
- | + | ||
- | ====3.1 - Présentation d'un Deployment==== | + | |
- | + | ||
- | Un **Deployment** sous Kubernetes est un objet hiérarchiquement supérieur à un ReplicaSet : | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | Le Deployment permet la gestion des : | + | |
- | + | ||
- | * déploiements de PODs (Rollouts), | + | |
- | * mises à jour roulantes (Rolling Updates), | + | |
- | * retours en arrière (Rollbacks). | + | |
- | + | ||
- | ====3.2 - Mise en Application==== | + | |
- | + | ||
- | ===Rollouts=== | + | |
- | + | ||
- | Pour créer un Deployment, il convient de créer un fichier YAML. Créez donc le fichier **deployment-definition.yaml** : | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | root@kubemaster: | + | root@kubemaster: |
- | --- | + | ... |
- | apiVersion: apps/v1 | + | |
- | kind: Deployment | + | |
- | metadata: | + | |
- | name: myapp-deployment | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | template: | + | |
- | + | ||
- | metadata: | + | |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
spec: | spec: | ||
containers: | containers: | ||
- | - name: nginx-container | + | - args: |
- | | + | - --cert-dir=/tmp |
- | + | | |
- | | + | - --kubelet-insecure-tls |
- | | + | - --kubelet-preferred-address-types=InternalIP, |
- | matchLabels: | + | - --kubelet-use-node-status-port |
- | type: front-end | + | ... |
</ | </ | ||
- | Utilisez la commande suivante pour créer | + | Déployez |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.apps/ | + | serviceaccount/ |
+ | clusterrole.rbac.authorization.k8s.io/ | ||
+ | clusterrole.rbac.authorization.k8s.io/ | ||
+ | rolebinding.rbac.authorization.k8s.io/ | ||
+ | clusterrolebinding.rbac.authorization.k8s.io/ | ||
+ | clusterrolebinding.rbac.authorization.k8s.io/ | ||
+ | service/ | ||
+ | deployment.apps/ | ||
+ | apiservice.apiregistration.k8s.io/ | ||
</ | </ | ||
- | Constatez la création de celui-ci | + | Vérifiez l' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME | + | NAMESPACE |
- | myapp-deployment | + | default |
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
</ | </ | ||
- | Notez que la création du Deployment a également créé un ReplicaSet | + | Pour connaître l' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME | + | NAME |
- | myapp-deployment-689f9d59 | + | kubemaster.ittraining.loc |
+ | kubenode1.ittraining.loc | ||
+ | kubenode2.ittraining.loc | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | Pour voir l' |
- | **Important** : Notez que la valeur | + | |
- | </ | + | |
- | + | ||
- | Bien entendu, la création de Deployment a créé le nombre de PODs indiqué dans le fichier YAML : | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME | + | Every 2,0s: kubectl top nodes kubemaster.ittraining.loc: |
- | myapp-deployment-689f9d59-cmxlm | + | |
- | myapp-deployment-689f9d59-kt88s | + | NAME |
- | myapp-deployment-689f9d59-zlwp4 | + | kubemaster.ittraining.loc |
+ | kubenode1.ittraining.loc | ||
+ | kubenode2.ittraining.loc | ||
+ | ... | ||
+ | ^C | ||
+ | root@kubemaster: | ||
</ | </ | ||
- | Pour voir tous ces objets en même temps, utilisez | + | <WRAP center round important 60%> |
+ | **Important** : Notez l' | ||
+ | </ | ||
- | < | + | Il est possible de trier la sortie par ordre décroissant de l' |
- | root@kubemaster: | + | |
- | NAME READY | + | |
- | pod/ | + | |
- | pod/ | + | |
- | pod/ | + | |
- | + | ||
- | NAME | + | |
- | service/ | + | |
- | + | ||
- | NAME | + | |
- | deployment.apps/ | + | |
- | + | ||
- | NAME DESIRED | + | |
- | replicaset.apps/ | + | |
- | </ | + | |
- | + | ||
- | Pour obtenir plus d' | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | Name: myapp-deployment | + | NAME CPU(cores) |
- | Namespace: | + | kubemaster.ittraining.loc |
- | CreationTimestamp: | + | kubenode1.ittraining.loc |
- | Labels: | + | kubenode2.ittraining.loc |
- | | + | |
- | Annotations: | + | |
- | Selector: | + | |
- | Replicas: | + | |
- | StrategyType: | + | |
- | MinReadySeconds: | + | |
- | RollingUpdateStrategy: | + | |
- | Pod Template: | + | |
- | Labels: | + | |
- | type=front-end | + | |
- | Containers: | + | |
- | | + | |
- | | + | |
- | Port: < | + | |
- | Host Port: < | + | |
- | Environment: | + | |
- | Mounts: | + | |
- | Volumes: | + | |
- | Conditions: | + | |
- | Type | + | |
- | ---- | + | |
- | Available | + | |
- | Progressing | + | |
- | OldReplicaSets: | + | |
- | NewReplicaSet: | + | |
- | Events: | + | |
- | Type Reason | + | |
- | ---- ------ | + | |
- | Normal | + | |
</ | </ | ||
- | Lors du Rollout du Deployment une **Révision** est créée. Cette Révision est incrémentée lors de chaque mise-à-jour : | + | Dernièrement, il est possible de trier la sortie par ordre décroissant de l'utilisation de la mémoire |
- | + | ||
- | {{ : | + | |
- | + | ||
- | Pour consulter le statut du Rollout, il convient d'utiliser | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment "myapp-deployment" | + | NAME CPU(cores) |
+ | kubemaster.ittraining.loc | ||
+ | kubenode1.ittraining.loc | ||
+ | kubenode2.ittraining.loc | ||
</ | </ | ||
- | Pour consulter la liste des Révisions, utilisez la commande suivante : | + | ====1.4 - Obtenir de l' |
- | < | + | ===La Commande describe pod=== |
- | root@kubemaster: | + | |
- | deployment.apps/ | + | |
- | REVISION | + | |
- | 1 < | + | |
- | </ | + | Tout comme avec les noeuds, des informations concernant un pod spécifique peuvent être obtenues en utilisant |
- | + | ||
- | <WRAP center round important 60%> | + | |
- | **Important** : Notez que la valeur de **CHANGE-CAUSE** est **< | + | |
- | </ | + | |
- | + | ||
- | Supprimez donc le Deployment avec la commande suivante | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.extensions "myapp-deployment" deleted | + | 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/myapp-deployment-689f9d59 | ||
+ | Containers: | ||
+ | nginx-container: | ||
+ | Container ID: | ||
+ | Image: | ||
+ | Image ID: | ||
+ | Port: < | ||
+ | Host Port: < | ||
+ | State: | ||
+ | Started: | ||
+ | Ready: | ||
+ | Restart Count: | ||
+ | Environment: | ||
+ | Mounts: | ||
+ | / | ||
+ | Conditions: | ||
+ | Type Status | ||
+ | Initialized | ||
+ | Ready True | ||
+ | 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: | ||
</ | </ | ||
- | Vérifiez la suppression du Deployment : | + | ===La Commande top=== |
- | + | ||
- | < | + | |
- | root@kubemaster: | + | |
- | NAME | + | |
- | service/ | + | |
- | </ | + | |
- | Créez le Deployment | + | Il est possible |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.apps/myapp-deployment | + | NAME CPU(cores) |
+ | myapp-deployment-689f9d59-c25f9 | ||
+ | myapp-deployment-689f9d59-nn9sw | ||
+ | myapp-deployment-689f9d59-rnc4r | ||
</ | </ | ||
- | Consultez le statut | + | Triez maintenant la sortie par ordre décroissant de l' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment | + | NAME CPU(cores) |
+ | myapp-deployment-689f9d59-c25f9 | ||
+ | myapp-deployment-689f9d59-nn9sw | ||
+ | myapp-deployment-689f9d59-rnc4r | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | Triez maintenant la sortie par ordre décroissant de l'utilisation de la mémoire |
- | **Important** : Notez qu'un Deployment peut être mis en pause avec la commande **kubectl rollout pause deployment < | + | |
- | </ | + | |
- | + | ||
- | Consultez | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.apps/ | + | NAME CPU(cores) |
- | REVISION | + | myapp-deployment-689f9d59-nn9sw |
- | 1 | + | myapp-deployment-689f9d59-rnc4r |
+ | myapp-deployment-689f9d59-c25f9 | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | ====1.5 |
- | **Important** : Notez que la valeur de **CHANGE-CAUSE** est la commande | + | |
- | </ | + | |
- | ===Rolling Updates=== | + | Créez |
- | + | ||
- | Il existe deux méthodes de Deployment en cas de mise-à-jours : | + | |
- | + | ||
- | * **Recreate**, | + | |
- | * Dans ce cas tous les PODs existants sont détruits en même temps et des PODs contenant la mise-à-jour sont créés dans un deuxième temps. L' | + | |
- | * **Rolling Update** | + | |
- | * Dans ce cas, les PODs sont détruits un-par-un. Après chaque destruction, | + | |
- | + | ||
- | <WRAP center round important 60%> | + | |
- | **Important** : Notez que **Rolling Update** est la méthode par défaut. | + | |
- | </ | + | |
- | + | ||
- | Modifiez maintenant | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | root@kubemaster: | + | root@kubemaster: |
- | --- | + | apiVersion: v1 |
- | apiVersion: | + | kind: Pod |
- | kind: Deployment | + | |
metadata: | metadata: | ||
- | name: myapp-deployment | + | name: my-pod |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
spec: | spec: | ||
- | | + | |
+ | - name: busybox | ||
+ | image: radial/ | ||
+ | command: [' | ||
+ | </ | ||
- | metadata: | + | ====La Commande apply==== |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | - name: nginx-container | + | |
- | image: nginx: | + | |
- | + | ||
- | replicas: 3 | + | |
- | selector: | + | |
- | matchLabels: | + | |
- | type: front-end | + | |
- | </ | + | |
- | Appliquez ce changement | + | Créez maintenant le pod en utilisant le fichier **pod.yaml** |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | Flag --record has been deprecated, --record will be removed in the future | + | pod/my-pod created |
- | Warning: resource deployments/myapp-deployment is missing the kubectl.kubernetes.io/ | + | |
- | deployment.apps/ | + | |
</ | </ | ||
- | Consultez | + | ====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: | + | root@kubemaster: |
- | Waiting for deployment | + | Error from server (AlreadyExists): |
- | Waiting for deployment | + | |
- | deployment | + | |
</ | </ | ||
- | Notez qu'il y a maintenant une **Révision** supplémentaire | + | Pour consulter la liste des objets qui peuvent être créés, utilisez la commande |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.apps/ | + | Error: must specify one of -f and -k |
- | REVISION | + | |
- | 1 kubectl create | + | |
- | 2 | + | |
- | </ | + | |
- | Consultez les détails du Deployment **myapp-deployment** : | + | Create a resource from a file or from stdin. |
- | < | + | JSON and YAML formats are accepted. |
- | root@kubemaster: | + | |
- | Name: | + | |
- | Namespace: | + | |
- | CreationTimestamp: | + | |
- | Labels: | + | |
- | type=front-end | + | |
- | Annotations: | + | |
- | kubernetes.io/ | + | |
- | Selector: | + | |
- | Replicas: | + | |
- | StrategyType: | + | |
- | MinReadySeconds: | + | |
- | RollingUpdateStrategy: | + | |
- | Pod Template: | + | |
- | Labels: | + | |
- | | + | |
- | Containers: | + | |
- | | + | |
- | Image: | + | |
- | Port: < | + | |
- | Host Port: < | + | |
- | Environment: | + | |
- | Mounts: | + | |
- | Volumes: | + | |
- | Conditions: | + | |
- | Type | + | |
- | ---- | + | |
- | Available | + | |
- | Progressing | + | |
- | OldReplicaSets: | + | |
- | NewReplicaSet: | + | |
- | Events: | + | |
- | Type Reason | + | |
- | ---- ------ | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | Examples: |
- | **Important** : Notez que l' | + | # Create a pod using the data in pod.json |
- | </ | + | kubectl create |
+ | |||
+ | # 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 | ||
- | Lors de la mise-à-jour le Deployment crée un autre ReplicaSet contenant les PODs mis-à-jour en suivant la méthode Rolling Update. Ceci peut être vu en regardant la sortie de la commande **kubectl get replicasets** | + | 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: |
- | root@kubemaster:~# kubectl get replicasets | + | --allow-missing-template-keys=true: |
- | NAME DESIRED | + | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to |
- | myapp-deployment-57c6cb89d9 | + | |
- | myapp-deployment-689f9d59 | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | --dry-run=' |
- | **Important** : Notez que le nombre d' | + | Must be " |
- | </ | + | sending it. If server strategy, submit server-side request without persisting the resource. |
- | La modification de la version de l' | + | --edit=false: |
+ | Edit the API resource before creating | ||
- | < | + | |
- | root@kubemaster: | + | Name of the manager used to track field ownership. |
- | Flag --record has been deprecated, --record will be removed in the future | + | |
- | deployment.apps/ | + | |
- | </ | + | |
- | Le nom du conteneur **nginx-container** est défini dans le fichier de définition du POD : | + | |
+ | Filename, directory, or URL to files to use to create the resource | ||
- | < | + | |
- | root@kubemaster: | + | |
- | --- | + | |
- | apiVersion: v1 | + | |
- | kind: Pod | + | |
- | metadata: | + | |
- | name: myapp-pod | + | |
- | labels: | + | |
- | app: myapp | + | |
- | type: front-end | + | |
- | spec: | + | |
- | containers: | + | |
- | - name: nginx-container | + | |
- | image: nginx | + | |
- | </ | + | |
- | Consultez le statut du Deployment | + | -o, --output='' |
+ | Output format. One of: (json, yaml, name, go-template, | ||
+ | jsonpath-as-json, | ||
- | < | + | |
- | root@kubemaster: | + | Raw URI to POST to the server. |
- | deployment "myapp-deployment" | + | |
- | </ | + | |
- | Notez qu'il y a maintenant une **Révision** supplémentaire | + | -R, --recursive=false: |
+ | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests | ||
+ | organized within the same directory. | ||
- | < | + | |
- | root@kubemaster: | + | If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will |
- | deployment.apps/ | + | be unchanged. This flag is useful when you want to perform |
- | REVISION | + | |
- | 1 | + | |
- | 2 kubectl apply --filename=deployment-definition.yaml --record=true | + | |
- | 3 | + | |
- | </ | + | |
- | Lors de la mise-à-jour le Deployment crée un autre ReplicaSet contenant les PODs mis-à-jour en suivant la méthode Rolling Update. Ceci peut être vu en regardant la sortie de la commande **kubectl get replicasets** : | + | |
+ | Selector (label query) to filter on, supports ' | ||
+ | objects must satisfy all of the specified label constraints. | ||
- | < | + | |
- | root@kubemaster: | + | If true, keep the managedFields when printing objects in JSON or YAML format. |
- | NAME DESIRED | + | |
- | myapp-deployment-57c6cb89d9 | + | |
- | myapp-deployment-689f9d59 | + | |
- | myapp-deployment-6c95f449f5 | + | |
- | </ | + | |
- | Consultez les détails du Deployment **myapp-deployment** | + | |
+ | Template string or path to template file to use when -o=go-template, | ||
+ | is golang templates [http:// | ||
- | < | + | |
- | root@kubemaster: | + | Must be one of: strict (or true), warn, ignore (or false). " |
- | Name: myapp-deployment | + | |
- | Namespace: | + | |
- | CreationTimestamp: Wed, 13 Jul 2022 07:44:43 +0200 | + | warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled |
- | Labels: | + | on the API server, and behave as " |
- | type=front-end | + | |
- | Annotations: | + | |
- | kubernetes.io/ | + | |
- | Selector: | + | |
- | Replicas: | + | |
- | StrategyType: | + | |
- | MinReadySeconds: | + | |
- | RollingUpdateStrategy: | + | |
- | Pod Template: | + | |
- | Labels: | + | |
- | | + | |
- | Containers: | + | |
- | | + | |
- | Image: | + | |
- | | + | |
- | Host Port: < | + | |
- | Environment: | + | |
- | Mounts: | + | |
- | Volumes: | + | |
- | Conditions: | + | |
- | Type | + | |
- | | + | |
- | Available | + | |
- | Progressing | + | |
- | OldReplicaSets: | + | |
- | NewReplicaSet: | + | |
- | Events: | + | |
- | Type Reason | + | |
- | ---- ------ | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | | + | |
- | | + | |
- | | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | Normal | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | --windows-line-endings=false: |
- | **Important** : Notez que l' | + | Only relevant if --edit=true. Defaults to the line ending native to your platform. |
- | </ | + | |
- | ===Rollbacks=== | + | Usage: |
+ | kubectl create -f FILENAME [options] | ||
- | Grâce au système des **Révisions**, | + | Use " |
- | + | Use "kubectl | |
- | < | + | |
- | root@kubemaster: | + | |
- | deployment.extensions/ | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | La commande |
- | **Important** : Notez qu' | + | |
- | </ | + | |
- | + | ||
- | Saisissez la commande **kubectl get replicasets** | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME DESIRED | + | pod/my-pod unchanged |
- | myapp-deployment-57c6cb89d9 | + | |
- | myapp-deployment-689f9d59 | + | |
- | myapp-deployment-6c95f449f5 | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | ====La Commande get==== |
- | **Important** : Notez que l' | + | |
- | </ | + | |
- | Utilisez la commande **kubectl rollout history** | + | Constatez le statut du pod : |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.apps/ | + | NAME READY |
- | REVISION | + | my-pod 1/1 Running |
- | 1 kubectl create | + | myapp-deployment-689f9d59-c25f9 |
- | 3 | + | myapp-deployment-689f9d59-nn9sw |
- | 4 | + | myapp-deployment-689f9d59-rnc4r |
</ | </ | ||
- | <WRAP center round important 60%> | + | Rappelez-vous |
- | **Important** : Notez que Révision 2 est devenue la Révision 4 démontrant ainsi le Rollback. | + | |
- | </ | + | |
- | + | ||
- | Créez maintenant | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.extensions/ | + | NAME READY |
+ | my-pod | ||
+ | myapp-deployment-689f9d59-c25f9 | ||
+ | myapp-deployment-689f9d59-nn9sw | ||
+ | myapp-deployment-689f9d59-rnc4r | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | Pour ne voir qu'un seul pod, il convient de préciser son nom en tant qu' |
- | **Important** : Notez que l'erreur est **nginx1.14** qui devrait être **nginx: | + | |
- | </ | + | |
- | + | ||
- | Constatez le statut du Deployment | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | Waiting for deployment "myapp-deployment" | + | NAME |
- | ^C | + | my-pod 1/1 |
</ | </ | ||
- | <WRAP center round important 60%> | + | ====Utilisation des Options==== |
- | **Important** : Notez que le Rollout est bloqué. L' | + | |
- | </ | + | |
- | Pour visualiser ce qui se passe, utilisez la commande | + | Rappelez-vous que l' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME | + | NAME READY STATUS |
- | myapp-deployment | + | my-pod 1/1 |
+ | myapp-deployment-689f9d59-c25f9 | ||
+ | myapp-deployment-689f9d59-nn9sw | ||
+ | myapp-deployment-689f9d59-rnc4r | ||
</ | </ | ||
- | La commande **kubectl get pods** démontre un statut | + | L' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME READY | + | { |
- | myapp-deployment-57c6cb89d9-dh4cb 1/1 | + | " |
- | myapp-deployment-57c6cb89d9-f69nk | + | " |
- | myapp-deployment-57c6cb89d9-q7d4p | + | { |
- | myapp-deployment-74f697676f-2z95l | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ": | ||
+ | "while true; do sleep 3600; done\" | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | "while true; do sleep 3600; done" | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | --More-- | ||
</ | </ | ||
- | En consultant | + | L' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.apps/ | + | apiVersion: v1 |
- | REVISION | + | items: |
- | 1 kubectl | + | - apiVersion: v1 |
- | 3 | + | |
- | 4 | + | |
- | 5 | + | annotations: |
+ | cni.projectcalico.org/ | ||
+ | cni.projectcalico.org/ | ||
+ | cni.projectcalico.org/ | ||
+ | | ||
+ | {" | ||
+ | ers": | ||
+ | creationTimestamp: | ||
+ | name: my-pod | ||
+ | namespace: default | ||
+ | resourceVersion: | ||
+ | uid: 628ca9e4-2fbe-4fc9-b0fa-9a05ef942a07 | ||
+ | | ||
+ | containers: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | image: radial/busyboxplus: | ||
+ | imagePullPolicy: | ||
+ | name: busybox | ||
+ | resources: {} | ||
+ | terminationMessagePath: | ||
+ | terminationMessagePolicy: | ||
+ | volumeMounts: | ||
+ | | ||
+ | name: kube-api-access-qwzzv | ||
+ | readOnly: | ||
+ | dnsPolicy: ClusterFirst | ||
+ | enableServiceLinks: | ||
+ | nodeName: kubenode2.ittraining.loc | ||
+ | preemptionPolicy: | ||
+ | priority: 0 | ||
+ | restartPolicy: | ||
+ | --More-- | ||
</ | </ | ||
- | Pour rectifier cette erreur il convient | + | L' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | deployment.extensions/ | + | NAME READY |
+ | myapp-deployment-689f9d59-c25f9 | ||
+ | myapp-deployment-689f9d59-nn9sw | ||
+ | myapp-deployment-689f9d59-rnc4r | ||
+ | my-pod | ||
</ | </ | ||
- | Constatez ensuite la réussite | + | L' |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME READY | + | NAME READY |
- | myapp-deployment-57c6cb89d9-dh4cb | + | calico-node-5htrc 1/1 |
- | myapp-deployment-57c6cb89d9-f69nk | + | calico-node-dc7hd 1/1 |
- | myapp-deployment-57c6cb89d9-q7d4p | + | calico-node-qk5kt 1/1 |
- | + | ||
- | root@kubemaster: | + | |
- | deployment.apps/ | + | |
- | REVISION | + | |
- | 1 | + | |
- | 3 | + | |
- | 5 | + | |
- | 6 | + | |
</ | </ | ||
- | =====LAB #4 - Gestion de la Maintenance d'un Noeud===== | + | ====La Commande exec==== |
- | Afin de procéer à la maintenance | + | La commande **exec** permet |
- | + | ||
- | ====4.1 - La Commande drain==== | + | |
- | + | ||
- | Constatez l' | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAMESPACE | + | Hello, world! |
- | default | + | |
- | default | + | |
- | default | + | |
- | default | + | |
- | 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 | + | |
</ | </ | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important** : Notez que sur **kubenode1.ittraining.loc**, | + | **Important** : Notez l' |
</ | </ | ||
- | Procédez maintenant au drain de kubenode1.ittraining.loc : | ||
- | < | + | ====5.6 - Commandes Impératives ==== |
- | root@kubemaster: | + | |
- | node/ | + | |
- | error: unable to drain node " | + | |
- | There are pending nodes to be drained: | + | |
- | | + | |
- | cannot delete Pods declare no controller (use --force to override): default/ | + | |
- | cannot delete DaemonSet-managed Pods (use --ignore-daemonsets to ignore): kube-system/ | + | |
- | < | + | |
- | + | ||
- | Notez que la commande retourne deux erreurs : | + | |
- | + | ||
- | * cannot delete Pods declare no controller (use --force to override): default/ | + | |
- | * cannot delete DaemonSet-managed Pods (use --ignore-daemonsets to ignore): kube-system/ | + | |
- | + | ||
- | La première erreur est due au fait que l' | + | |
- | + | ||
- | <WRAP center round important 60%> | + | |
- | **Important** : Le mot Controller implique un ReplicationController, | + | |
- | </ | + | |
- | + | ||
- | La deuxième erreur est due au fait que l' | + | |
- | + | ||
- | <WRAP center round important 60%> | + | |
- | **Important** : Un DaemonSet contient des pods qui sont **liés** à des noeuds **spécifiques**. | + | |
- | </ | + | |
- | Exécutez donc la commande | + | Avant de poursuivre, supprimez le pod **my-pod** : |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | node/ | + | pod "my-pod" deleted |
- | WARNING: deleting Pods that declare no controller: default/ | + | |
- | evicting | + | |
- | evicting | + | |
- | pod/nginx evicted | + | |
- | pod/ | + | |
- | node/ | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | Créez ensuite un deployment avec une commande |
- | **Important** : Notez que la commande | + | |
- | </ | + | |
- | + | ||
- | Consultez de nouveau l' | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAMESPACE | + | deployment.apps/my-deployment created |
- | default | + | |
- | default | + | |
- | default | + | |
- | 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 | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | En exécutant la même commande impérative, |
- | **Important** : Notez que le pod **nginx** a été détruit tandis que le pod **myapp-deployment-57c6cb89d9-f69nk** a été **expulsé**. Un nouveau pod dénommé **myapp-deployment-57c6cb89d9-l7lkd** a été créé sur **kubenode2.ittraining.loc** afin de maintenir le nombre à **3**. Les deux pods **calico-node-5htrc** et **kube-proxy-sn26v** ont été ignorés. | + | |
- | </ | + | |
- | + | ||
- | Constatez maintenant l' | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME STATUS | + | W0910 15:28:49.797172 |
- | kubemaster.ittraining.loc | + | apiVersion: apps/v1 |
- | kubenode1.ittraining.loc | + | kind: Deployment |
- | kubenode2.ittraining.loc | + | 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: {} | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | Ces instructions peuvent ensuite être injectées dans un fichier afin d' |
- | **Important** : Notez que le STATUS de **kubenode1.ittraining.loc** est **SchedulingDisabled** ce qui implique que le noeud n' | + | |
- | </ | + | |
- | + | ||
- | ====4.2 - La Commande uncordon==== | + | |
- | + | ||
- | Pour permettre le noeud de recevoir de nouveau des pods, il convient | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | node/ | + | W0910 15: |
</ | </ | ||
- | |||
- | Constatez de nouveau l' | ||
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME STATUS | + | apiVersion: apps/v1 |
- | kubemaster.ittraining.loc | + | kind: Deployment |
- | kubenode1.ittraining.loc | + | metadata: |
- | kubenode2.ittraining.loc | + | creationTimestamp: |
+ | labels: | ||
+ | | ||
+ | name: my-deployment | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | | ||
+ | app: my-deployment | ||
+ | strategy: {} | ||
+ | template: | ||
+ | | ||
+ | creationTimestamp: | ||
+ | labels: | ||
+ | app: my-deployment | ||
+ | | ||
+ | containers: | ||
+ | - image: nginx | ||
+ | name: nginx | ||
+ | resources: {} | ||
+ | status: {} | ||
</ | </ | ||
- | Dernièrement consultez | + | =====LAB #2 - Géstion les plugins |
+ | |||
+ | Les plugins de kubectl étendent ses fonctionnalités. Le gestionnaire | ||
+ | |||
+ | ====2.1 - Installation de krew==== | ||
+ | |||
+ | Afin d' | ||
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME READY | + | |
- | myapp-deployment-57c6cb89d9-dh4cb | + | |
- | myapp-deployment-57c6cb89d9-f69nk | + | |
- | myapp-deployment-57c6cb89d9-l7lkd | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | Installez ensuite krew avec la commande |
- | **Important** : Notez que l' | + | |
- | </ | + | |
- | =====LAB #5 - Mise-à-jour de K8s===== | + | < |
- | + | ( | |
- | ====5.1 - Mise-à-jour de kubeadm==== | + | set -x; cd " |
+ | curl -fsSLO " | ||
+ | tar zxvf krew-linux_amd64.tar.gz && | ||
+ | KREW=./krew-" | ||
+ | " | ||
+ | ) | ||
+ | </ | ||
- | Afin de mettre à jour kubeadm, il convient de faire un drain du **Contrôleur** | + | Vous obtiendrez |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | node/kubemaster.ittraining.loc cordoned | + | > |
- | WARNING: ignoring DaemonSet-managed Pods: kube-system/calico-node-dc7hd, kube-system/kube-proxy-fpksg | + | > |
- | evicting pod kube-system/coredns-6d4b75cb6d-td7cf | + | > tar zxvf krew-linux_amd64.tar.gz && |
- | evicting pod kube-system/calico-kube-controllers-6799f5f4b4-zk298 | + | > |
- | evicting pod kube-system/coredns-6d4b75cb6d-kxtqk | + | > " |
- | pod/calico-kube-controllers-6799f5f4b4-zk298 evicted | + | > ) |
- | pod/coredns-6d4b75cb6d-td7cf evicted | + | ++ mktemp |
- | pod/coredns-6d4b75cb6d-kxtqk evicted | + | + cd / |
- | node/kubemaster.ittraining.loc drained | + | + curl -fsSLO https:// |
+ | + tar zxvf krew-linux_amd64.tar.gz | ||
+ | ./LICENSE | ||
+ | ./krew-linux_amd64 | ||
+ | ++ uname | ||
+ | ++ tr ' | ||
+ | ++ uname -m | ||
+ | ++ sed -e s/ | ||
+ | + KREW=./krew-linux_amd64 | ||
+ | + ./krew-linux_amd64 install krew | ||
+ | Adding " | ||
+ | Updated the local copy of plugin index. | ||
+ | Installing plugin: krew | ||
+ | Installed plugin: krew | ||
+ | \ | ||
+ | | Use this plugin: | ||
+ | | ||
+ | | Documentation: | ||
+ | | ||
+ | | Caveats: | ||
+ | | \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | | - Restart your shell. | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | / | ||
+ | / | ||
</ | </ | ||
- | Afin de connaître la ou les version(s) supérieure(s) | + | Ensuite ajoutez **$HOME/ |
< | < | ||
- | + | root@kubemaster: | |
- | root@kubemaster: | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | --Plus-- | + | |
- | [q] | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | Afin de ne pas avoir besoin de redéfinir le PATH après chaque ouverture de session, ajoutez |
- | **Important** : Notez que la version la plus récente est la **1.25.0-00**. | + | |
- | </ | + | |
- | + | ||
- | Procédez maintenant à la mise-à-jour de kubeadm | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | Atteint:1 http:// | + | |
- | Ign:2 http://ftp.fr.debian.org/debian stretch InRelease | + | |
- | Atteint:3 http:// | + | |
- | Atteint:4 http:// | + | |
- | Réception de:5 https:// | + | |
- | Atteint:6 https:// | + | |
- | 44,8 ko réceptionnés en 0s (80,5 ko/s) | + | |
- | Lecture des listes de paquets... Fait | + | |
- | Lecture des listes de paquets... Fait | + | |
- | Construction de l'arbre des dépendances | + | |
- | Lecture des informations d' | + | |
- | Les paquets suivants ont été installés automatiquement et ne sont plus nécessaires : | + | |
- | libjsoncpp1 linux-image-4.9.0-8-amd64 | + | |
- | Veuillez utiliser « apt autoremove » pour les supprimer. | + | |
- | Les paquets retenus suivants seront changés : | + | |
- | kubeadm | + | |
- | Les paquets suivants seront mis à jour : | + | |
- | kubeadm | + | |
- | 1 mis à jour, 0 nouvellement installés, 0 à enlever et 5 non mis à jour. | + | |
- | Il est nécessaire de prendre 9 213 ko dans les archives. | + | |
- | Après cette opération, 586 ko d' | + | |
- | Réception de:1 https:// | + | |
- | 9 213 ko réceptionnés en 0s (15,3 Mo/s) | + | |
- | apt-listchanges : Lecture des fichiers de modifications (« changelog »)... | + | |
- | (Lecture de la base de données... 137041 fichiers et répertoires déjà installés.) | + | |
- | Préparation du dépaquetage de .../ | + | |
- | Dépaquetage de kubeadm (1.25.0-00) sur (1.24.2-00) ... | + | |
- | Paramétrage de kubeadm (1.25.0-00) ... | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | ====2.2 - Consultation |
- | **Important** : Notez que l' | + | |
- | </ | + | |
- | Vérifiez que la version désirée a été installée | + | Mettez à jour la liste des plugins |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | kubeadm version: & | + | Updated the local copy of plugin index. |
</ | </ | ||
- | Afin de connaître les version des composants du Control Plane compatibles avec la version 1.25.0 de kubeadm, utilisez | + | Pour visualiser |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | [upgrade/ | + | NAME DESCRIPTION |
- | [upgrade/ | + | access-matrix |
- | [upgrade/ | + | accurate |
- | [upload-config] Storing the configuration used in ConfigMap | + | advise-policy |
- | [preflight] Running pre-flight checks. | + | advise-psp Suggests PodSecurityPolicies for cluster. |
- | [upgrade] Running | + | allctx |
- | [upgrade] Fetching available versions to upgrade | + | apparmor-manager |
- | [upgrade/versions] Cluster version: v1.24.2 | + | assert |
- | [upgrade/ | + | auth-proxy Authentication proxy to a pod or service |
- | [upgrade/ | + | aws-auth Manage aws-auth |
- | [upgrade/ | + | azad-proxy Generate and handle authentication for azad-kub... |
- | + | bd-xray | |
- | Components that must be upgraded manually after you have upgraded the control plane with ' | + | blame Show who edited resource fields. |
- | COMPONENT | + | bulk-action |
- | kubelet | + | ca-cert |
- | + | capture | |
- | Upgrade to the latest version in the v1.24 series: | + | cert-manager |
- | + | change-ns View or change the current namespace via kubectl. no | |
- | COMPONENT | + | cilium |
- | kube-apiserver | + | cluster-group |
- | kube-controller-manager | + | clusternet |
- | kube-scheduler | + | cm Provides commands for OCM/MCE/ACM. no |
- | kube-proxy | + | cnpg Manage your CloudNativePG clusters |
- | CoreDNS | + | config-cleanup |
- | etcd 3.5.3-0 3.5.4-0 | + | config-registry |
- | + | cost View cluster cost information | |
- | You can now apply the upgrade by executing the following command: | + | creyaml |
- | + | ctx | |
- | | + | custom-cols |
- | + | cyclonus | |
- | _____________________________________________________________________ | + | datadog |
- | + | datree | |
- | Components that must be upgraded manually after you have upgraded | + | dds |
- | COMPONENT | + | debug-shell |
- | kubelet | + | deprecations |
- | + | df-pv Show disk usage (like unix df) for persistent v... no | |
- | Upgrade | + | direct-csi |
- | + | directpv | |
- | COMPONENT | + | doctor |
- | kube-apiserver | + | dtlogin |
- | kube-controller-manager | + | duck List custom resources |
- | kube-scheduler | + | edit-status |
- | kube-proxy v1.24.2 v1.25.0 | + | eds |
- | CoreDNS | + | eksporter |
- | etcd 3.5.3-0 3.5.4-0 | + | emit-event |
- | + | evict-pod | |
- | You can now apply the upgrade by executing the following command: | + | example |
- | + | exec-as | |
- | | + | exec-cronjob |
- | + | explore | |
- | _____________________________________________________________________ | + | fields |
- | + | flame | |
- | + | fleet Shows config and resources of a fleet of clusters | |
- | The table below shows the current state of component configs as understood by this version of kubeadm. | + | flyte |
- | Configs | + | fuzzy Fuzzy and partial string search for kubectl |
- | resetting to kubeadm defaults before | + | gadget |
- | upgrade | + | get-all Like `kubectl get all` but _really_ everything |
- | + | gke-credentials | |
- | API GROUP | + | gopass |
- | kubeproxy.config.k8s.io | + | graph |
- | kubelet.config.k8s.io | + | grep Filter Kubernetes resources by matching their n... no |
- | _____________________________________________________________________ | + | gs Handle custom resources with Giant Swarm no |
+ | hlf | ||
+ | hns | ||
+ | htpasswd | ||
+ | ice View configuration settings of containers insid... no | ||
+ | iexec | ||
+ | images | ||
+ | ingress-nginx | ||
+ | ingress-rule | ||
+ | ipick A kubectl wrapper for interactive resource sele... no | ||
+ | istiolog | ||
+ | janitor | ||
+ | kadalu | ||
+ | karbon | ||
+ | karmada | ||
+ | konfig | ||
+ | krew Package manager for kubectl plugins. yes | ||
+ | kruise | ||
+ | ks Simple management of KubeSphere components | ||
+ | ktop A top tool to display workload metrics | ||
+ | kubesec-scan | ||
+ | kudo Declaratively build, install, and run operators... no | ||
+ | kuota-calc | ||
+ | kurt Find what's restarting and why no | ||
+ | kuttl | ||
+ | kyverno | ||
+ | lineage | ||
+ | linstor | ||
+ | liqo Install and manage Liqo on your clusters | ||
+ | log2rbac | ||
+ | match-name | ||
+ | mc Run kubectl commands against multiple clusters | ||
+ | minio | ||
+ | moco Interact with MySQL operator MOCO. no | ||
+ | modify-secret | ||
+ | mtail Tail logs from multiple pods matching label sel... | ||
+ | multiforward | ||
+ | multinet | ||
+ | neat Remove clutter from Kubernetes manifests to mak... no | ||
+ | net-forward | ||
+ | node-admin | ||
+ | node-restart | ||
+ | node-shell | ||
+ | np-viewer | ||
+ | ns Switch between Kubernetes namespaces | ||
+ | nsenter | ||
+ | oidc-login | ||
+ | open-svc | ||
+ | openebs | ||
+ | operator | ||
+ | oulogin | ||
+ | outdated | ||
+ | passman | ||
+ | pexec | ||
+ | pod-dive | ||
+ | pod-inspect | ||
+ | pod-lens | ||
+ | pod-logs | ||
+ | pod-shell | ||
+ | podevents | ||
+ | popeye | ||
+ | preflight | ||
+ | print-env Build config files from k8s environments. no | ||
+ | profefe | ||
+ | promdump | ||
+ | prompt | ||
+ | prune-unused | ||
+ | psp-util Manage Pod Security Policy(PSP) and the related... no | ||
+ | pv-migrate | ||
+ | pvmigrate | ||
+ | rabbitmq | ||
+ | rbac-lookup | ||
+ | rbac-tool | ||
+ | rbac-view | ||
+ | realname-diff Diffs live and local resources ignoring Kustomi... no | ||
+ | reap Delete unused Kubernetes resources. no | ||
+ | relay | ||
+ | reliably | ||
+ | rename-pvc | ||
+ | resource-capacity | ||
+ | resource-snapshot | ||
+ | resource-versions | ||
+ | restart | ||
+ | rm-standalone-pods | ||
+ | rolesum | ||
+ | roll Rolling restart of all persistent pods in a nam... no | ||
+ | rook-ceph | ||
+ | safe Prompts before running edit commands | ||
+ | schemahero | ||
+ | score | ||
+ | secretdata | ||
+ | service-tree | ||
+ | shovel | ||
+ | sick-pods | ||
+ | skew Find if your cluster/ | ||
+ | slice Split a multi-YAML file into individual files. | ||
+ | snap Delete half of the pods in a namespace | ||
+ | sniff | ||
+ | socks5-proxy | ||
+ | sort-manifests | ||
+ | split-yaml | ||
+ | spy pod debugging tool for kubernetes clusters with... | ||
+ | sql Query the cluster via pseudo-SQL | ||
+ | ssh-jump | ||
+ | sshd Run SSH server in a Pod no | ||
+ | ssm-secret | ||
+ | starboard | ||
+ | status | ||
+ | stern Multi pod and container log tailing | ||
+ | strace | ||
+ | sudo Run Kubernetes commands impersonated as group s... no | ||
+ | support-bundle | ||
+ | switch-config | ||
+ | tail Stream logs from multiple pods and containers u... no | ||
+ | tap | ||
+ | tmux-exec | ||
+ | topology | ||
+ | trace Trace Kubernetes pods and nodes with system tools no | ||
+ | tree Show a tree of object hierarchies through owner... | ||
+ | tunnel | ||
+ | unused-volumes | ||
+ | vela Easily interact with KubeVela | ||
+ | view-allocations | ||
+ | view-cert | ||
+ | view-secret | ||
+ | view-serviceaccount-kubeconfig | ||
+ | view-utilization | ||
+ | view-webhook | ||
+ | viewnode | ||
+ | virt Control KubeVirt virtual machines using virtctl | ||
+ | volsync | ||
+ | vpa-recommendation | ||
+ | warp Sync and execute local files in Pod no | ||
+ | whisper-secret | ||
+ | who-can | ||
+ | whoami | ||
</ | </ | ||
- | Procédez donc à la mise-à-jour | + | ====2.3 |
- | < | + | Installez les plugins **ctx**, **ns**, **view-allocations** et **pod-logs** |
- | root@kubemaster: | + | |
- | [upgrade/ | + | |
- | [upgrade/ | + | |
- | [upgrade/ | + | |
- | [preflight] Running pre-flight checks. | + | |
- | [upgrade] Running cluster health checks | + | |
- | [upgrade/ | + | |
- | [upgrade/ | + | |
- | [upgrade/ | + | |
- | [upgrade] Are you sure you want to proceed? [y/N]: y | + | |
- | </ | + | |
- | + | ||
- | A l'issu de processus, vous verrez les deux lignes suivantes | + | |
< | < | ||
- | ... | + | root@kubemaster: |
- | [upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.25.0" | + | Updated the local copy of plugin index. |
- | + | Installing plugin: ctx | |
- | [upgrade/ | + | Installed plugin: ctx |
- | root@kubemaster:~# | + | \ |
+ | | Use this plugin: | ||
+ | | ||
+ | | Documentation: | ||
+ | | ||
+ | | Caveats: | ||
+ | | \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | | See https://github.com/ | ||
+ | | / | ||
+ | / | ||
+ | WARNING: You installed plugin "ctx" | ||
+ | These plugins are not audited for security by the Krew maintainers. | ||
+ | Run them at your own risk. | ||
+ | Installing plugin: ns | ||
+ | Installed plugin: ns | ||
+ | \ | ||
+ | | Use this plugin: | ||
+ | | ||
+ | | Documentation: | ||
+ | | ||
+ | | Caveats: | ||
+ | | \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | / | ||
+ | / | ||
+ | WARNING: You installed plugin " | ||
+ | These plugins are not audited for security by the Krew maintainers. | ||
+ | Run them at your own risk. | ||
+ | Installing plugin: view-allocations | ||
+ | Installed plugin: view-allocations | ||
+ | \ | ||
+ | | Use this plugin: | ||
+ | | ||
+ | | Documentation: | ||
+ | | ||
+ | / | ||
+ | WARNING: You installed plugin " | ||
+ | These plugins are not audited for security by the Krew maintainers. | ||
+ | Run them at your own risk. | ||
+ | Installing plugin: pod-logs | ||
+ | Installed plugin: pod-logs | ||
+ | \ | ||
+ | | Use this plugin: | ||
+ | | ||
+ | | Documentation: | ||
+ | | ||
+ | / | ||
+ | WARNING: You installed plugin " | ||
+ | These plugins are not audited for security by the Krew maintainers. | ||
+ | Run them at your own risk. | ||
</ | </ | ||
- | Mettez-à-jour maintenant | + | Le plugin |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | ... | + | kubernetes-admin@kubernetes |
</ | </ | ||
- | Au cas où le fichier du service | + | Le plugin **ns** permet |
- | < | + | Les Namespaces |
- | root@kubemaster:~# systemctl daemon-reload | + | |
- | root@kubemaster: | + | * peuvent être considérées comme des clusters virtuels, |
- | </ | + | * permettent l' |
+ | * permettent le regroupement d' | ||
+ | * sont utilisés avec des applications, | ||
- | Annulez | + | Listez les namespaces dans le cluster |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | node/ | + | default |
+ | kube-node-lease | ||
+ | kube-public | ||
+ | kube-system | ||
</ | </ | ||
- | Constatez maintenant l' | + | Le plugin **view-allocations** permet de visualiser les allocations de ressources telles le CPU, la mémoire, le stockage etc : |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME STATUS | + | Resource |
- | kubemaster.ittraining.loc | + | cpu (13%) 1.6 __ |
- | kubenode1.ittraining.loc | + | ├─ kubemaster.ittraining.loc |
- | kubenode2.ittraining.loc | + | |
+ | │ ├─ coredns-6d4b75cb6d-dw4ph | ||
+ | │ ├─ coredns-6d4b75cb6d-ms2jm | ||
+ | │ ├─ etcd-kubemaster.ittraining.loc | ||
+ | │ ├─ kube-apiserver-kubemaster.ittraining.loc | ||
+ | │ ├─ kube-controller-manager-kubemaster.ittraining.loc | ||
+ | │ └─ kube-scheduler-kubemaster.ittraining.loc | ||
+ | | ||
+ | │ └─ calico-node-5mrjl | ||
+ | | ||
+ | | ||
+ | ephemeral-storage | ||
+ | ├─ kubemaster.ittraining.loc | ||
+ | ├─ kubenode1.ittraining.loc | ||
+ | └─ kubenode2.ittraining.loc | ||
+ | memory | ||
+ | ├─ kubemaster.ittraining.loc | ||
+ | │ ├─ coredns-6d4b75cb6d-dw4ph | ||
+ | │ ├─ coredns-6d4b75cb6d-ms2jm | ||
+ | │ └─ etcd-kubemaster.ittraining.loc | ||
+ | ├─ kubenode1.ittraining.loc | ||
+ | └─ kubenode2.ittraining.loc | ||
+ | pods (5%) 17.0 (5%) 17.0 330.0 | ||
+ | ├─ kubemaster.ittraining.loc | ||
+ | ├─ kubenode1.ittraining.loc | ||
+ | └─ kubenode2.ittraining.loc | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | Le plugin |
- | **Important** : Notez que le Control Plane est à la version 1.25.0 tandis que les Travailleurs sont à la version 1.24.2. | + | |
- | </ | + | |
- | + | ||
- | ====5.2 - Mise-à-jour des Travailleurs==== | + | |
- | + | ||
- | Afin de mettre à jour un Travailleur, | + | |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | node/ | + | 1) myapp-deployment-57c6cb89d9-dh4cb |
- | Warning: ignoring DaemonSet-managed Pods: kube-system/calico-node-5htrc, | + | 2) myapp-deployment-57c6cb89d9-f69nk default |
- | evicting pod kube-system/coredns-565d847f94-rh7vb | + | 3) |
- | evicting pod kube-system/calico-kube-controllers-6799f5f4b4-6ng7z | + | 4) |
- | pod/calico-kube-controllers-6799f5f4b4-6ng7z evicted | + | 5) calico-node-5mrjl |
- | pod/coredns-565d847f94-rh7vb evicted | + | 6) |
- | node/ | + | 7) |
+ | 8) | ||
+ | 9) coredns-6d4b75cb6d-ms2jm | ||
+ | 10) etcd-kubemaster.ittraining.loc | ||
+ | 11) kube-apiserver-kubemaster.ittraining.loc | ||
+ | 12) kube-controller-manager-kubemaster.ittraining.loc | ||
+ | 13) kube-proxy-bwctz | ||
+ | 14) kube-proxy-j89vg | ||
+ | 15) kube-proxy-jx76x | ||
+ | 16) kube-scheduler-kubemaster.ittraining.loc | ||
+ | 17) metrics-server-7cb867d5dc-g55k5 | ||
+ | Select a Pod: | ||
</ | </ | ||
- | Conectez-vous à kubenode1 | + | Choisissez le pod **17**. Vous verrez la sortie de la commande logs : |
< | < | ||
- | root@kubemaster:~# ssh -l trainee kubenode1 | + | Select a Pod: 17 |
- | trainee@kubenode1' | + | I0713 03:28:27.452157 |
- | Linux kubenode1.ittraining.loc 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64 | + | I0713 03: |
- | + | I0713 03: | |
- | The programs included with the Debian GNU/Linux system are free software; | + | I0713 03: |
- | the exact distribution terms for each program are described in the | + | I0713 03: |
- | individual files in /usr/share/doc/*/copyright. | + | I0713 03: |
- | + | I0713 03: | |
- | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | + | I0713 03:28:28.435702 |
- | permitted by applicable law. | + | I0713 03:28:28.435727 |
- | Last login: Sun Sep 4 09:40:17 2022 from 192.168.56.2 | + | I0713 03:28:28.435735 |
- | trainee@kubenode1:~$ su - | + | I0713 03:28:28.534094 |
- | Mot de passe : fenestros | + | I0713 03:28: |
- | root@kubenode1:~# | + | I0713 03:28: |
</ | </ | ||
- | Mettez-à-jour le paquet | + | Pour lister les plugins installés, utilisez la commande |
< | < | ||
- | root@kubenode1:~# apt-get update && apt-get install -y --allow-change-held-packages kubeadm=1.25.0-00 | + | root@kubemaster:~# kubectl krew list |
- | ... | + | PLUGIN |
+ | ctx v0.9.4 | ||
+ | krew v0.4.3 | ||
+ | ns v0.9.4 | ||
+ | pod-logs | ||
+ | view-allocations | ||
</ | </ | ||
- | Mettez-à-jour la configuration | + | ====2.4 |
- | < | + | Pour mettre |
- | root@kubenode1: | + | |
- | [upgrade] Reading configuration from the cluster... | + | |
- | [upgrade] FYI: You can look at this config file with ' | + | |
- | [preflight] Running pre-flight checks | + | |
- | [preflight] Skipping prepull. Not a control plane node. | + | |
- | [upgrade] Skipping phase. Not a control plane node. | + | |
- | [kubelet-start] Writing kubelet configuration to file "/ | + | |
- | [upgrade] The configuration for this node was successfully updated! | + | |
- | [upgrade] Now you should go ahead and upgrade the kubelet package using your package manager. | + | |
- | </ | + | |
- | + | ||
- | Mettez-à-jour maintenant | + | |
< | < | ||
- | root@kubenode1:~# apt-get update && apt-get install -y --allow-change-held-packages kubelet=1.25.0-00 | + | root@kubemaster:~# kubectl |
- | ... | + | Updated the local copy of plugin index. |
+ | Upgrading plugin: ctx | ||
+ | Skipping plugin ctx, it is already on the newest version | ||
+ | Upgrading plugin: krew | ||
+ | Skipping plugin krew, it is already on the newest version | ||
+ | Upgrading plugin: ns | ||
+ | Skipping plugin ns, it is already on the newest version | ||
+ | Upgrading plugin: pod-logs | ||
+ | Skipping plugin pod-logs, it is already on the newest version | ||
+ | Upgrading plugin: view-allocations | ||
+ | Skipping plugin view-allocations, | ||
</ | </ | ||
- | Au cas où le fichier du service de kubelet a subi des modifications, re-démarrez le daemon systemctl ainsi que le service kubelet | + | Pour supprimer un plugin, utilisez la commande **remove** |
< | < | ||
- | root@kubenode1:~# systemctl daemon-reload | + | root@kubemaster:~# kubectl krew remove pod-logs |
- | root@kubenode1:~# systemctl restart kubelet | + | Uninstalled plugin: pod-logs |
+ | root@kubemaster:~# kubectl krew list | ||
+ | PLUGIN | ||
+ | ctx | ||
+ | krew v0.4.3 | ||
+ | ns v0.9.4 | ||
+ | view-allocations | ||
</ | </ | ||
- | Retournez à la machine | + | =====LAB #3 - Géstion des patchs avec la Commande kustomize==== |
+ | |||
+ | Commencez par installer l' | ||
< | < | ||
- | root@kubenode1: | + | root@kubemaster: |
- | déconnexion | + | |
- | trainee@kubenode1: | + | |
- | déconnexion | + | |
- | Connection to kubenode1 closed. | + | |
- | root@kubemaster: | + | |
</ | </ | ||
- | Annulez | + | Créez ensuite |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | node/kubenode1.ittraining.loc uncordoned | + | root@kubemaster: |
+ | root@kubemaster: | ||
</ | </ | ||
- | Constatez maintenant l' | + | Créez le manifest **deployment.yaml** |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME STATUS | + | root@kubemaster: |
- | kubemaster.ittraining.loc | + | apiVersion: apps/v1 |
- | kubenode1.ittraining.loc | + | kind: Deployment |
- | kubenode2.ittraining.loc | + | metadata: |
+ | name: nginx | ||
+ | labels: | ||
+ | app: nginx | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: nginx | ||
+ | template: | ||
+ | | ||
+ | labels: | ||
+ | app: nginx | ||
+ | spec: | ||
+ | affinity: | ||
+ | podAntiAffinity: | ||
+ | requiredDuringSchedulingIgnoredDuringExecution: | ||
+ | - labelSelector: | ||
+ | matchExpressions: | ||
+ | - key: app | ||
+ | operator: In | ||
+ | values: | ||
+ | - nginx | ||
+ | topologyKey: | ||
+ | containers: | ||
+ | - image: nginx:1.18.0 | ||
+ | imagePullPolicy: | ||
+ | name: nginx | ||
</ | </ | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important** | + | **Important** |
</ | </ | ||
- | Faites un drain du kubenode2 | + | Créez ensuite le manifest **service.yaml** |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | node/kubenode2.ittraining.loc cordoned | + | root@kubemaster: |
- | Warning: ignoring DaemonSet-managed Pods: kube-system/ | + | apiVersion: v1 |
- | evicting pod kube-system/ | + | kind: Service |
- | evicting pod default/ | + | metadata: |
- | evicting pod default/ | + | name: nginx |
- | evicting pod default/ | + | |
- | evicting pod kube-system/ | + | app: nginx |
- | pod/ | + | spec: |
- | pod/ | + | type: ClusterIP |
- | pod/myapp-deployment-689f9d59-9pkjz evicted | + | |
- | pod/ | + | - port: 80 |
- | pod/ | + | |
- | node/ | + | |
+ | | ||
+ | app: nginx | ||
</ | </ | ||
- | Connectez-vous à kubenode2 : | + | <WRAP center round important 60%> |
+ | **Important** | ||
+ | </ | ||
- | < | + | Dernièrement, créez |
- | root@kubemaster: | + | |
- | The authenticity of host ' | + | |
- | ECDSA key fingerprint is SHA256: | + | |
- | Are you sure you want to continue connecting (yes/no)? yes | + | |
- | Warning: Permanently added ' | + | |
- | trainee@kubenode2' | + | |
- | Linux kubenode2.ittraining.loc 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64 | + | |
- | + | ||
- | The programs included with the Debian GNU/Linux system are free software; | + | |
- | the exact distribution terms for each program are described in the | + | |
- | individual files in / | + | |
- | + | ||
- | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | + | |
- | permitted by applicable law. | + | |
- | Last login: Sun Sep 4 09:42:58 2022 from 192.168.56.1 | + | |
- | trainee@kubenode2: | + | |
- | Mot de passe : fenestros | + | |
- | root@kubenode2: | + | |
- | </ | + | |
- | + | ||
- | Mettez-à-jour | + | |
< | < | ||
- | root@kubenode2:~# apt-get update && apt-get install -y --allow-change-held-packages kubeadm=1.25.0-00 | + | root@kubemaster:~/ |
- | ... | + | root@kubemaster: |
- | </code> | + | apiVersion: kustomize.config.k8s.io/v1beta1 |
+ | kind: Kustomization | ||
- | Mettez-à-jour la configuration de kubelet | + | images: |
+ | - name: nginx | ||
+ | newTag: 1.19.1 | ||
- | < | + | resources: |
- | root@kubenode2:~# kubeadm upgrade node | + | - deployment.yaml |
- | [upgrade] Reading configuration from the cluster... | + | - service.yaml |
- | [upgrade] FYI: You can look at this config file with ' | + | |
- | [preflight] Running pre-flight checks | + | |
- | [preflight] Skipping prepull. Not a control plane node. | + | |
- | [upgrade] Skipping phase. Not a control plane node. | + | |
- | [kubelet-start] Writing kubelet configuration to file "/ | + | |
- | [upgrade] The configuration for this node was successfully updated! | + | |
- | [upgrade] Now you should go ahead and upgrade the kubelet package using your package manager. | + | |
</ | </ | ||
- | Mettez-à-jour maintenant | + | <WRAP center round important 60%> |
- | + | **Important** | |
- | < | + | </WRAP> |
- | root@kubenode2: | + | |
- | ... | + | |
- | </code> | + | |
- | Au cas où le fichier | + | Consultez donc l' |
< | < | ||
- | root@kubenode2:~# systemctl daemon-reload | + | root@kubemaster:~/ |
+ | root@kubemaster: | ||
+ | . | ||
+ | └── base | ||
+ | ├── deployment.yaml | ||
+ | ├── kustomization.yaml | ||
+ | └── service.yaml | ||
- | root@kubenode2: | + | 1 directory, 3 files |
</ | </ | ||
- | Retournez à la machine | + | Exécutez maintenant |
< | < | ||
- | root@kubenode2:~# exit | + | root@kubemaster:~/kustomize# kubectl kustomize base |
- | déconnexion | + | apiVersion: v1 |
- | trainee@kubenode2:~$ exit | + | kind: Service |
- | déconnexion | + | metadata: |
- | Connection to kubenode2 closed. | + | |
- | root@kubemaster:~# | + | app: nginx |
+ | name: nginx | ||
+ | spec: | ||
+ | ports: | ||
+ | - port: 80 | ||
+ | protocol: TCP | ||
+ | targetPort: 80 | ||
+ | selector: | ||
+ | app: nginx | ||
+ | type: ClusterIP | ||
+ | --- | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | name: nginx | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: nginx | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | spec: | ||
+ | affinity: | ||
+ | podAntiAffinity: | ||
+ | requiredDuringSchedulingIgnoredDuringExecution: | ||
+ | - labelSelector: | ||
+ | matchExpressions: | ||
+ | - key: app | ||
+ | operator: In | ||
+ | values: | ||
+ | - nginx | ||
+ | topologyKey: | ||
+ | | ||
+ | - image: nginx: | ||
+ | imagePullPolicy: | ||
+ | name: nginx | ||
</ | </ | ||
- | Annulez | + | <WRAP center round important 60%> |
+ | **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' | ||
+ | </ | ||
- | < | + | Imaginons maintenant que vous souhaitez déployer deux environnements **différents** de la même application, |
- | root@kubemaster: | + | |
- | node/ | + | |
- | </ | + | |
- | Constatez maintenant l' | + | Créez les répertoires **kustomize/ |
< | < | ||
- | root@kubemaster: | + | root@kubemaster: |
- | NAME STATUS | + | root@kubemaster: |
- | kubemaster.ittraining.loc | + | |
- | kubenode1.ittraining.loc | + | |
- | kubenode2.ittraining.loc | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | Consultez l' |
- | **Important** : Notez que tout a été mis-à-jour. | + | |
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | . | ||
+ | ├── base | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | └── overlays | ||
+ | ├── development | ||
+ | └── production | ||
+ | 4 directories, | ||
</ | </ | ||
- | < | + | Créez le fichier **dev_kustomization.yaml** : |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: kustomize.config.k8s.io/ | ||
+ | kind: Kustomization | ||
- | </code> | + | bases: |
+ | - ../../ | ||
- | <code> | + | nameSuffix: -development # <----------met à jour le nom du service/ |
- | </ | + | commonLabels: |
- | + | | |
- | <code> | + | |
+ | namespace: nginx-dev # < | ||
</ | </ | ||
+ | |||
+ | Appliquez ces modifications : | ||
< | < | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | name: nginx-development # < | ||
+ | namespace: nginx-dev # < | ||
+ | spec: | ||
+ | ports: | ||
+ | - port: 80 | ||
+ | protocol: TCP | ||
+ | targetPort: 80 | ||
+ | selector: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | type: ClusterIP | ||
+ | --- | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | name: nginx-development | ||
+ | namespace: nginx-dev | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | spec: | ||
+ | affinity: | ||
+ | podAntiAffinity: | ||
+ | requiredDuringSchedulingIgnoredDuringExecution: | ||
+ | - labelSelector: | ||
+ | matchExpressions: | ||
+ | - key: app | ||
+ | operator: In | ||
+ | values: | ||
+ | - nginx | ||
+ | topologyKey: | ||
+ | containers: | ||
+ | - image: nginx: | ||
+ | imagePullPolicy: | ||
+ | name: nginx | ||
</ | </ | ||
- | < | + | Maintenant créez le fichier **prod_kustomization.yaml** : |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: kustomize.config.k8s.io/ | ||
+ | kind: Kustomization | ||
- | </code> | + | bases: |
+ | - ../../base # < | ||
- | <code> | + | nameSuffix: -production # <----------met à jour le nom du service/ |
- | </code> | + | commonLabels: |
+ | environment: | ||
- | <code> | + | namespace: nginx-prod # <------------indique le nom du namespace |
+ | images: | ||
+ | - name: nginx | ||
+ | newTag: 1.19.2 # < | ||
</ | </ | ||
- | < | + | Appliquez ces modifications : |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | name: nginx-production # < | ||
+ | namespace: nginx-prod # < | ||
+ | spec: | ||
+ | ports: | ||
+ | - port: 80 | ||
+ | protocol: TCP | ||
+ | targetPort: 80 | ||
+ | selector: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | type: ClusterIP | ||
+ | --- | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | name: nginx-production | ||
+ | namespace: nginx-prod | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: nginx | ||
+ | environment: | ||
+ | spec: | ||
+ | affinity: | ||
+ | podAntiAffinity: | ||
+ | requiredDuringSchedulingIgnoredDuringExecution: | ||
+ | - labelSelector: | ||
+ | matchExpressions: | ||
+ | - key: app | ||
+ | operator: In | ||
+ | values: | ||
+ | - nginx | ||
+ | topologyKey: | ||
+ | containers: | ||
+ | - image: nginx: | ||
+ | imagePullPolicy: | ||
+ | name: nginx | ||
</ | </ | ||
- | < | + | Créez maintenant le namespace **nginx-prod** : |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | namespace/ | ||
</ | </ | ||
- | < | + | Installez l' |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | service/ | ||
+ | deployment.apps/ | ||
</ | </ | ||
- | < | + | Constatez le résultat de l' |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | NAME READY | ||
+ | nginx-production-75d9486bb9-7xpr6 | ||
- | </code> | + | root@kubemaster: |
- | + | NAME | |
- | < | + | nginx-production |
+ | root@kubemaster: | ||
+ | NAME | ||
+ | nginx-production | ||
</ | </ | ||
- | < | + | Supprimez le deployment et le service nginx-production : |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | deployment.apps " | ||
- | </code> | + | root@kubemaster: |
+ | No resources found in nginx-prod namespace. | ||
- | <code> | + | root@kubemaster: |
+ | NAME | ||
+ | nginx-production | ||
- | </code> | + | root@kubemaster: |
+ | No resources found in nginx-prod namespace. | ||
- | < | + | root@kubemaster: |
+ | service " | ||
+ | root@kubemaster: | ||
+ | No resources found in nginx-prod namespace. | ||
</ | </ | ||
- | < | + | Installez l' |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | namespace/ | ||
+ | root@kubemaster: | ||
+ | service/ | ||
+ | deployment.apps/ | ||
</ | </ | ||
- | < | + | Constatez le résultat : |
- | + | ||
- | </ | + | |
< | < | ||
+ | root@kubemaster: | ||
+ | NAME | ||
+ | nginx-development-5f8d7bdd88-fsnc6 | ||
- | </code> | + | root@kubemaster: |
- | + | NAME READY | |
- | < | + | nginx-development |
+ | root@kubemaster: | ||
+ | NAME TYPE CLUSTER-IP | ||
+ | nginx-development | ||
</ | </ | ||
---- | ---- | ||
- | Copyright © 2022 Hugh Norris | + | Copyright © 2024 Hugh Norris |