Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
elearning:workbooks:kubernetes:k8s02 [2022/09/04 11:45] – created adminelearning:workbooks:kubernetes:k8s02 [2024/12/15 06:47] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version - **2022.03**+Version - **2024.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======DOF302 Gestion des PODsContrôleurs de Réplication, ReplicaSets et Deployments======+======DOF303 Les Commandes kubectlkrew et kustomize======
  
 =====Contenu du Module===== =====Contenu du Module=====
  
-  * **DOF302 Gestion des PODsContrôleurs de Réplication, ReplicaSets et Deployments**+  * **DOF303 Les Commandes kubectlkrew et kustomize**
     * 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.Obtenir de l'Information sur les Nœuds 
-        * Utilisation du Fichier YAML +        * La Commande describe node 
-    * LAB #2 Utilisation de Contrôleurs de Réplication et ReplicaSets +        * La Commande top 
-      * 2.Contrôleurs de Réplication +      * 1.Obtenir de l'Information sur les Pods 
-        * Présentation d'un Contrôleur de Réplication +        * La Commande describe pod 
-        * Mise en Application +        * La Commande top 
-      * 2.ReplicaSets +      * 1.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.Présentation d'un Deployment +        * Utilisation des Options 
-      3.2 - Mise en Application +        * La Commande exec 
-        * Rollouts +        * Commandes Impératives 
-        * Rolling Updates +    * LAB #- Gestion les plugins de kubectl avec la Commande krew 
-        * Rollbacks +      2.1 - Installation de krew 
-    * LAB #- Gestion de la Maintenance d'un Noeud +      2.2 - Consultation de la liste des plugins 
-     4.1 - La Commande drain +      2.3 Installation et utilisation de plugins 
-   4.2 - La Commande uncordon +      * 2.- Mise à jour et suppression de plugins 
-    LAB #5 Mise-à-jour de K8s +    * LAB #3 - Gestion des patchs avec la Commande kustomize
-      * 5.- 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 conteneurLe conteneur est un instance d'une applicationLa relation entre un POD et un conteneur d'application est en règle générale 1:1, c'est-à-dire que dans le cas d'une augmentation de la charge, des PODs additionnels sont créés, chacun contenant un conteneur d'application au lieu de créer plusieurs conteneurs dans le même POD.+  * https://www.dropbox.com/scl/fi/a5ki48szu8q5159177opv/components.yaml?rlkey=354a4ybivgbmu97gyoduadm61&dl=0 
 +  * https://www.dropbox.com/scl/fi/weivllvybgtxtf2psq1ko/pod.yaml?rlkey=x1spvh9v0hy8p8m86rv8oqd60&dl=0
  
-A l'inverse, dans le cas d'une réduction de la charge, des PODs sont détruits. Avec Kubernetes, on ne crée pas de conteneurs multiples du même type dans le même POD. Par contre, il est possible d'avoir des conteneurs de types différents dans le même POD.+====Lab #2====
  
-Dans ce cas on parle d'un conteneur d'application et un ou des conteneur(s) **Helper**. Le conteneur d'application et le conteneur Helper peuvent communiquer directement parce qu'ils partagent le même **espace réseau**De même, ils ont accès au même **espace de stockage**.+  https://www.dropbox.com/scl/fi/qhpr75m74mrho0c2k7ky9/krew-linux_amd64.tar.gz?rlkey=bigm37fy2c3rzqgziszq71tb8&dl=0
  
-Un POD permet donc de dispenser l'administrateur de la gestion de **liens** Docker ainsi que des **volumes**.+====Lab #3====
  
-Lors da la création d'un POD avec la commande **kubectl**, celle-ci télécharge l'image Docker nécessaire à la création du conteneur à partir du Docker Hub.+  https://www.dropbox.com/scl/fi/0af2lqns1q26u63lotu7x/deployment.yaml?rlkey=ese25kacg2ibagpio9bky3cv9&dl=0 
 +  https://www.dropbox.com/scl/fi/qnr0m18sa3lwjbsk1qrj5/service.yaml?rlkey=sd5t8a4bh1trawum5vpy2bzww&dl=0 
 +  https://www.dropbox.com/scl/fi/5pz0wg63yd68w018248nc/kustomization.yaml?rlkey=liff7kt68fsicgjfyvxaozadi&dl=0 
 +  https://www.dropbox.com/scl/fi/2j60pti1wmd60kuv6kvc2/dev_kustomization.yaml?rlkey=iz6488nj8rrwg2b3y83suwch2&dl=0 
 +  * https://www.dropbox.com/scl/fi/bbdxrx0vxdx4y67uxehlv/prod_kustomization.yaml?rlkey=c723auhoeuzlut1p6qx96ktse&dl=0
  
-====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 de l'image nginx :+====1.1 - Obtenir de l'Aide sur les Commandes de kubectl====
  
-<code> +Les commandes de **kubectl** sont regroupées par catégorie :
-root@kubemaster:~# kubectl run  nginx --image=nginx +
-pod/nginx created +
-</code> +
- +
-Visualisez le POD avec la commande **kubectl** :+
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +root@kubemaster:~# kubectl --help 
-NAME    READY   STATUS              RESTARTS   AGE +kubectl controls the Kubernetes cluster manager.
-nginx   0/    ContainerCreating            20s+
  
-root@kubemaster:~# kubectl get pods + Find more information at: https://kubernetes.io/docs/reference/kubectl/
-NAME    READY   STATUS    RESTARTS   AGE +
-nginx   1/1     Running            44s +
-</code>+
  
-Consultez les informations concernant ce POD :+Basic Commands (Beginner): 
 +  create          Create a resource from a file or from stdin 
 +  expose          Take a replication controller, service, deployment or pod and expose it as a new Kubernetes service 
 +  run             Run a particular image on the cluster 
 +  set             Set specific features on objects
  
-<code> +Basic Commands (Intermediate): 
-root@kubemaster:~# kubectl describe pods +  explain         Get documentation for resource 
-Name:         nginx +  get             Display one or many resources 
-Namespace:    default +  edit            Edit a resource on the server 
-Priority:     0 +  delete          Delete resources by file names, stdin, resources and names, or by resources and label selector
-Node:         kubenode1.ittraining.loc/192.168.56.3 +
-Start Time:   Wed, 13 Jul 2022 05:09:12 +0200 +
-Labels:       run=nginx +
-Annotations:  cni.projectcalico.org/containerID: b401002d2766b402d37143c1fa4da7b87c1fc332324e841a9532c3814320ff83 +
-              cni.projectcalico.org/podIP: 192.168.239.1/32 +
-              cni.projectcalico.org/podIPs: 192.168.239.1/32 +
-Status:       Running +
-IP:           192.168.239.1 +
-IPs: +
-  IP:  192.168.239.1 +
-Containers: +
-  nginx: +
-    Container ID:   containerd://7976f5c10f7884c02d862c69bb21115f47bf8cd22646a76aed51ede70214371e +
-    Image:          nginx +
-    Image ID:       docker.io/library/nginx@sha256:dbe677093f569cc0afe2a149c529645f255aac959490ef11fb19ac6418b815d3 +
-    Port:           <none> +
-    Host Port:      <none> +
-    State:          Running +
-      Started:      Wed, 13 Jul 2022 05:09:55 +0200 +
-    Ready:          True +
-    Restart Count: +
-    Environment:    <none> +
-    Mounts: +
-      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-pmfww (ro) +
-Conditions+
-  Type              Status +
-  Initialized       True +
-  Ready             True +
-  ContainersReady   True +
-  PodScheduled      True +
-Volumes: +
-  kube-api-access-pmfww: +
-    Type:                    Projected (volume that contains injected data from multiple sources) +
-    TokenExpirationSeconds:  3607 +
-    ConfigMapName:           kube-root-ca.crt +
-    ConfigMapOptional:       <nil> +
-    DownwardAPI:             true +
-QoS Class:                   BestEffort +
-Node-Selectors:              <none> +
-Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s +
-                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s +
-Events: +
-  Type    Reason     Age   From               Message +
-  ----    ------     ----  ----               ------- +
-  Normal  Scheduled  23m   default-scheduler  Successfully assigned default/nginx to kubenode1.ittraining.loc +
-  Normal  Pulling    23m   kubelet            Pulling image "nginx" +
-  Normal  Pulled     22m   kubelet            Successfully pulled image "nginx" in 41.16449179s +
-  Normal  Created    22m   kubelet            Created container nginx +
-  Normal  Started    22m   kubelet            Started container nginx +
-</code>+
  
-<WRAP center round important 60%> +Deploy Commands: 
-**Important** Notez que la première ligne de la section **Events** indique clairement que dans le cas de cet exemple, le kubemaster schedulé le POD sur kubenode1. +  rollout         Manage the rollout of resource 
-</WRAP>+  scale           Set a new size for a deployment, replica set, or replication controller 
 +  autoscale       Auto-scale a deployment, replica set, stateful set, or replication controller
  
-Utilisez maintenant le commande kubectl avec l'option **-o wide** :+Cluster Management Commands: 
 +  certificate     Modify certificate resources. 
 +  cluster-info    Display cluster information 
 +  top             Display resource (CPU/memory) usage 
 +  cordon          Mark node as unschedulable 
 +  uncordon        Mark node as schedulable 
 +  drain           Drain node in preparation for maintenance 
 +  taint           Update the taints on one or more nodes
  
-<code> +Troubleshooting and Debugging Commands
-root@kubemaster:~# kubectl get pods -o wide +  describe        Show details of a specific resource or group of resources 
-NAME    READY   STATUS    RESTARTS   AGE   IP              NODE                       NOMINATED NODE   READINESS GATES +  logs            Print the logs for a container in a pod 
-nginx   1/    Running            24m   192.168.239.1   kubenode1.ittraining.loc   <none>           <none> +  attach          Attach to a running container 
-</code>+  exec            Execute a command in a container 
 +  port-forward    Forward one or more local ports to a pod 
 +  proxy           Run a proxy to the Kubernetes API server 
 +  cp              Copy files and directories to and from containers 
 +  auth            Inspect authorization 
 +  debug           Create debugging sessions for troubleshooting workloads and nodes
  
-<WRAP center round important 60%> +Advanced Commands: 
-**Important** Notez que l'adresse IP du POD est la **192.168.239.1**. Cette adresse est **dynamique**. Si le POD s'arrête et un autre démarre, l'adresse IP du nouveau POD sera différente. +  diff            Diff the live version against a would-be applied version 
-</WRAP>+  apply           Apply a configuration to a resource by file name or stdin 
 +  patch           Update fields of a resource 
 +  replace         Replace a resource by file name or stdin 
 +  wait            ExperimentalWait for a specific condition on one or many resources 
 +  kustomize       Build a kustomization target from a directory or URL.
  
-<WRAP center round important 60%> +Settings Commands: 
-**Important** : Notez que dans la colonne **NOMINATED NODE** il est marqué **<none>**. En effet il est possible d'assigner un POD à un nœud spécifique grâce à l'utilisation d'une étiquette définie pour le ou les nœuds nominés. Pour plus d'information maintenantconsultez le lien **[[https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/]]**. +  label           Update the labels on a resource 
-</WRAP>+  annotate        Mettre à jour les annotations d'une ressource 
 +  completion      Output shell completion code for the specified shell (bash, zshfish, or powershell)
  
-<WRAP center round important 60%> +Other Commands: 
-**Important** : Notez que dans la colonne **READINESS GATES** il est marqué **<none>**. En effet il est possible d'assigner à un POD des conditions spécifiques pour que Kubenetes considère que le POD soit dans un état de **ready**. Pour plus d'information maintenantconsultez le lien **[[https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-readiness-gate]]**. +  alpha           Commands for features in alpha 
-</WRAP>+  api-resources   Print the supported API resources on the server 
 +  api-versions    Print the supported API versions on the serverin the form of "group/version" 
 +  config          Modifier des fichiers kubeconfig 
 +  plugin          Provides utilities for interacting with plugins 
 +  version         Print the client and server version information
  
-====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, la définition du POD à créer est décrite dans un fichier YAML. Créez le fichier **pod-definition.yaml** : +Use "kubectl <command> --help" for more information about a given command
- +Use "kubectl options" for a list of global command-line options (applies to all commands).
-<code> +
-root@kubemaster:~# vi pod-definition.yaml +
-root@kubemaster:~# cat pod-definition.yaml +
---- +
-apiVersion: v1 +
-kind: Pod +
-metadata: +
-  name: myapp-pod +
-  labels: +
-    app: myapp +
-    type: front-end +
-spec: +
-  containers: +
-    - name: nginx-container +
-      image: nginx+
 </code> </code>
  
-Dans ce fichier on trouve les champs suivants :+Plus d'informations sur chaque commande peut être obtenue en passant l'option **--help**, par exemple :
  
-===apiVersion===+<code> 
 +root@kubemaster:~# kubectl create --help 
 +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'objet qui est créé, +
-  * 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 | +  kubectl create -f ./pod.json 
-ReplicaSet | apps/v1 | +   
-| Deployment | apps/v1 |+  # 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
  
-===kind===+Available Commands: 
 +  clusterrole           Create a cluster role 
 +  clusterrolebinding    Create a cluster role binding for a particular cluster role 
 +  configmap             Create a config map from a local file, directory or literal value 
 +  cronjob               Create a cron job with the specified name 
 +  deployment            Create a deployment with the specified name 
 +  ingress               Create an ingress with the specified name 
 +  job                   Create a job with the specified name 
 +  namespace             Create a namespace with the specified name 
 +  poddisruptionbudget   Create a pod disruption budget with the specified name 
 +  priorityclass         Create a priority class with the specified name 
 +  quota                 Create a quota with the specified name 
 +  role                  Create a role with single rule 
 +  rolebinding           Create a role binding for a particular role or cluster role 
 +  secret                Create a secret using specified subcommand 
 +  service               Create a service using a specified subcommand 
 +  serviceaccount        Create a service account with the specified name 
 +  token                 Request a service account token
  
-  * Ce champs est **obligatoire**, +Options: 
-  * La valeur de l'apiServer par rapport au type d'objet est :+    --allow-missing-template-keys=true: 
 +        If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to 
 +        golang and jsonpath output formats.
  
-^ kind ^ apiVersion ^ +    --dry-run='none': 
-| Pod | v1 | +        Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without 
-| Service | v1 | +        sending it. If server strategy, submit server-side request without persisting the resource.
-| ReplicaSet | apps/v1 | +
-| Deployment | apps/v1 |+
  
-===metadata===+    --edit=false: 
 +        Edit the API resource before creating
  
-  * Ce champs est **obligatoire**, +    --field-manager='kubectl-create': 
-  * 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 :+
  
-<file> +    -f, --filename=[]
-metadata: +        Filename, directory, or URL to files to use to create the resource
-  name: myapp-pod +
-  labels+
-    app: myapp +
-    type: front-end +
-</file>+
  
-===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, go-template-file, template, templatefile, jsonpath, 
-  * Les informations sont sous la forme d'un **liste** YAML :+        jsonpath-as-json, jsonpath-file).
  
-<file> +    --raw=''
-spec: +        Raw URI to POST to the server.  Uses the transport specified by the kubeconfig file.
-  containers: +
-    name: nginx-container +
-      imagenginx +
-</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.
  
-<code> +    -l, --selector='': 
-root@kubemaster:~# kubectl create -f pod-definition.yaml +        Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching 
-pod/myapp-pod created +        objects must satisfy all of the specified label constraints.
-</code>+
  
-<code> +    --show-managed-fields=false
-root@kubemaster:~# kubectl get pods +        If true, keep the managedFields when printing objects in JSON or YAML format.
-NAME        READY   STATUS    RESTARTS   AGE +
-myapp-pod   1/    Running            23s +
-nginx       1/    Running            29m +
-</code>+
  
-=====LAB #Utilisation de Contrôleurs de Réplication et ReplicaSets=====+    --template='': 
 +        Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format 
 +        is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
  
-====2.Contrôleurs de Réplication====+    --validate='strict': 
 +        Must be one of: strict (or true), warn, ignore (or false)             "true" or "strict" will use a schema to validate 
 +        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" will 
 +        warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled 
 +        on the API server, and behave as "ignore" otherwise.            "false" or "ignore" will not perform any schema 
 +        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'exécuter plusieurs instances du même POD de façon à offrir de la **haute disponibilité** au cas où l'application crash et le POD se met en échec. Même dans le cas où il n'y a qu'un seul POD, le Contrôleur de Réplication peut démarrer automatiquement un autre POD contenant l'application :+Usage: 
 +  kubectl create -f FILENAME [options]
  
-{{ :elearning:workbooks:debian:6:avance:kubernetes07.png?direct&600 |}}+Use "kubectl <command> --help" for more information about a given command. 
 +Use "kubectl options" for a list of global command-line options (applies to all commands). 
 +</code>
  
-Un Contrôleur de Réplication permet aussi de démarrer de nouveaux PODs en cas d'augmentation de la charge ainsi que d'assurer l'équilibrage de la charge entre les PODs :+Dernièrement les commandes kubectl peuvent recevoir des options. Pour visualiser les options qui peuvent être passées à toutes les commandes kubectl, saisissez la commande suivante :
  
-{{ :elearning:workbooks:debian:6:avance:kubernetes08.png?direct&600 |}}+<code> 
 +root@kubemaster:~# kubectl options 
 +The following options can be passed to any command:
  
-Dans le cas où le premier nœud venait à court de ressourcesun 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: will be removed in a future 
 +        releasesee 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-{{ :elearning:workbooks:debian:6:avance:kubernetes09.png?direct&600 |}}+    --alsologtostderr=false: 
 +        log to standard error as well as files (no effect when -logtostderr=true) (DEPRECATEDwill be removed in a 
 +        future release, see 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-===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, il convient de créer un fichier YAML. Créez donc le fichier **cr-definition.yaml** :+    --as-group=[]: 
 +        Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
  
-<code> +    --as-uid=''
-root@kubemaster:~# vi cr-definition.yaml +        UID to impersonate for the operation.
-root@kubemaster:~# cat cr-definition.yaml +
---- +
-apiVersionv1 +
-kind: ReplicationController +
-metadata: +
-  name: myapp-cr +
-  labels: +
-    app: myapp +
-    type: front-end +
-spec: +
-  template:+
  
-    metadata: +    --cache-dir='/root/.kube/cache'
-      name: myapp-pod +        Default cache directory
-      labels: +
-        app: myapp +
-        type: front-end +
-    spec: +
-      containers: +
-      namenginx-container +
-        image: nginx+
  
-  replicas3 +    --certificate-authority=''
-</code>+        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 :+    --client-certificate='': 
 +        Path to a client certificate file for TLS
  
-<code> +    --client-key=''
-root@kubemaster:~# cat pod-definition.yaml +        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 +
-      imagenginx +
-</code>+
  
-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 :+    --context='': 
 +        The name of the kubeconfig context to use
  
-<code> +    --insecure-skip-tls-verify=false: 
-root@kubemaster:~# kubectl create -f cr-definition.yaml +        If true, the server's certificate will not be checked for validity. This will make your HTTPS connections 
-replicationcontroller/myapp-cr created +        insecure
-</code>+
  
-Pour visualiser le Contrôleur de Réplication, utilisez la commande suivante :+    --kubeconfig='': 
 +        Path to the kubeconfig file to use for CLI requests.
  
-<code> +    --log-backtrace-at=:0: 
-root@kubemaster:~# kubectl get replicationcontroller +        when logging hits line file:N, emit a stack trace (DEPRECATED: will be removed in a future release, see 
-NAME       DESIRED   CURRENT   READY   AGE +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
-myapp-cr                         71s +
-</code>+
  
-Pour visualiser les PODs créés par le Contrôleur de Réplicationutilisez la commande suivante :+    --log-dir='': 
 +        If non-empty, write log files in this directory (no effect when -logtostderr=true) (DEPRECATED: will be 
 +        removed in a future releasesee 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-<code> +    --log-file='': 
-root@kubemaster:~# kubectl get pods +        If non-empty, use this log file (no effect when -logtostderr=true) (DEPRECATED: will be removed in a future 
-NAME             READY   STATUS    RESTARTS   AGE +        release, see 
-myapp-cr-6gxg6   1/    Running            90s +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
-myapp-cr-78frz   1/    Running            90s +
-myapp-pod        1/1     Running            3m53s +
-nginx            1/1     Running            32m +
-</code>+
  
-<WRAP center round important 60%> +    --log-file-max-size=1800: 
-**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 placele 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 0the maximum file size is unlimited(DEPRECATED: will be removed in a future release, see 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-Supprimez maintenant le POD **myapp-pod** :+    --log-flush-frequency=5s: 
 +        Maximum number of seconds between log flushes
  
-<code> +    --logtostderr=true: 
-root@kubemaster:~# kubectl delete pod myapp-pod +        log to standard error instead of files (DEPRECATEDwill be removed in a future release, see 
-pod "myapp-pod" deleted +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
-</code>+
  
-Constatez ensuite la réaction du Contrôleur de Réplication :+    --match-server-version=false: 
 +        Require server version to match client version
  
-<code> +    -n, --namespace='': 
-root@kubemaster:~# kubectl get pods +        If present, the namespace scope for this CLI request
-NAME             READY   STATUS    RESTARTS   AGE +
-myapp-cr-6gxg6   1/    Running            3m5s +
-myapp-cr-78frz   1/    Running            3m5s +
-myapp-cr-pt4zt   1/    Running            27s +
-nginx            1/1     Running            34m +
-</code>+
  
-<WRAP center round important 60%> +    --one-output=false: 
-**Important** Notez que le Contrôleur de Réplication créé le POD **myapp-cr-pt4zt**. +        If true, only write logs to their native severity level (vs also writing to each lower severity level; no 
-</WRAP>+        effect when -logtostderr=true) (DEPRECATEDwill be removed in future release, see 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-Pour consulter le statut d'un Contrôleur de Réplication, utilisez la commande suivante :+    --password='': 
 +        Password for basic authentication to the API server
  
-<code> +    --profile='none'
-root@kubemaster:~# kubectl describe replicationcontrollers/myapp-cr +        Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)
-Name:         myapp-cr +
-Namespace:    default +
-Selector:     app=myapp,type=front-end +
-Labels:       app=myapp +
-              type=front-end +
-Annotations:  <none> +
-Replicas:     3 current / 3 desired +
-Pods Status:  3 Running / 0 Waiting / 0 Succeeded / 0 Failed +
-Pod Template: +
-  Labels:  app=myapp +
-           type=front-end +
-  Containers: +
-   nginx-container: +
-    Image:        nginx +
-    Port:         <none+
-    Host Port   <none> +
-    Environment:  <none> +
-    Mounts:       <none> +
-  Volumes:        <none+
-Events: +
-  Type    Reason            Age    From                    Message +
-  ----    ------            ----   ----                    ------- +
-  Normal  SuccessfulCreate  3m51s  replication-controller  Created pod: myapp-cr-78frz +
-  Normal  SuccessfulCreate  3m51s  replication-controller  Created pod: myapp-cr-6gxg6 +
-  Normal  SuccessfulCreate  72s    replication-controller  Created pod: myapp-cr-pt4zt +
-</code>+
  
-Pour supprimer un Contrôleur de Réplication, utilisez la commande suivante :+    --profile-output='profile.pprof': 
 +        Name of the file to write the profile to
  
-<code> +    --request-timeout='0': 
-root@kubemaster:~# kubectl delete replicationcontroller myapp-cr +        The length of time to wait before giving up on a single server request. Non-zero values should contain a 
-replicationcontroller "myapp-cr" deleted +        corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests.
-</code>+
  
-====2.2 ReplicaSets====+    -s, --server='': 
 +        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: will be removed in a future release, see 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-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: will be removed 
 +        in a future release, see 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-===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: will be removed in a future release, see 
 +        https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
  
-Pour créer un ReplicaSet, créez le fichier **replicaset-definition.yaml** :+    --tls-server-name='': 
 +        Server name to use for server certificate validation. If it is not provided, the hostname used to contact the 
 +        server is used
  
-<code> +    --token=''
-root@kubemaster:~# vi replicaset-definition.yaml +        Bearer token for authentication to the API server
-root@kubemaster:~# cat replicaset-definition.yaml +
---- +
-apiVersionapps/v1 +
-kind: ReplicaSet +
-metadata: +
-  name: myapp-replicaset +
-  labels: +
-    app: myapp +
-    type: front-end +
-spec: +
-  template:+
  
-    metadata: +    --user=''
-      name: myapp-pod +        The name of the kubeconfig user to use
-      labels+
-        app: myapp +
-        type: front-end +
-    spec: +
-      containers: +
-      - name: nginx-container +
-        image: nginx+
  
-  replicas+    --username=''
-  selector: +        Username for basic authentication to the API server
-    matchLabels: +
-      type: front-end +
-</code>+
  
-<WRAP center round important 60%> +    -v, --v=0: 
-**Important** : Notez que dans le cas d'un ReplicaSetcelui-ci identifie les PODs sous son contrôle par la valeur du champ **matchLabels**.. +        number for the log level verbosity
-</WRAP>+
  
-Utilisez le fichier replicaset-definition.yaml pour créer le ReplicaSet :+    --vmodule=: 
 +        comma-separated list of pattern=N settings for file-filtered logging
  
-<code> +    --warnings-as-errors=false: 
-root@kubemaster:~# kubectl create -f replicaset-definition.yaml +        Treat warnings received from the server as errors and exit with a non-zero exit code
-replicaset.apps/myapp-replicaset created+
 </code> </code>
  
-Pour visualiser le ReplicaSet, utilisez la commande suivante :+====1.2 - Obtenir de l'Information sur le Cluster====
  
-<code> +===La Commande version===
-root@kubemaster:~# kubectl get replicaset +
-NAME               DESIRED   CURRENT   READY   AGE +
-myapp-replicaset                         12s +
-</code>+
  
-Pour visualiser les PODs créés par le ReplicaSet, utilisez la commande suivante :+Commencez par obtenir l'information concernant la version du client et du serveur :
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +root@kubemaster:~# kubectl version --short 
-NAME                     READY   STATUS    RESTARTS   AGE +Flag --short has been deprecated, and will be removed in the future. The --short output will become the default. 
-myapp-replicaset-56gwv   1/    Running            29s +Client Version: v1.25.
-myapp-replicaset-gh8gl   1/    Running            29s +Kustomize Version: v4.5.7 
-myapp-replicaset-kz742   1/    Running            29s +Server Version: v1.25.0
-nginx                    1/1     Running            60m+
 </code> </code>
  
-Modifiez maintenant le fichier **replicaset-definition.yaml** en augmentant le nombre de replicas de 3 à **6** :+===La Commande cluster-info===
  
-<code> +Consultez ensuite les informations concernant le cluster :
-root@kubemaster:~# vi replicaset-definition.yaml +
-root@kubemaster:~# cat replicaset-definition.yaml +
---- +
-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 +
-</code> +
- +
-Exécutez ensuite la commande **kubectl replace** :+
  
 <code> <code>
-root@kubemaster:~# kubectl replace -f replicaset-definition.yaml +root@kubemaster:~# kubectl cluster-info 
-replicaset.apps/myapp-replicaset replaced +Kubernetes control plane is running at https://192.168.56.2:6443 
-</code>+CoreDNS is running at https://192.168.56.2:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
  
-Visualiser le ReplicaSet : +To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
- +
-<code> +
-root@kubemaster:~# kubectl get replicaset +
-NAME               DESIRED   CURRENT   READY   AGE +
-myapp-replicaset                         95s +
-root@kubemaster:~# kubectl get replicaset +
-NAME               DESIRED   CURRENT   READY   AGE +
-myapp-replicaset                         98s +
-root@kubemaster:~# kubectl get replicaset +
-NAME               DESIRED   CURRENT   READY   AGE +
-myapp-replicaset                         99s+
 </code> </code>
  
-Visualiser les PODs créés par le ReplicaSet : +===La Commande api-versions===
- +
-<code> +
-root@kubemaster:~# kubectl get pods +
-NAME                     READY   STATUS    RESTARTS   AGE +
-myapp-replicaset-56gwv   1/    Running            2m14s +
-myapp-replicaset-7g6r4   1/    Running            49s +
-myapp-replicaset-7rsnc   1/    Running            49s +
-myapp-replicaset-gh8gl   1/    Running            2m14s +
-myapp-replicaset-kz742   1/    Running            2m14s +
-myapp-replicaset-twcwg   1/    Running            49s +
-nginx                    1/1     Running            62m +
-</code>+
  
-Exécutez ensuite la commande suivante :+Afin de connaître les versions des API compatibles avec la version de Kubernetes installée, exécutez la commande **api-versions** :
  
 <code> <code>
-root@kubemaster:~# kubectl scale --replicas=9 -f replicaset-definition.yaml +root@kubemaster:~# kubectl api-versions 
-replicaset.apps/myapp-replicaset scaled+admissionregistration.k8s.io/v1 
 +apiextensions.k8s.io/v1 
 +apiregistration.k8s.io/v1 
 +apps/v1 
 +authentication.k8s.io/v1 
 +authorization.k8s.io/v1 
 +autoscaling/v1 
 +autoscaling/v2 
 +autoscaling/v2beta2 
 +batch/v1 
 +certificates.k8s.io/v1 
 +coordination.k8s.io/v1 
 +crd.projectcalico.org/v1 
 +discovery.k8s.io/v1 
 +events.k8s.io/v1 
 +flowcontrol.apiserver.k8s.io/v1beta1 
 +flowcontrol.apiserver.k8s.io/v1beta2 
 +networking.k8s.io/v1 
 +node.k8s.io/v1 
 +policy/v1 
 +rbac.authorization.k8s.io/v1 
 +scheduling.k8s.io/v1 
 +storage.k8s.io/v1 
 +storage.k8s.io/v1beta1 
 +v1
 </code> </code>
  
-Visualiser le ReplicaSet :+===La Commande api-resources===
  
-<code> +La commande **api-resources** permet de consulter la liste des ressources du cluster, à savoir :
-root@kubemaster:~# kubectl get replicaset +
-NAME               DESIRED   CURRENT   READY   AGE +
-myapp-replicaset                         3m6s +
-</code>+
  
-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**.
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +root@kubemaster:~# kubectl api-resources 
-NAME                     READY   STATUS    RESTARTS   AGE +NAME                              SHORTNAMES   APIVERSION                             NAMESPACED   KIND 
-myapp-replicaset-56gwv   1/    Running            3m12s +bindings                                       v1                                     true         Binding 
-myapp-replicaset-7g6r4   1/    Running            107s +componentstatuses                 cs           v1                                     false        ComponentStatus 
-myapp-replicaset-7rsnc   1/1     Running            107s +configmaps                        cm           v1                                     true         ConfigMap 
-myapp-replicaset-gh8gl   1/    Running            3m12s +endpoints                         ep           v1                                     true         Endpoints 
-myapp-replicaset-klsvp   1/1     Running            33s +events                            ev           v1                                     true         Event 
-myapp-replicaset-kz742   1/1     Running            3m12s +limitranges                       limits       v1                                     true         LimitRange 
-myapp-replicaset-twcwg   1/1     Running            107s +namespaces                        ns           v1                                     false        Namespace 
-myapp-replicaset-vqsxc   1/1     Running            33s +nodes                             no           v1                                     false        Node 
-myapp-replicaset-z9l65   1/1     Running            33s +persistentvolumeclaims            pvc          v1                                     true         PersistentVolumeClaim 
-nginx                    1/1     Running            63m+persistentvolumes                 pv           v1                                     false        PersistentVolume 
 +pods                              po           v1                                     true         Pod 
 +podtemplates                                   v1                                     true         PodTemplate 
 +replicationcontrollers            rc           v1                                     true         ReplicationController 
 +resourcequotas                    quota        v1                                     true         ResourceQuota 
 +secrets                                        v1                                     true         Secret 
 +serviceaccounts                   sa           v1                                     true         ServiceAccount 
 +services                          svc          v1                                     true         Service 
 +mutatingwebhookconfigurations                  admissionregistration.k8s.io/v1        false        MutatingWebhookConfiguration 
 +validatingwebhookconfigurations                admissionregistration.k8s.io/v1        false        ValidatingWebhookConfiguration 
 +customresourcedefinitions         crd,crds     apiextensions.k8s.io/v1                false        CustomResourceDefinition 
 +apiservices                                    apiregistration.k8s.io/v1              false        APIService 
 +controllerrevisions                            apps/v1                                true         ControllerRevision 
 +daemonsets                        ds           apps/v1                                true         DaemonSet 
 +deployments                       deploy       apps/v1                                true         Deployment 
 +replicasets                       rs           apps/v1                                true         ReplicaSet 
 +statefulsets                      sts          apps/v1                                true         StatefulSet 
 +tokenreviews                                   authentication.k8s.io/v1               false        TokenReview 
 +localsubjectaccessreviews                      authorization.k8s.io/v1                true         LocalSubjectAccessReview 
 +selfsubjectaccessreviews                       authorization.k8s.io/v1                false        SelfSubjectAccessReview 
 +selfsubjectrulesreviews                        authorization.k8s.io/v1                false        SelfSubjectRulesReview 
 +subjectaccessreviews                           authorization.k8s.io/v1                false        SubjectAccessReview 
 +horizontalpodautoscalers          hpa          autoscaling/v2                         true         HorizontalPodAutoscaler 
 +cronjobs                          cj           batch/v1                               true         CronJob 
 +jobs                                           batch/v1                               true         Job 
 +certificatesigningrequests        csr          certificates.k8s.io/v1                 false        CertificateSigningRequest 
 +leases                                         coordination.k8s.io/v1                 true         Lease 
 +bgpconfigurations                              crd.projectcalico.org/v1               false        BGPConfiguration 
 +bgppeers                                       crd.projectcalico.org/v1               false        BGPPeer 
 +blockaffinities                                crd.projectcalico.org/v1               false        BlockAffinity 
 +caliconodestatuses                             crd.projectcalico.org/v1               false        CalicoNodeStatus 
 +clusterinformations                            crd.projectcalico.org/v1               false        ClusterInformation 
 +felixconfigurations                            crd.projectcalico.org/v1               false        FelixConfiguration 
 +globalnetworkpolicies                          crd.projectcalico.org/v1               false        GlobalNetworkPolicy 
 +globalnetworksets                              crd.projectcalico.org/v1               false        GlobalNetworkSet 
 +hostendpoints                                  crd.projectcalico.org/v1               false        HostEndpoint 
 +ipamblocks                                     crd.projectcalico.org/v1               false        IPAMBlock 
 +ipamconfigs                                    crd.projectcalico.org/v1               false        IPAMConfig 
 +ipamhandles                                    crd.projectcalico.org/v1               false        IPAMHandle 
 +ippools                                        crd.projectcalico.org/v1               false        IPPool 
 +ipreservations                                 crd.projectcalico.org/v1               false        IPReservation 
 +kubecontrollersconfigurations                  crd.projectcalico.org/v1               false        KubeControllersConfiguration 
 +networkpolicies                                crd.projectcalico.org/v1               true         NetworkPolicy 
 +networksets                                    crd.projectcalico.org/v1               true         NetworkSet 
 +endpointslices                                 discovery.k8s.io/v1                    true         EndpointSlice 
 +events                            ev           events.k8s.io/v1                       true         Event 
 +flowschemas                                    flowcontrol.apiserver.k8s.io/v1beta2   false        FlowSchema 
 +prioritylevelconfigurations                    flowcontrol.apiserver.k8s.io/v1beta2   false        PriorityLevelConfiguration 
 +ingressclasses                                 networking.k8s.io/v1                   false        IngressClass 
 +ingresses                         ing          networking.k8s.io/v1                   true         Ingress 
 +networkpolicies                   netpol       networking.k8s.io/v1                   true         NetworkPolicy 
 +runtimeclasses                                 node.k8s.io/v1                         false        RuntimeClass 
 +poddisruptionbudgets              pdb          policy/v1                              true         PodDisruptionBudget 
 +clusterrolebindings                            rbac.authorization.k8s.io/v1           false        ClusterRoleBinding 
 +clusterroles                                   rbac.authorization.k8s.io/v1           false        ClusterRole 
 +rolebindings                                   rbac.authorization.k8s.io/v1           true         RoleBinding 
 +roles                                          rbac.authorization.k8s.io/v1           true         Role 
 +priorityclasses                   pc           scheduling.k8s.io/v1                   false        PriorityClass 
 +csidrivers                                     storage.k8s.io/v1                      false        CSIDriver 
 +csinodes                                       storage.k8s.io/v1                      false        CSINode 
 +csistoragecapacities                           storage.k8s.io/v1                      true         CSIStorageCapacity 
 +storageclasses                    sc           storage.k8s.io/v1                      false        StorageClass 
 +volumeattachments                              storage.k8s.io/v1                      false        VolumeAttachment
 </code> </code>
  
-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====
  
-<code> +===La Commande describe node===
-root@kubemaster:~# cat replicaset-definition.yaml +
---- +
-apiVersion: apps/v1 +
-kind: ReplicaSet +
-metadata: +
-  name: myapp-replicaset +
-  labels: +
-    app: myapp +
-    type: front-end +
-spec: +
-  template:+
  
-    metadata: +De l'information sur le nœud peut être obtenue grâce à la commande **describe node**. Dans la première partie de la sortie de la commande on peut constater :
-      name: myapp-pod +
-      labels: +
-        app: myapp +
-        type: front-end +
-    spec: +
-      containers: +
-      - name: nginx-container +
-        image: nginx+
  
-  replicas6 +  * la section **Labels:**. Les Labels peuvent être utilisés pour gérer l'affinité d'un pod, autrement dit sur quel nœud un pod peut être schedulé en fonction des étiquettes associées au pod, 
-  selector: +  * la ligne **Unschedulable:      false** qui indique que le nœud accepte des pods.
-    matchLabels: +
-      type: front-end +
-</code> +
- +
-Dernièrement, exécutez la commande suivante :+
  
 <code> <code>
-root@kubemaster:~# kubectl scale --replicas=3 replicaset myapp-replicaset +root@kubemaster:~# kubectl describe node kubemaster.ittraining.loc 
-replicaset.extensions/myapp-replicaset scaled+Name:               kubemaster.ittraining.loc 
 +Roles:              control-plane 
 +Labels:             beta.kubernetes.io/arch=amd64 
 +                    beta.kubernetes.io/os=linux 
 +                    kubernetes.io/arch=amd64 
 +                    kubernetes.io/hostname=kubemaster.ittraining.loc 
 +                    kubernetes.io/os=linux 
 +                    node-role.kubernetes.io/control-plane= 
 +                    node.kubernetes.io/exclude-from-external-load-balancers= 
 +Annotations:        kubeadm.alpha.kubernetes.io/cri-socket: unix:///var/run/containerd/containerd.sock 
 +                    node.alpha.kubernetes.io/ttl:
 +                    projectcalico.org/IPv4Address: 192.168.56.2/24 
 +                    projectcalico.org/IPv4IPIPTunnelAddr: 192.168.55.192 
 +                    volumes.kubernetes.io/controller-managed-attach-detach: true 
 +CreationTimestamp:  Sun, 04 Sep 2022 09:36:00 +0200 
 +Taints:             node-role.kubernetes.io/control-plane:NoSchedule 
 +Unschedulable:      false 
 +Lease: 
 +  HolderIdentity:  kubemaster.ittraining.loc 
 +  AcquireTime:     <unset> 
 +  RenewTime:       Sun, 04 Sep 2022 16:56:54 +0200 
 +Conditions: 
 +  Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message 
 +  ----                 ------  -----------------                 ------------------                ------                       ------- 
 +  NetworkUnavailable   False   Sun, 04 Sep 2022 09:44:21 +0200   Sun, 04 Sep 2022 09:44:21 +0200   CalicoIsUp                   Calico is running on this node 
 +  MemoryPressure       False   Sun, 04 Sep 2022 16:52:48 +0200   Sun, 04 Sep 2022 09:35:59 +0200   KubeletHasSufficientMemory   kubelet has sufficient memory available 
 +  DiskPressure         False   Sun, 04 Sep 2022 16:52:48 +0200   Sun, 04 Sep 2022 09:35:59 +0200   KubeletHasNoDiskPressure     kubelet has no disk pressure 
 +  PIDPressure          False   Sun, 04 Sep 2022 16:52:48 +0200   Sun, 04 Sep 2022 09:35:59 +0200   KubeletHasSufficientPID      kubelet has sufficient PID available 
 +  Ready                True    Sun, 04 Sep 2022 16:52:48 +0200   Sun, 04 Sep 2022 12:15:32 +0200   KubeletReady                 kubelet is posting ready status 
 +...
 </code> </code>
  
-Visualiser le ReplicaSet :+Dans la deuxième partie de la sortie, on peut constater :
  
-<code> +  * la section **Addresses:** contenant l'adresse IP ainsi que le nom d'hôte du nœud.
-root@kubemaster:~# kubectl get replicaset +
-NAME               DESIRED   CURRENT   READY   AGE +
-myapp-replicaset                         4m12s +
-</code> +
- +
-Visualiser les PODs créés par le ReplicaSet :+
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +... 
-NAME                     READY   STATUS    RESTARTS   AGE +Addresses
-myapp-replicaset-56gwv   1/    Running            4m4s +  InternalIP:  10.0.2.65 
-myapp-replicaset-7g6r4   1/    Running            2m39s +  Hostname:    kubemaster.ittraining.loc 
-myapp-replicaset-gh8gl   1/    Running            4m4s +Capacity: 
-nginx                    1/1     Running            64m+  cpu:                4 
 +  ephemeral-storage:  18400976Ki 
 +  hugepages-2Mi:      
 +  memory:             8181164Ki 
 +  pods:               110 
 +Allocatable: 
 +  cpu:                4 
 +  ephemeral-storage:  16958339454 
 +  hugepages-2Mi:      
 +  memory:             8078764Ki 
 +  pods:               110 
 +...
 </code> </code>
  
-Créez maintenant un POD en dehors du ReplicaSet :+Dans la troisième partie de la sortie, on peut constater :
  
-<code> +  * la section **System Info:** contenant de l'information sur le système d'exploitation ainsi que les versions de Docker et de Kubernetes, 
-root@kubemaster:~# kubectl create -f pod-definition.yaml +  * la section **Non-terminated Pods** contenant de l'information sur les limites du CPU et de la mémoire de chaque POD en cours d'exécution.
-pod/myapp-pod created +
-</code> +
- +
-Consultez la liste des PODs :+
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +... 
-NAME                     READY   STATUS        RESTARTS   AGE +System Info
-myapp-pod                0/    Terminating   0          2s +  Machine ID:                 243c6f9d604e4aba852a482a1936be23 
-myapp-replicaset-56gwv   1/    Running                5m58s +  System UUID:                68639C3A-D77A-4C61-B7E8-4F4F70419B8A 
-myapp-replicaset-7g6r4   1/    Running                4m33s +  Boot ID:                    9bd56aa5-b94c-40d3-804a-a54bd8daf305 
-myapp-replicaset-gh8gl   1/    Running       0          5m58s +  Kernel Version:             4.9.0-19-amd64 
-nginx                    1/1     Running                66m+  OS Image:                   Debian GNU/Linux 9 (stretch) 
 +  Operating System:           linux 
 +  Architecture:               amd64 
 +  Container Runtime Version:  containerd://1.4.3 
 +  Kubelet Version:            v1.25.0 
 +  Kube-Proxy Version:         v1.25.0 
 +PodCIDR:                      192.168.0.0/24 
 +PodCIDRs:                     192.168.0.0/24 
 +Non-terminated Pods:          (7 in total) 
 +  Namespace                   Name                                                 CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age 
 +  ---------                   ----                                                 ------------  ----------  ---------------  -------------  --- 
 +  kube-system                 calico-node-dc7hd                                    250m (6%)     0 (0%)      0 (0%)           0 (0%)         7h18m 
 +  kube-system                 coredns-565d847f94-tqd8z                             100m (2%)     0 (0%)      70Mi (0%)        170Mi (2%)     3h56m 
 +  kube-system                 etcd-kubemaster.ittraining.loc                       100m (2%)     0 (0%)      100Mi (1%)       0 (0%)         4h19m 
 +  kube-system                 kube-apiserver-kubemaster.ittraining.loc             250m (6%)     0 (0%)      0 (0%)           0 (0%)         4h19m 
 +  kube-system                 kube-controller-manager-kubemaster.ittraining.loc    200m (5%)     0 (0%)      0 (0%)           0 (0%)         4h19m 
 +  kube-system                 kube-proxy-x7fpc                                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         4h25m 
 +  kube-system                 kube-scheduler-kubemaster.ittraining.loc             100m (2%)     0 (0%)      0 (0%)           0 (0%)         4h19m 
 +...
 </code> </code>
  
-<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**. +
-</WRAP>+
  
-Pour supprimer le ReplicaSet, utilisez la commande suivante :+  * la section **Allocated resources:** qui indique les ressources allouées au noeud.
  
 <code> <code>
-root@kubemaster:~# kubectl delete replicaset myapp-replicaset +Allocated resources
-replicaset.extensions "myapp-replicaset" deleted+  (Total limits may be over 100 percent, i.e., overcommitted.) 
 +  Resource           Requests    Limits 
 +  --------           --------    ------ 
 +  cpu                1 (25%)     0 (0%) 
 +  memory             170Mi (2%)  170Mi (2%) 
 +  ephemeral-storage  0 (0%)      0 (0%) 
 +  hugepages-2Mi      0 (0%)      0 (0%) 
 +Events: 
 +  Type    Reason          Age   From             Message 
 +  ----    ------          ----  ----             ------- 
 +  Normal  RegisteredNode  37m   node-controller  Node kubemaster.ittraining.loc event: Registered Node kubemaster.ittraining.loc in Controller
 </code> </code>
  
-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** :
  
 <code> <code>
-root@kubemaster:~# kubectl get all +root@kubemaster:~# wget https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.4.1/components.yaml
-NAME        READY   STATUS    RESTARTS   AGE +
-pod/nginx   1/1     Running            67m +
- +
-NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE +
-service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   16h+
 </code> </code>
  
-=====LAB #3 - Gestion des Deployments===== +Modifiez la section **containers** du fichier **components.yaml** :
- +
-====3.1 - Présentation d'un Deployment==== +
- +
-Un **Deployment** sous Kubernetes est un objet hiérarchiquement supérieur à un ReplicaSet : +
- +
-{{ :elearning:workbooks:debian:6:avance:kubernetes10.png?direct&600 |}} +
- +
-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** :+
  
 <code> <code>
-root@kubemaster:~# vi deployment-definition.yaml +root@kubemaster:~# vi components.yaml 
-root@kubemaster:~# cat deployment-definition.yaml +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:
-      - namenginx-container +      - args: 
-        image: nginx +        - --cert-dir=/tmp 
- +        - --secure-port=4443 
-  replicas: 3 +        - --kubelet-insecure-tls 
-  selector: +        - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP 
-    matchLabels: +        --kubelet-use-node-status-port 
-      type: front-end+...
 </code> </code>
  
-Utilisez la commande suivante pour créer le Deployment :+Déployez le serveur Metrics :
  
 <code> <code>
-root@kubemaster:~# kubectl create -f deployment-definition.yaml +root@kubemaster:~# kubectl apply -f components.yaml 
-deployment.apps/myapp-deployment created+serviceaccount/metrics-server created 
 +clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created 
 +clusterrole.rbac.authorization.k8s.io/system:metrics-server created 
 +rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created 
 +clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created 
 +clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created 
 +service/metrics-server created 
 +deployment.apps/metrics-server created 
 +apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
 </code> </code>
  
-Constatez la création de celui-ci :+Vérifiez l'état du deployment :
  
 <code> <code>
-root@kubemaster:~# kubectl get deployments +root@kubemaster:~# kubectl get deployments --all-namespaces 
-NAME               READY   UP-TO-DATE   AVAILABLE   AGE +NAMESPACE     NAME                      READY   UP-TO-DATE   AVAILABLE   AGE 
-myapp-deployment   3/3                3           17s+default       myapp-deployment          3/3                3           6h50m 
 +kube-system   calico-kube-controllers   1/               1           7h22m 
 +kube-system   coredns                   2/               2           7h25m 
 +kube-system   metrics-server            1/1                1           28s
 </code> </code>
  
-Notez que la création du Deployment a également créé un ReplicaSet :+Pour connaître l'utilisation des ressources par le nœud, utilisez la commande **top nodes** :
  
 <code> <code>
-root@kubemaster:~# kubectl get replicasets +root@kubemaster:~# kubectl top nodes 
-NAME                        DESIRED   CURRENT   READY   AGE +NAME                        CPU(cores)   CPU%   MEMORY(bytes)   MEMORY% 
-myapp-deployment-689f9d59                   3       41s+kubemaster.ittraining.loc   182m         4%     1901Mi          24% 
 +kubenode1.ittraining.loc    68m          1%     898Mi           23% 
 +kubenode2.ittraining.loc    104m         2%     819Mi           21%
 </code> </code>
  
-<WRAP center round important 60%> +Pour voir l'évolution de l'utilisation des ressources par le nœud, utilisez la commande **watch**
-**Important** : Notez que la valeur **689f9d59** est générée d'une manière aléatoire en interne par Kubernetes. +
-</WRAP> +
- +
-Bien entendu, la création de Deployment a créé le nombre de PODs indiqué dans le fichier YAML :+
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +root@kubemaster:~# watch kubectl top nodes 
-NAME                              READY   STATUS    RESTARTS   AGE +Every 2,0s: kubectl top nodes                                                                                                                                  kubemaster.ittraining.loc: Sun Sep  4 17:02:45 2022 
-myapp-deployment-689f9d59-cmxlm   1/1     Running            98s + 
-myapp-deployment-689f9d59-kt88s   1/1     Running            98s +NAME                        CPU(cores)   CPU%   MEMORY(bytes)   MEMORY% 
-myapp-deployment-689f9d59-zlwp4   1/1     Running            98s+kubemaster.ittraining.loc   142m         3%     1951Mi          24% 
 +kubenode1.ittraining.loc    71m          1    899Mi           23% 
 +kubenode2.ittraining.loc    52m          1    742Mi           19% 
 +... 
 +^C 
 +root@kubemaster:~#
 </code> </code>
  
-Pour voir tous ces objets en même temps, utilisez la commande **kubectl get all** :+<WRAP center round important 60%> 
 +**Important** : Notez l'utilisation de **^C** pour sortir de l'écran de la commande **watch**
 +</WRAP>
  
-<code> +Il est possible de trier la sortie par ordre décroissant de l'utilisation du processeur :
-root@kubemaster:~# kubectl get all +
-NAME                                  READY   STATUS    RESTARTS   AGE +
-pod/myapp-deployment-689f9d59-cmxlm   1/    Running            2m10s +
-pod/myapp-deployment-689f9d59-kt88s   1/    Running            2m10s +
-pod/myapp-deployment-689f9d59-zlwp4   1/    Running            2m10s +
- +
-NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE +
-service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   16h +
- +
-NAME                               READY   UP-TO-DATE   AVAILABLE   AGE +
-deployment.apps/myapp-deployment   3/               3           2m10s +
- +
-NAME                                        DESIRED   CURRENT   READY   AGE +
-replicaset.apps/myapp-deployment-689f9d59                         2m10s +
-</code> +
- +
-Pour obtenir plus d'informations concernant le Deployment, utilisez la commande **kubectl describe** :+
  
 <code> <code>
-root@kubemaster:~# kubectl describe deployments +root@kubemaster:~# kubectl top nodes --sort-by cpu 
-Name:                   myapp-deployment +NAME                        CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%    
-Namespace:              default +kubemaster.ittraining.loc   132m         3%     1916Mi          24       
-CreationTimestamp:      Wed, 13 Jul 2022 06:18:11 +0200 +kubenode1.ittraining.loc    65m          1%     952Mi           24%        
-Labels:                 app=myapp +kubenode2.ittraining.loc    50m          1%     887Mi           23% 
-                        type=front-end +
-Annotations:            deployment.kubernetes.io/revision:+
-Selector:               type=front-end +
-Replicas:               desired | 3 updated | 3 total | 3 available | 0 unavailable +
-StrategyType:           RollingUpdate +
-MinReadySeconds:        0 +
-RollingUpdateStrategy:  25max unavailable, 25max surge +
-Pod Template: +
-  Labels:  app=myapp +
-           type=front-end +
-  Containers: +
-   nginx-container: +
-    Image:        nginx +
-    Port:         <none> +
-    Host Port:    <none> +
-    Environment:  <none> +
-    Mounts:       <none> +
-  Volumes:        <none> +
-Conditions: +
-  Type           Status  Reason +
-  ----           ------  ------ +
-  Available      True    MinimumReplicasAvailable +
-  Progressing    True    NewReplicaSetAvailable +
-OldReplicaSets:  <none> +
-NewReplicaSet:   myapp-deployment-689f9d59 (3/3 replicas created) +
-Events: +
-  Type    Reason             Age    From                   Message +
-  ----    ------             ----   ----                   ------- +
-  Normal  ScalingReplicaSet  2m48s  deployment-controller  Scaled up replica set myapp-deployment-689f9d59 to 3+
 </code> </code>
  
-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 :
- +
-{{ :elearning:workbooks:debian:6:avance:kubernetes11.png?direct&600 |}} +
- +
-Pour consulter le statut du Rollout, il convient d'utiliser la commande suivante :+
  
 <code> <code>
-root@kubemaster:~# kubectl rollout status deployment/myapp-deployment +root@kubemaster:~# kubectl top nodes --sort-by memory 
-deployment "myapp-deployment" successfully rolled out+NAME                        CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%    
 +kubemaster.ittraining.loc   139m         3%     1909Mi          24%        
 +kubenode1.ittraining.loc    70m          1%     951Mi           24%        
 +kubenode2.ittraining.loc    52m          1%     885Mi           23%  
 </code> </code>
  
-Pour consulter la liste des Révisions, utilisez la commande suivante :+====1.4 - Obtenir de l'Information sur les Pods====
  
-<code> +===La Commande describe pod===
-root@kubemaster:~# kubectl rollout history deployment/myapp-deployment +
-deployment.apps/myapp-deployment +
-REVISION  CHANGE-CAUSE +
-1         <none>+
  
-</code> +Tout comme avec les noeuds, des informations concernant un pod spécifique peuvent être obtenues en utilisant la commande **kubectl describe** :
- +
-<WRAP center round important 60%> +
-**Important** : Notez que la valeur de **CHANGE-CAUSE** est **<none>** parce que l'option **--record** n'a pas été spécifiée sur la ligne de commande. Il est possible de modifier la valeur **CHANGE-CAUSE** avec la commande **kubectl annotate deployment <deployment> kubernetes.io/change-cause="<Message>" --record=false --overwrite=true**+
-</WRAP> +
- +
-Supprimez donc le Deployment avec la commande suivante :+
  
 <code> <code>
-root@kubemaster:~# kubectl delete deployment myapp-deployment +root@kubemaster:~# kubectl describe pod myapp-deployment-689f9d59-c25f9 
-deployment.extensions "myapp-deployment" deleted+Name:             myapp-deployment-689f9d59-c25f9 
 +Namespace:        default 
 +Priority:         0 
 +Service Account:  default 
 +Node:             kubenode1.ittraining.loc/192.168.56.3 
 +Start Time:       Sun, 04 Sep 2022 13:23:12 +0200 
 +Labels:           app=myapp 
 +                  pod-template-hash=689f9d59 
 +                  type=front-end 
 +Annotations:      cni.projectcalico.org/containerID: 0d234054b43a4bd5c8a3c8f0a9e0b8594a8d1abdccdad8b656c311ad31731a54 
 +                  cni.projectcalico.org/podIP: 192.168.239.9/32 
 +                  cni.projectcalico.org/podIPs: 192.168.239.9/32 
 +Status:           Running 
 +IP:               192.168.239.9 
 +IPs: 
 +  IP:           192.168.239.9 
 +Controlled By:  ReplicaSet/myapp-deployment-689f9d59 
 +Containers: 
 +  nginx-container: 
 +    Container ID:   containerd://b0367fe494be444f98facd069f5a6e48fadce9236ad5a1baa5feb31d2a08760a 
 +    Image:          nginx 
 +    Image ID:       docker.io/library/nginx@sha256:b95a99feebf7797479e0c5eb5ec0bdfa5d9f504bc94da550c2f58e839ea6914f 
 +    Port:           <none> 
 +    Host Port:      <none> 
 +    State:          Running 
 +      Started:      Sun, 04 Sep 2022 13:23:21 +0200 
 +    Ready:          True 
 +    Restart Count: 
 +    Environment:    <none> 
 +    Mounts: 
 +      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-fjdsw (ro) 
 +Conditions: 
 +  Type              Status 
 +  Initialized       True  
 +  Ready             True  
 +  ContainersReady   True  
 +  PodScheduled      True  
 +Volumes: 
 +  kube-api-access-fjdsw: 
 +    Type:                    Projected (a volume that contains injected data from multiple sources) 
 +    TokenExpirationSeconds:  3607 
 +    ConfigMapName:           kube-root-ca.crt 
 +    ConfigMapOptional:       <nil> 
 +    DownwardAPI:             true 
 +QoS Class:                   BestEffort 
 +Node-Selectors:              <none> 
 +Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s 
 +                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s 
 +Events:                      <none>
 </code> </code>
  
-Vérifiez la suppression du Deployment : +===La Commande top===
- +
-<code> +
-root@kubemaster:~# kubectl get all +
-NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE +
-service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   18h +
-</code>+
  
-Créez le Deployment de nouveau en ajoutant l'option **--record** :+Il est possible de voir l'utilisation des ressources par pod :
  
 <code> <code>
-root@kubemaster:~# kubectl create -deployment-definition.yaml --record +root@kubemaster:~# kubectl top pods 
-deployment.apps/myapp-deployment created+NAME                              CPU(cores)   MEMORY(bytes)    
 +myapp-deployment-689f9d59-c25f9   0m           3Mi              
 +myapp-deployment-689f9d59-nn9sw   0m           4Mi              
 +myapp-deployment-689f9d59-rnc4r   0m           4Mi 
 </code> </code>
  
-Consultez le statut du Rollout :+Triez maintenant la sortie par ordre décroissant de l'utilisation du processeur :
  
 <code> <code>
-root@kubemaster:~# kubectl rollout status deployment/myapp-deployment +root@kubemaster:~# kubectl top pods --sort-by cpu 
-deployment "myapp-deployment" successfully rolled out+NAME                              CPU(cores)   MEMORY(bytes)    
 +myapp-deployment-689f9d59-c25f9   0m           3Mi              
 +myapp-deployment-689f9d59-nn9sw   0m           4Mi              
 +myapp-deployment-689f9d59-rnc4r   0m           4Mi 
 </code> </code>
  
-<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 <deployment>** et peut être repris avec la commande **kubectl rollout resume deployment <deployment>**. +
-</WRAP> +
- +
-Consultez la liste des Révisions :+
  
 <code> <code>
-root@kubemaster:~# kubectl rollout history deployment/myapp-deployment +root@kubemaster:~# kubectl top pods --sort-by memory 
-deployment.apps/myapp-deployment +NAME                              CPU(cores)   MEMORY(bytes)    
-REVISION  CHANGE-CAUSE +myapp-deployment-689f9d59-nn9sw   0m           4Mi              
-1         kubectl create --filename=deployment-definition.yaml --record=true +myapp-deployment-689f9d59-rnc4r   0m           4Mi              
 +myapp-deployment-689f9d59-c25f9   0m           3Mi 
 </code> </code>
  
-<WRAP center round important 60%> +====1.5 Travailler avec la commande kubectl====
-**Important** : Notez que la valeur de **CHANGE-CAUSE** est la commande qui a été saisie. +
-</WRAP>+
  
-===Rolling Updates=== +Créez le fichier **pod.yaml** :
- +
-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'inconvénient de cette méthode est évident - entre la déstruction des PODs et la re-création des nouveaux PODs, l'application n'est pas disponible, +
-  * **Rolling Update** +
-    * Dans ce cas, les PODs sont détruits un-par-un. Après chaque destruction, un nouveau POD est créé contenant la mise-à-jour. De cette façon, l'application reste disponible. +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que **Rolling Update** est la méthode par défaut. +
-</WRAP> +
- +
-Modifiez maintenant le fichier **deployment-description.yaml** en spécifiant la version **1.12** de **nginx** :+
  
 <code> <code>
-root@kubemaster:~# vi deployment-definition.yaml +root@kubemaster:~# vi pod.yaml 
-root@kubemaster:~# cat deployment-definition.yaml +root@kubemaster:~# cat pod.yaml 
---- +apiVersion: v1 
-apiVersion: apps/v1 +kind: Pod
-kind: Deployment+
 metadata: metadata:
-  name: myapp-deployment +  name: my-pod
-  labels: +
-    app: myapp +
-    type: front-end+
 spec: spec:
-  template:+  containers: 
 +  - name: busybox 
 +    image: radial/busyboxplus:curl 
 +    command: ['sh', '-c', 'while true; do sleep 3600; done'
 +</code>
  
-    metadata: +====La Commande apply====
-      name: myapp-pod +
-      labels: +
-        app: myapp +
-        type: front-end +
-    spec: +
-      containers: +
-      - name: nginx-container +
-        image: nginx:1.12 +
- +
-  replicas: 3 +
-  selector: +
-    matchLabels: +
-      type: front-end +
-</code>+
  
-Appliquez ce changement :+Créez maintenant le pod en utilisant le fichier **pod.yaml** :
  
 <code> <code>
-root@kubemaster:~# kubectl apply -f deployment-definition.yaml --record +root@kubemaster:~# kubectl apply -f pod.yaml 
-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/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically. +
-deployment.apps/myapp-deployment configured+
 </code> </code>
  
-Consultez le statut du Deployment :+====La Commande create==== 
 + 
 +La commande **create** ne peut être utilisée que dans le cas où un objet du même nom n'existe pas déjà dans le cluster :
  
 <code> <code>
-root@kubemaster:~# kubectl rollout status deployment/myapp-deployment +root@kubemaster:~# kubectl create -f pod.yaml 
-Waiting for deployment "myapp-deployment" rollout to finish: 1 old replicas are pending termination... +Error from server (AlreadyExists): error when creating "pod.yaml": pods "my-podalready exists
-Waiting for deployment "myapp-deployment" rollout to finish1 old replicas are pending termination... +
-deployment "myapp-deploymentsuccessfully rolled out+
 </code> </code>
  
-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 **kubectl create** :
  
 <code> <code>
-root@kubemaster:~# kubectl rollout history deployment/myapp-deployment +root@kubemaster:~# kubectl create 
-deployment.apps/myapp-deployment +Error: must specify one of -f and -k
-REVISION  CHANGE-CAUSE +
-1         kubectl create --filename=deployment-definition.yaml --record=true +
-2         kubectl apply --filename=deployment-definition.yaml --record=true +
-</code>+
  
-Consultez les détails du Deployment **myapp-deployment** :+Create a resource from a file or from stdin.
  
-<code> + JSON and YAML formats are accepted.
-root@kubemaster:~# kubectl describe deployment myapp-deployment +
-Name:                   myapp-deployment +
-Namespace:              default +
-CreationTimestamp:      Wed, 13 Jul 2022 07:44:43 +0200 +
-Labels:                 app=myapp +
-                        type=front-end +
-Annotations:            deployment.kubernetes.io/revision:+
-                        kubernetes.io/change-cause: kubectl apply --filename=deployment-definition.yaml --record=true +
-Selector:               type=front-end +
-Replicas:               3 desired | 3 updated | 3 total | 3 available | 0 unavailable +
-StrategyType:           RollingUpdate +
-MinReadySeconds:        0 +
-RollingUpdateStrategy:  25% max unavailable, 25% max surge +
-Pod Template: +
-  Labels:  app=myapp +
-           type=front-end +
-  Containers: +
-   nginx-container: +
-    Image:        nginx:1.12 +
-    Port:         <none> +
-    Host Port:    <none> +
-    Environment:  <none> +
-    Mounts:       <none> +
-  Volumes:        <none> +
-Conditions: +
-  Type           Status  Reason +
-  ----           ------  ------ +
-  Available      True    MinimumReplicasAvailable +
-  Progressing    True    NewReplicaSetAvailable +
-OldReplicaSets:  <none> +
-NewReplicaSet:   myapp-deployment-57c6cb89d9 (3/3 replicas created) +
-Events: +
-  Type    Reason             Age    From                   Message +
-  ----    ------             ----   ----                   ------- +
-  Normal  ScalingReplicaSet  7m46s  deployment-controller  Scaled up replica set myapp-deployment-689f9d59 to 3 +
-  Normal  ScalingReplicaSet  4m45s  deployment-controller  Scaled up replica set myapp-deployment-57c6cb89d9 to 1 +
-  Normal  ScalingReplicaSet  4m20s  deployment-controller  Scaled down replica set myapp-deployment-689f9d59 to 2 +
-  Normal  ScalingReplicaSet  4m19s  deployment-controller  Scaled up replica set myapp-deployment-57c6cb89d9 to 2 +
-  Normal  ScalingReplicaSet  3m43s  deployment-controller  Scaled down replica set myapp-deployment-689f9d59 to 1 +
-  Normal  ScalingReplicaSet  3m42s  deployment-controller  Scaled up replica set myapp-deployment-57c6cb89d9 to 3 +
-  Normal  ScalingReplicaSet  2m10s  deployment-controller  Scaled down replica set myapp-deployment-689f9d59 to 0 +
-</code>+
  
-<WRAP center round important 60%> +Examples: 
-**Important** : Notez que l'image utilisée est bien la **nginx:1.12**. Notez ensuite que dans la section **Events**, les PODs ont été **Scaled down** un-par-un et **Scaled up** un-par-unNotez aussi que la valeur de **StrategyType** peut être soit **Recreate** soit **RollingUpdate**Dernièrement, notez la valeur de **RollingUpdateStrategy****25% max unavailable** indique qu'à un instant "t" 75% des PODs doivent être disponibles tandis que **25% max surge** indique le nombre total des PODs ne peut pas dépasser 1,25 fois la valeur du champ **Replicas**Ces valeurs peuvent être modifiéesConsultez la page **[[https://kubernetes.io/docs/concepts/workloads/controllers/deployment/]]**. +  # Create a pod using the data in pod.json 
-</WRAP>+  kubectl create -./pod.json 
 +   
 +  # Create a pod based on the JSON passed into stdin 
 +  cat pod.json | kubectl create -f - 
 +   
 +  # Edit the data in registry.yaml in JSON then create the resource using the edited data 
 +  kubectl create -f registry.yaml --edit -o json
  
-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           Create a cluster role 
 +  clusterrolebinding    Create a cluster role binding for a particular cluster role 
 +  configmap             Create a config map from a local file, directory or literal value 
 +  cronjob               Create a cron job with the specified name 
 +  deployment            Create a deployment with the specified name 
 +  ingress               Create an ingress with the specified name 
 +  job                   Create a job with the specified name 
 +  namespace             Create a namespace with the specified name 
 +  poddisruptionbudget   Create a pod disruption budget with the specified name 
 +  priorityclass         Create a priority class with the specified name 
 +  quota                 Create a quota with the specified name 
 +  role                  Create a role with single rule 
 +  rolebinding           Create a role binding for a particular role or cluster role 
 +  secret                Create a secret using specified subcommand 
 +  service               Create a service using a specified subcommand 
 +  serviceaccount        Create a service account with the specified name 
 +  token                 Request a service account token
  
-<code> +Options
-root@kubemaster:~# kubectl get replicasets +    --allow-missing-template-keys=true: 
-NAME                          DESIRED   CURRENT   READY   AGE +        If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to 
-myapp-deployment-57c6cb89d9                         5m41s +        golang and jsonpath output formats.
-myapp-deployment-689f9d59                           8m42s +
-</code>+
  
-<WRAP center round important 60%> +    --dry-run='none': 
-**Important** : Notez que le nombre d'anciens ReplicaSets retenu est de **10** par défautCette valeur peut être modifiéeConsultez la page **[[https://kubernetes.io/docs/concepts/workloads/controllers/deployment/]]**. +        Must be "none", "server", or "client"If client strategy, only print the object that would be sent, without 
-</WRAP>+        sending itIf server strategy, submit server-side request without persisting the resource.
  
-La modification de la version de l'image peut aussi être effectuée sur la ligne de commande :+    --edit=false: 
 +        Edit the API resource before creating
  
-<code> +    --field-manager='kubectl-create'
-root@kubemaster:~# kubectl set image deployment/myapp-deployment nginx-container=nginx:1.14 --record +        Name of the manager used to track field ownership.
-Flag --record has been deprecated, --record will be removed in the future +
-deployment.apps/myapp-deployment image updated +
-</code>+
  
-Le nom du conteneur **nginx-container** est défini dans le fichier de définition du POD :+    -f, --filename=[]: 
 +        Filename, directory, or URL to files to use to create the resource
  
-<code> +    -k, --kustomize=''
-root@kubemaster:~# cat pod-definition.yaml +        Process the kustomization directory. This flag can't be used together with -f or -R.
---+
-apiVersionv1 +
-kind: Pod +
-metadata: +
-  name: myapp-pod +
-  labels: +
-    app: myapp +
-    type: front-end +
-spec: +
-  containers: +
-    - name: nginx-container +
-      image: nginx +
-</code>+
  
-Consultez le statut du Deployment :+    -o, --output='': 
 +        Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, 
 +        jsonpath-as-json, jsonpath-file).
  
-<code> +    --raw='': 
-root@kubemaster:~# kubectl rollout status deployment/myapp-deployment +        Raw URI to POST to the server.  Uses the transport specified by the kubeconfig file.
-deployment "myapp-deployment" successfully rolled out +
-</code>+
  
-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.
  
-<code> +    --save-config=false: 
-root@kubemaster:~# kubectl rollout history deployment/myapp-deployment +        If true, the configuration of current object will be saved in its annotationOtherwise, the annotation will 
-deployment.apps/myapp-deployment +        be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
-REVISION  CHANGE-CAUSE +
-1         kubectl create --filename=deployment-definition.yaml --record=true +
-2         kubectl apply --filename=deployment-definition.yaml --record=true +
-3         kubectl set image deployment/myapp-deployment nginx-container=nginx:1.14 --record=true +
-</code>+
  
-Lors de la mise-à-jour le Deployment crée un autre ReplicaSet contenant les PODs mis-à-jour en suivant la méthode Rolling UpdateCeci peut être vu en regardant la sortie de la commande **kubectl get replicasets** :+    -l, --selector='': 
 +        Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching 
 +        objects must satisfy all of the specified label constraints.
  
-<code> +    --show-managed-fields=false: 
-root@kubemaster:~# kubectl get replicasets +        If true, keep the managedFields when printing objects in JSON or YAML format.
-NAME                          DESIRED   CURRENT   READY   AGE +
-myapp-deployment-57c6cb89d9                         22m +
-myapp-deployment-689f9d59                           25m +
-myapp-deployment-6c95f449f5                         16m +
-</code>+
  
-Consultez les détails du Deployment **myapp-deployment** :+    --template='': 
 +        Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format 
 +        is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
  
-<code> +    --validate='strict'
-root@kubemaster:~# kubectl describe deployment myapp-deployment +        Must be one ofstrict (or true)warn, ignore (or false)             "true" or "strict" will use a schema to validate 
-Name:                   myapp-deployment +        the input and fail the request if invalidIt will perform server side validation if ServerSideFieldValidation 
-Namespace             default +        is enabled on the api-server, but will fall back to less reliable client-side validation if not.                "warn" will 
-CreationTimestamp     Wed13 Jul 2022 07:44:43 +0200 +        warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled 
-Labels:                 app=myapp +        on the API server, and behave as "ignore" otherwise.            "false" or "ignore" will not perform any schema 
-                        type=front-end +        validation, silently dropping any unknown or duplicate fields.
-Annotations:            deployment.kubernetes.io/revision:+
-                        kubernetes.io/change-cause: kubectl set image deployment/myapp-deployment nginx-container=nginx:1.14 --record=true +
-Selector:               type=front-end +
-Replicas:               3 desired | 3 updated | 3 total | 3 available | 0 unavailable +
-StrategyType:           RollingUpdate +
-MinReadySeconds:        +
-RollingUpdateStrategy:  25% max unavailable, 25% max surge +
-Pod Template: +
-  Labels:  app=myapp +
-           type=front-end +
-  Containers: +
-   nginx-container: +
-    Image:        nginx:1.14 +
-    Port:         <none> +
-    Host Port:    <none> +
-    Environment:  <none> +
-    Mounts:       <none> +
-  Volumes:        <none> +
-Conditions: +
-  Type           Status  Reason +
-  ----           ------  ------ +
-  Available      True    MinimumReplicasAvailable +
-  Progressing    True    NewReplicaSetAvailable +
-OldReplicaSets:  <none> +
-NewReplicaSet:   myapp-deployment-6c95f449f5 (3/3 replicas created) +
-Events: +
-  Type    Reason             Age                From                   Message +
-  ----    ------             ----               ----                   ------- +
-  Normal  ScalingReplicaSet  26m                deployment-controller  Scaled up replica set myapp-deployment-689f9d59 to +
-  Normal  ScalingReplicaSet  23m                deployment-controller  Scaled up replica set myapp-deployment-57c6cb89d9 to 1 +
-  Normal  ScalingReplicaSet  22m                deployment-controller  Scaled down replica set myapp-deployment-689f9d59 to 2 +
-  Normal  ScalingReplicaSet  22m                deployment-controller  Scaled up replica set myapp-deployment-57c6cb89d9 to 2 +
-  Normal  ScalingReplicaSet  22m                deployment-controller  Scaled down replica set myapp-deployment-689f9d59 to 1 +
-  Normal  ScalingReplicaSet  22m                deployment-controller  Scaled up replica set myapp-deployment-57c6cb89d9 to 3 +
-  Normal  ScalingReplicaSet  20m                deployment-controller  Scaled down replica set myapp-deployment-689f9d59 to 0 +
-  Normal  ScalingReplicaSet  16m                deployment-controller  Scaled up replica set myapp-deployment-6c95f449f5 to 1 +
-  Normal  ScalingReplicaSet  16m                deployment-controller  Scaled down replica set myapp-deployment-57c6cb89d9 to 2 +
-  Normal  ScalingReplicaSet  14m (x4 over 16m)  deployment-controller  (combined from similar events): Scaled down replica set myapp-deployment-57c6cb89d9 to 0 +
-</code>+
  
-<WRAP center round important 60%> +    --windows-line-endings=false: 
-**Important** : Notez que l'image utilisée est bien la **nginx:1.14**. +        Only relevant if --edit=trueDefaults to the line ending native to your platform.
-</WRAP>+
  
-===Rollbacks===+Usage: 
 +  kubectl create -f FILENAME [options]
  
-Grâce au système des **Révisions**, il est possible de revenir en arrière vers la version précédente **N-1** de l'applicationSaisissez la commande suivante : +Use "kubectl <command> --help" for more information about a given command
- +Use "kubectl options" for a list of global command-line options (applies to all commands).
-<code> +
-root@kubemaster:~# kubectl rollout undo deployment/myapp-deployment +
-deployment.extensions/myapp-deployment rolled back+
 </code> </code>
  
-<WRAP center round important 60%> +La commande **apply** est ensuite utilisée pour appliquer des modifications apportées au fichier yaml :
-**Important** : Notez qu'il est possible de revenir en arrière vers une version précédente spécifique avec la commande **kubectl rollout undo deployment <deployment> --to-revision=<revision>**. +
-</WRAP> +
- +
-Saisissez la commande **kubectl get replicasets** :+
  
 <code> <code>
-root@kubemaster:~# kubectl get replicasets +root@kubemaster:~# kubectl apply -f pod.yaml 
-NAME                          DESIRED   CURRENT   READY   AGE +pod/my-pod unchanged
-myapp-deployment-57c6cb89d9                         24m +
-myapp-deployment-689f9d59                           27m +
-myapp-deployment-6c95f449f5                         18m+
 </code> </code>
  
-<WRAP center round important 60%> +====La Commande get====
-**Important** : Notez que l'application est revenue à la version précédente. +
-</WRAP>+
  
-Utilisez la commande **kubectl rollout history** :+Constatez le statut du pod :
  
 <code> <code>
-root@kubemaster:~# kubectl rollout history deployment/myapp-deployment +root@kubemaster:~# kubectl get pods 
-deployment.apps/myapp-deployment +NAME                              READY   STATUS    RESTARTS   AGE 
-REVISION  CHANGE-CAUSE +my-pod                            1/    Running            10s 
-        kubectl create --filename=deployment-definition.yaml --record=true +myapp-deployment-689f9d59-c25f9   1/    Running            6d1h 
-3         kubectl set image deployment/myapp-deployment nginx-container=nginx:1.14 --record=true +myapp-deployment-689f9d59-nn9sw   1/1     Running            6d1h 
-4         kubectl apply --filename=deployment-definition.yaml --record=true+myapp-deployment-689f9d59-rnc4r   1/    Running            6d1h
 </code> </code>
  
-<WRAP center round important 60%> +Rappelez-vous que vous pouvez utiliser une abréviation pour pods :
-**Important** : Notez que Révision 2 est devenue la Révision 4 démontrant ainsi le Rollback. +
-</WRAP> +
- +
-Créez maintenant une erreur d'un Rollout :+
  
 <code> <code>
-root@kubemaster:~# kubectl set image deployment/myapp-deployment nginx-container=nginx1.14 --record +root@kubemaster:~# kubectl get po 
-deployment.extensions/myapp-deployment image updated+NAME                              READY   STATUS    RESTARTS   AGE 
 +my-pod                            1/1     Running            54s 
 +myapp-deployment-689f9d59-c25f9   1/    Running            6d1h 
 +myapp-deployment-689f9d59-nn9sw   1/1     Running            6d1h 
 +myapp-deployment-689f9d59-rnc4r   1/    Running            6d1h
 </code> </code>
  
-<WRAP center round important 60%> +Pour ne voir qu'un seul pod, il convient de préciser son nom en tant qu'argument :
-**Important** : Notez que l'erreur est **nginx1.14** qui devrait être **nginx:1.14**. +
-</WRAP> +
- +
-Constatez le statut du Deployment :+
  
 <code> <code>
-root@kubemaster:~# kubectl rollout status deployment/myapp-deployment +root@kubemaster:~# kubectl get po my-pod 
-Waiting for deployment "myapp-deployment" rollout to finish: out of 3 new replicas have been updated... +NAME     READY   STATUS    RESTARTS   AGE 
-^C+my-pod   1/1     Running            109s
 </code> </code>
  
-<WRAP center round important 60%> +====Utilisation des Options====
-**Important** : Notez que le Rollout est bloqué. L'erreur **error: deployment "myapp-deployment" exceeded its progress deadline** va être retournée au bout d'une dizaine de minutes ! +
-</WRAP>+
  
-Pour visualiser ce qui se passe, utilisez la commande **kubectl get deployments** :+Rappelez-vous que l'option **wide** vous permet de voir les adresses IP des pods ainsi que les noeuds qui les hébergent :
  
 <code> <code>
-root@kubemaster:~# kubectl get deployments +root@kubemaster:~# kubectl get pods -o wide 
-NAME               READY   UP-TO-DATE   AVAILABLE   AGE +NAME                              READY   STATUS    RESTARTS   AGE    IP               NODE                       NOMINATED NODE   READINESS GATES 
-myapp-deployment   3/    1                      15m+my-pod                            1/1     Running            115s   192.168.150.9    kubenode2.ittraining.loc   <none>           <none> 
 +myapp-deployment-689f9d59-c25f9   1/1     Running   0          6d1h   192.168.239.9    kubenode1.ittraining.loc   <none>           <none> 
 +myapp-deployment-689f9d59-nn9sw   1/    Running            6d1h   192.168.239.13   kubenode1.ittraining.loc   <none>           <none> 
 +myapp-deployment-689f9d59-rnc4r   1/1     Running            6d1h   192.168.239.12   kubenode1.ittraining.loc   <none>           <none>
 </code> </code>
  
-La commande **kubectl get pods** démontre un statut de **ImagePullBackOff** pour le premier POD dans le nouveau ReplicaSet qui indique que Kubernetes ne peut pas effectuer le **pull** de l'image à partir de Docker Hub :+L'utilisation de l'option **json** permet de voir cette même information au format json :
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +root@kubemaster:~# kubectl get pods -o json | more 
-NAME                                READY   STATUS             RESTARTS   AGE +{ 
-myapp-deployment-57c6cb89d9-dh4cb   1/1     Running            0          7m24s +    "apiVersion": "v1", 
-myapp-deployment-57c6cb89d9-f69nk   1/    Running            0          7m30s +    "items":
-myapp-deployment-57c6cb89d9-q7d4p   1/    Running            0          7m19s +        { 
-myapp-deployment-74f697676f-2z95l   0/1     ImagePullBackOff            4m1s+            "apiVersion": "v1", 
 +            "kind": "Pod", 
 +            "metadata":
 +                "annotations":
 +                    "cni.projectcalico.org/containerID": "584cf2663957e8a6d5628c7f316e5858629ea646ec890bd5d6f9d1e217963b52", 
 +                    "cni.projectcalico.org/podIP": "192.168.150.9/32", 
 +                    "cni.projectcalico.org/podIPs": "192.168.150.9/32", 
 +                    "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\ 
 +":{\"annotations\":{},\"name\":\"my-pod\",\"namespace\":\"default\"},\"spec\":{\"containers\":[{\"command\":[\"sh\",\"-c\",
 +"while true; do sleep 3600; done\"],\"image\":\"radial/busyboxplus:curl\",\"name\":\"busybox\"}]}}\n" 
 +                }, 
 +                "creationTimestamp": "2022-09-10T13:03:20Z", 
 +                "name": "my-pod", 
 +                "namespace": "default", 
 +                "resourceVersion": "755938", 
 +                "uid": "628ca9e4-2fbe-4fc9-b0fa-9a05ef942a07" 
 +            }, 
 +            "spec":
 +                "containers":
 +                    { 
 +                        "command":
 +                            "sh", 
 +                            "-c", 
 +                            "while true; do sleep 3600; done" 
 +                        ], 
 +                        "image": "radial/busyboxplus:curl", 
 +                        "imagePullPolicy": "IfNotPresent", 
 +                        "name": "busybox", 
 +                        "resources": {}, 
 +                        "terminationMessagePath": "/dev/termination-log", 
 +                        "terminationMessagePolicy": "File", 
 +                        "volumeMounts":
 +                            { 
 +                                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", 
 +                                "name": "kube-api-access-qwzzv", 
 +--More--
 </code> </code>
  
-En consultant l'historique du Rollout, une Révision supplémentaire a été ajoutée suite à la commande en erreur :+L'utilisation de l'option **yaml** permet de voir cette même information au format yaml :
  
 <code> <code>
-root@kubemaster:~# kubectl rollout history deployment/myapp-deployment +root@kubemaster:~# kubectl get pods -o yaml | more 
-deployment.apps/myapp-deployment +apiVersion: v1 
-REVISION  CHANGE-CAUSE +items: 
-1         kubectl create --filename=deployment-definition.yaml --record=true +apiVersion: v1 
-3         kubectl set image deployment/myapp-deployment nginx-container=nginx:1.14 --record=true +  kind: Pod 
-4         kubectl apply --filename=deployment-definition.yaml --record=true +  metadata: 
-5         kubectl set image deployment/myapp-deployment nginx-container=nginx1.14 --record=true+    annotations: 
 +      cni.projectcalico.org/containerID: 584cf2663957e8a6d5628c7f316e5858629ea646ec890bd5d6f9d1e217963b52 
 +      cni.projectcalico.org/podIP: 192.168.150.9/32 
 +      cni.projectcalico.org/podIPs: 192.168.150.9/32 
 +      kubectl.kubernetes.io/last-applied-configuration:
 +        {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"my-pod","namespace":"default"},"spec":{"contain 
 +ers":[{"command":["sh","-c","while true; do sleep 3600; done"],"image":"radial/busyboxplus:curl","name":"busybox"}]}} 
 +    creationTimestamp: "2022-09-10T13:03:20Z" 
 +    name: my-pod 
 +    namespace: default 
 +    resourceVersion: "755938" 
 +    uid: 628ca9e4-2fbe-4fc9-b0fa-9a05ef942a07 
 +  spec: 
 +    containers: 
 +    command: 
 +      sh 
 +      - -
 +      while true; do sleep 3600; done 
 +      image: radial/busyboxplus:curl 
 +      imagePullPolicy: IfNotPresent 
 +      name: busybox 
 +      resources: {} 
 +      terminationMessagePath: /dev/termination-log 
 +      terminationMessagePolicy: File 
 +      volumeMounts: 
 +      mountPath: /var/run/secrets/kubernetes.io/serviceaccount 
 +        name: kube-api-access-qwzzv 
 +        readOnly: true 
 +    dnsPolicy: ClusterFirst 
 +    enableServiceLinks: true 
 +    nodeName: kubenode2.ittraining.loc 
 +    preemptionPolicy: PreemptLowerPriority 
 +    priority: 0 
 +    restartPolicy: Always 
 +--More--
 </code> </code>
  
-Pour rectifier cette erreur il convient de faire un Rollback :+L'option **--sort-by** permet de trier la sortie en fonction d'une clef yaml :
  
 <code> <code>
-root@kubemaster:~# kubectl rollout undo deployment/myapp-deployment +root@kubemaster:~# kubectl get pods -o wide --sort-by .spec.nodeName 
-deployment.extensions/myapp-deployment rolled back+NAME                              READY   STATUS    RESTARTS   AGE     IP               NODE                       NOMINATED NODE   READINESS GATES 
 +myapp-deployment-689f9d59-c25f9   1/1     Running            6d1h    192.168.239.9    kubenode1.ittraining.loc   <none>           <none> 
 +myapp-deployment-689f9d59-nn9sw   1/1     Running            6d1h    192.168.239.13   kubenode1.ittraining.loc   <none>           <none> 
 +myapp-deployment-689f9d59-rnc4r   1/    Running            6d1h    192.168.239.12   kubenode1.ittraining.loc   <none>           <none> 
 +my-pod                            1/1     Running            3m22s   192.168.150.9    kubenode2.ittraining.loc   <none>           <none>
 </code> </code>
  
-Constatez ensuite la réussite de la commande :+L'option **--selector** vous permet de ne voir que les pods qui correspondent à l'étiquette indiquée, par exemple, **k8s-app** :
  
 <code> <code>
-root@kubemaster:~# kubectl get pods +root@kubemaster:~# kubectl get pods -n kube-system --selector k8s-app=calico-node 
-NAME                                READY   STATUS    RESTARTS   AGE +NAME                READY   STATUS    RESTARTS   AGE 
-myapp-deployment-57c6cb89d9-dh4cb   1/1     Running            9m38s +calico-node-5htrc   1/1     Running            6d5h 
-myapp-deployment-57c6cb89d9-f69nk   1/1     Running            9m44s +calico-node-dc7hd   1/1     Running            6d5h 
-myapp-deployment-57c6cb89d9-q7d4p   1/1     Running            9m33s +calico-node-qk5kt   1/1     Running            6d5h
- +
-root@kubemaster:~# kubectl rollout history deployment/myapp-deployment +
-deployment.apps/myapp-deployment +
-REVISION  CHANGE-CAUSE +
-1         kubectl create --filename=deployment-definition.yaml --record=true +
-3         kubectl set image deployment/myapp-deployment nginx-container=nginx:1.14 --record=true +
-5         kubectl set image deployment/myapp-deployment nginx-container=nginx1.14 --record=true +
-6         kubectl apply --filename=deployment-definition.yaml --record=true+
 </code> </code>
  
-=====LAB #4 - Gestion de la Maintenance d'un Noeud=====+====La Commande exec====
  
-Afin de procéer à la maintenance d'un noeud, il est souvent necéssaire de le sortir du clusterCette opération s'appelle un **drain**+La commande **exec** permet d'exécuter une commande dans le conteneurLa commande est précédée par les caractères **- -** :
- +
-====4.1 - La Commande drain==== +
- +
-Constatez l'état des pods :+
  
 <code> <code>
-root@kubemaster:~# kubectl get pods -o wide --all-namespaces +root@kubemaster:~# kubectl exec my-pod -c busybox -- echo "Hello, world!" 
-NAMESPACE     NAME                                                READY   STATUS    RESTARTS      AGE   IP               NODE                        NOMINATED NODE   READINESS GATES +Hello, world!
-default       myapp-deployment-57c6cb89d9-dh4cb                   1/    Running               27m   192.168.150.2    kubenode2.ittraining.loc    <none>           <none> +
-default       myapp-deployment-57c6cb89d9-f69nk                   1/    Running               27m   192.168.239.2    kubenode1.ittraining.loc    <none>           <none> +
-default       myapp-deployment-57c6cb89d9-q7d4p                   1/    Running               27m   192.168.150.3    kubenode2.ittraining.loc    <none>           <none> +
-default       nginx                                               1/    Running               32m   192.168.239.1    kubenode1.ittraining.loc    <none>           <none> +
-kube-system   calico-kube-controllers-6799f5f4b4-zk298            1/1     Running               60m   192.168.55.195   kubemaster.ittraining.loc   <none>           <none> +
-kube-system   calico-node-5htrc                                   1/    Running               50m   192.168.56.3     kubenode1.ittraining.loc    <none>           <none> +
-kube-system   calico-node-dc7hd                                   1/    Running               60m   10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   calico-node-qk5kt                                   1/    Running               52m   192.168.56.4     kubenode2.ittraining.loc    <none>           <none> +
-kube-system   coredns-6d4b75cb6d-kxtqk                            1/1     Running               62m   192.168.55.194   kubemaster.ittraining.loc   <none>           <none> +
-kube-system   coredns-6d4b75cb6d-td7cf                            1/1     Running               62m   192.168.55.193   kubemaster.ittraining.loc   <none>           <none> +
-kube-system   etcd-kubemaster.ittraining.loc                      1/1     Running   1 (57m ago)   63m   10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-apiserver-kubemaster.ittraining.loc            1/1     Running   2 (55m ago)   63m   10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-controller-manager-kubemaster.ittraining.loc   1/    Running   5 (50m ago)   63m   10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-proxy-fpksg                                    1/1     Running               62m   10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-proxy-sn26v                                    1/1     Running               50m   192.168.56.3     kubenode1.ittraining.loc    <none>           <none> +
-kube-system   kube-proxy-wxm4z                                    1/1     Running               52m   192.168.56.4     kubenode2.ittraining.loc    <none>           <none> +
-kube-system   kube-scheduler-kubemaster.ittraining.loc            1/1     Running   5 (51m ago)   63m   10.0.2.65        kubemaster.ittraining.loc   <none>           <none>+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Notez que sur **kubenode1.ittraining.loc**, il y a 4 pods, à savoir **myapp-deployment-57c6cb89d9-f69nk**, **nginx**, **calico-node-5htrc**  et **kube-proxy-sn26v**.+**Important** : Notez l'utilisation de **-c** pour pour indiquer le nom du conteneur.
 </WRAP> </WRAP>
  
-Procédez maintenant au drain de kubenode1.ittraining.loc : 
  
-<code> +====5.Commandes Impératives ====
-root@kubemaster:~# kubectl drain kubenode1.ittraining.loc +
-node/kubenode1.ittraining.loc cordoned +
-error: unable to drain node "kubenode1.ittraining.loc" due to error:[cannot delete Pods declare no controller (use --force to override): default/nginx, cannot delete DaemonSet-managed Pods (use --ignore-daemonsets to ignore): kube-system/calico-node-5htrc, kube-system/kube-proxy-sn26v], continuing command... +
-There are pending nodes to be drained: +
- kubenode1.ittraining.loc +
-cannot delete Pods declare no controller (use --force to override): default/nginx +
-cannot delete DaemonSet-managed Pods (use --ignore-daemonsets to ignore): kube-system/calico-node-5htrc, kube-system/kube-proxy-sn26v +
-<code> +
- +
-Notez que la commande retourne deux erreurs : +
- +
-  * cannot delete Pods declare no controller (use --force to override): default/nginx +
-  * cannot delete DaemonSet-managed Pods (use --ignore-daemonsets to ignore): kube-system/calico-node-5htrc, kube-system/kube-proxy-sn26v +
-   +
-La première erreur est due au fait que l'opération ne peux pas déplacer un pod isolé, autrement dit un pod qui n'est pas géré par un Controller d'un vers un autre noeud. Dans ce cas, le drain ne peut que supprimer le pod **nginx** et refuse donc de le faire sans l'utilisation dee l'option **--force**. +
- +
-<WRAP center round important 60%> +
-**Important** : Le mot Controller implique un ReplicationController, un ReplicaSet, un Job, un DaemonSet et un StatefulSet. +
-</WRAP> +
- +
-La deuxième erreur est due au fait que l'opération ne peut pas traiter les DaemonSets. +
- +
-<WRAP center round important 60%> +
-**Important** : Un DaemonSet contient des pods qui sont **liés** à des noeuds **spécifiques**. +
-</WRAP>+
  
-Exécutez donc la commande de nouveau en ajoutant les deux options **--ignore-daemonsets** et **--force** :+Avant de poursuivre, supprimez le pod **my-pod** :
  
 <code> <code>
-root@kubemaster:~# kubectl drain kubenode1.ittraining.loc --ignore-daemonsets --force +root@kubemaster:~# kubectl delete pod my-pod 
-node/kubenode1.ittraining.loc already cordoned +pod "my-pod" deleted
-WARNING: deleting Pods that declare no controller: default/nginx; ignoring DaemonSet-managed Pods: kube-system/calico-node-5htrc, kube-system/kube-proxy-sn26v +
-evicting pod default/nginx +
-evicting pod default/myapp-deployment-57c6cb89d9-f69nk +
-pod/nginx evicted +
-pod/myapp-deployment-57c6cb89d9-f69nk evicted +
-node/kubenode1.ittraining.loc drained+
 </code> </code>
  
-<WRAP center round important 60%> +Créez ensuite un deployment avec une commande impérative :
-**Important** : Notez que la commande n'a pas retourné d'erreurs. +
-</WRAP> +
- +
-Consultez de nouveau l'état des pods :+
  
 <code> <code>
-root@kubemaster:~# kubectl get pods -o wide --all-namespaces +root@kubemaster:~# kubectl create deployment my-deployment --image=nginx 
-NAMESPACE     NAME                                                READY   STATUS    RESTARTS      AGE     IP               NODE                        NOMINATED NODE   READINESS GATES +deployment.apps/my-deployment created
-default       myapp-deployment-57c6cb89d9-dh4cb                   1/    Running               45m     192.168.150.2    kubenode2.ittraining.loc    <none>           <none> +
-default       myapp-deployment-57c6cb89d9-f69nk                   1/    Running               45m     192.168.150.3    kubenode2.ittraining.loc    <none>           <none> +
-default       myapp-deployment-57c6cb89d9-l7lkd                   1/    Running               6m22s   192.168.150.4    kubenode2.ittraining.loc    <none>           <none> +
-kube-system   calico-kube-controllers-6799f5f4b4-zk298            1/1     Running               77m     192.168.55.195   kubemaster.ittraining.loc   <none>           <none> +
-kube-system   calico-node-5htrc                                   1/    Running               68m     192.168.56.3     kubenode1.ittraining.loc    <none>           <none> +
-kube-system   calico-node-dc7hd                                   1/    Running               77m     10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   calico-node-qk5kt                                   1/    Running               70m     192.168.56.4     kubenode2.ittraining.loc    <none>           <none> +
-kube-system   coredns-6d4b75cb6d-kxtqk                            1/1     Running               80m     192.168.55.194   kubemaster.ittraining.loc   <none>           <none> +
-kube-system   coredns-6d4b75cb6d-td7cf                            1/1     Running               80m     192.168.55.193   kubemaster.ittraining.loc   <none>           <none> +
-kube-system   etcd-kubemaster.ittraining.loc                      1/1     Running   1 (74m ago)   80m     10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-apiserver-kubemaster.ittraining.loc            1/1     Running   2 (73m ago)   80m     10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-controller-manager-kubemaster.ittraining.loc   1/    Running   5 (67m ago)   80m     10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-proxy-fpksg                                    1/1     Running               80m     10.0.2.65        kubemaster.ittraining.loc   <none>           <none> +
-kube-system   kube-proxy-sn26v                                    1/1     Running               68m     192.168.56.3     kubenode1.ittraining.loc    <none>           <none> +
-kube-system   kube-proxy-wxm4z                                    1/1     Running               70m     192.168.56.4     kubenode2.ittraining.loc    <none>           <none> +
-kube-system   kube-scheduler-kubemaster.ittraining.loc            1/1     Running   5 (68m ago)   80m     10.0.2.65        kubemaster.ittraining.loc   <none>           <none>+
 </code> </code>
  
-<WRAP center round important 60%> +En exécutant la même commande impérative, il est possible de créer des instructions au format yaml en utilisant l'option **--dry-run** :
-**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. +
-</WRAP> +
- +
-Constatez maintenant l'état des noeuds :+
  
 <code> <code>
-root@kubemaster:~# kubectl get nodes +root@kubemaster:~# kubectl create deployment my-deployment --image=nginx --dry-run -o yaml 
-NAME                        STATUS                     ROLES           AGE   VERSION +W0910 15:28:49.797172   17135 helpers.go:639] --dry-run is deprecated and can be replaced with --dry-run=client
-kubemaster.ittraining.loc   Ready                      control-plane   91m   v1.24.2 +apiVersion: apps/v1 
-kubenode1.ittraining.loc    Ready,SchedulingDisabled   <none>          80m   v1.24.2 +kind: Deployment 
-kubenode2.ittraining.loc    Ready                      <none>          82m   v1.24.2+metadata: 
 +  creationTimestamp: null 
 +  labels: 
 +    app: my-deployment 
 +  name: my-deployment 
 +spec: 
 +  replicas: 1 
 +  selector: 
 +    matchLabels: 
 +      app: my-deployment 
 +  strategy: {} 
 +  template: 
 +    metadata: 
 +      creationTimestamp: null 
 +      labels: 
 +        app: my-deployment 
 +    spec: 
 +      containers: 
 +      - image: nginx 
 +        name: nginx 
 +        resources: {} 
 +status: {}
 </code> </code>
  
-<WRAP center round important 60%> +Ces instructions peuvent ensuite être injectées dans un fichier afin d'utiliser celui-ci pour créer un deployment indentique :
-**Important** : Notez que le STATUS de **kubenode1.ittraining.loc** est **SchedulingDisabled** ce qui implique que le noeud n'accepte plus de nouveaux pods. Dans cet état le neoud est dit **cordoned**. +
-</WRAP> +
- +
-====4.2 - La Commande uncordon==== +
- +
-Pour permettre le noeud de recevoir de nouveau des pods, il convient d'utiliser la commande suivante :+
  
 <code> <code>
-root@kubemaster:~# kubectl uncordon kubenode1.ittraining.loc +root@kubemaster:~# kubectl create deployment my-deployment --image=nginx --dry-run -o yaml > deployment.yml 
-node/kubenode1.ittraining.loc uncordoned+W0910 15:29:05.006256   17242 helpers.go:639] --dry-run is deprecated and can be replaced with --dry-run=client.
 </code> </code>
- 
-Constatez de nouveau l'état des noeuds : 
  
 <code> <code>
-root@kubemaster:~# kubectl get nodes +root@kubemaster:~# cat deployment.yml 
-NAME                        STATUS   ROLES           AGE    VERSION +apiVersion: apps/v1 
-kubemaster.ittraining.loc   Ready    control-plane   124m   v1.24.2 +kind: Deployment 
-kubenode1.ittraining.loc    Ready    <none>          113m   v1.24.2 +metadata: 
-kubenode2.ittraining.loc    Ready    <none>          115m   v1.24.2+  creationTimestamp: null 
 +  labels: 
 +    app: my-deployment 
 +  name: my-deployment 
 +spec: 
 +  replicas: 1 
 +  selector: 
 +    matchLabels: 
 +      app: my-deployment 
 +  strategy: {} 
 +  template: 
 +    metadata: 
 +      creationTimestamp: null 
 +      labels: 
 +        app: my-deployment 
 +    spec: 
 +      containers: 
 +      - image: nginx 
 +        name: nginx 
 +        resources: {} 
 +status: {}
 </code> </code>
  
-Dernièrement consultez de nouveau l'état des pods :+=====LAB #2 - Géstion les plugins de kubectl avec la Commande krew===== 
 + 
 +Les plugins de kubectl étendent ses fonctionnalités. Le gestionnaire des plugins **krew** est disponible pour macOS(tm), Windows(tm) et Linux. Un plugin est un simple exécutable écrit, par exemple, en **bash** ou en **Go**. 
 + 
 +====2.1 - Installation de krew==== 
 + 
 +Afin d'installer la commande **krew**, il faut d'abord installer **git** :
  
 <code> <code>
-root@kubemaster:~# kubectl get pods -o wide +root@kubemaster:~# apt install git-all
-NAME                                READY   STATUS    RESTARTS   AGE   IP              NODE                       NOMINATED NODE   READINESS GATES +
-myapp-deployment-57c6cb89d9-dh4cb   1/    Running            91m   192.168.150.2   kubenode2.ittraining.loc   <none>           <none> +
-myapp-deployment-57c6cb89d9-f69nk   1/    Running            91m   192.168.150.3   kubenode2.ittraining.loc   <none>           <none> +
-myapp-deployment-57c6cb89d9-l7lkd   1/    Running            52m   192.168.150.4   kubenode2.ittraining.loc   <none>           <none>+
 </code> </code>
  
-<WRAP center round important 60%> +Installez ensuite krew avec la commande suivante :
-**Important** : Notez que l'utilisation de la commande **uncordon** n'implique pas le basculement du pod **l7lkd** vers le noeud **kubenode2.ittraining.loc**. +
-</WRAP>+
  
-=====LAB #5 Mise-à-jour de K8s===== +<file> 
- +
-====5.Mise-à-jour de kubeadm====+  set -x; cd "$(mktemp -d)" && 
 +  curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/download/v0.4.3/krew-linux_amd64.tar.gz" && 
 +  tar zxvf krew-linux_amd64.tar.gz && 
 +  KREW=./krew-"$(uname | tr '[:upper:]' '[:lower:]')_$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm.*$/arm/')" && 
 +  "$KREW" install krew 
 +
 +</file>
  
-Afin de mettre à jour kubeadm, il convient de faire un drain du **Contrôleur** :+Vous obtiendrez :
  
 <code> <code>
-root@kubemaster:~# kubectl drain kubemaster.ittraining.loc --ignore-daemonsets +root@kubemaster:~# 
-node/kubemaster.ittraining.loc cordoned +>   set -x; cd "$(mktemp -d)" && 
-WARNING: ignoring DaemonSet-managed Pods: kube-system/calico-node-dc7hd, kube-system/kube-proxy-fpksg +>   curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/download/v0.4.3/krew-linux_amd64.tar.gz" && 
-evicting pod kube-system/coredns-6d4b75cb6d-td7cf +>   tar zxvf krew-linux_amd64.tar.gz && 
-evicting pod kube-system/calico-kube-controllers-6799f5f4b4-zk298 +>   KREW=./krew-"$(uname | tr '[:upper:]' '[:lower:]')_$(uname -m | sed -e 's/x86_64/amd64/-e 's/arm.*$/arm/')" && 
-evicting pod kube-system/coredns-6d4b75cb6d-kxtqk +>   "$KREW" install krew 
-pod/calico-kube-controllers-6799f5f4b4-zk298 evicted +> ) 
-pod/coredns-6d4b75cb6d-td7cf evicted +++ mktemp -d 
-pod/coredns-6d4b75cb6d-kxtqk evicted ++ cd /tmp/tmp.eA3ZH8tKRg 
-node/kubemaster.ittraining.loc drained++ curl -fsSLO https://github.com/kubernetes-sigs/krew/releases/download/v0.4.3/krew-linux_amd64.tar.gz 
 ++ tar zxvf krew-linux_amd64.tar.gz 
 +./LICENSE 
 +./krew-linux_amd64 
 +++ uname 
 +++ tr '[:upper:]' '[:lower:]' 
 +++ uname -
 +++ sed -e s/x86_64/amd64/ -e 's/arm.*$/arm/' 
 ++ KREW=./krew-linux_amd64 
 ++ ./krew-linux_amd64 install krew 
 +Adding "default" plugin index from https://github.com/kubernetes-sigs/krew-index.git. 
 +Updated the local copy of plugin index. 
 +Installing plugin: krew 
 +Installed plugin: krew 
 +
 + | Use this plugin: 
 +      kubectl krew 
 + | Documentation: 
 +      https://krew.sigs.k8s.io/ 
 + | Caveats: 
 + | \ 
 +  | krew is now installed! To start using kubectl plugins, you need to add 
 +  | krew's installation directory to your PATH: 
 + 
 +  |   * macOS/Linux: 
 +  |     Add the following to your ~/.bashrc or ~/.zshrc: 
 +  |         export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" 
 + |  |     - Restart your shell. 
 + 
 +  |   * Windows: Add %USERPROFILE%\.krew\bin to your PATH environment variable 
 + 
 +  | To list krew commands and to get help, run: 
 +  |   $ kubectl krew 
 +  | For a full list of available plugins, run: 
 +  |   $ kubectl krew search 
 + 
 +  | You can find documentation at 
 +  |   https://krew.sigs.k8s.io/docs/user-guide/quickstart/
 + | / 
 +/
 </code> </code>
  
-Afin de connaître la ou les version(s) supérieure(s) à celle installée, utilisez la commande suivante :+Ensuite ajoutez **$HOME/.krew/bin** à votre PATH :
  
 <code> <code>
- +root@kubemaster:~# export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
-root@kubemaster:~# apt-cache madison kubeadm | more +
-   kubeadm |  1.25.0-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.24.4-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.24.3-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.24.2-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.24.1-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.24.0-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm | 1.23.10-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.9-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.8-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.7-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.6-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.5-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.4-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.3-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.2-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.1-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.23.0-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm | 1.22.13-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm | 1.22.12-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm | 1.22.11-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm | 1.22.10-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.22.9-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.22.8-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.22.7-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
-   kubeadm |  1.22.6-00 | https://apt.kubernetes.io kubernetes-xenial/main amd64 Packages +
---Plus-- +
-[q]+
 </code> </code>
  
-<WRAP center round important 60%> +Afin de ne pas avoir besoin de redéfinir le PATH après chaque ouverture de session, ajoutez la ligne à la fin du fichier **.bashrc** :
-**Important** : Notez que la version la plus récente est la **1.25.0-00**+
-</WRAP> +
- +
-Procédez maintenant à la mise-à-jour de kubeadm :+
  
 <code> <code>
-root@kubemaster:~# apt-get update && apt-get install -y --allow-change-held-packages kubeadm=1.25.0-00 +root@kubemaster:~# echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH">> .bashrc
-Atteint:1 http://security.debian.org/debian-security stretch/updates InRelease +
-Ign:2 http://ftp.fr.debian.org/debian stretch InRelease +
-Atteint:3 http://ftp.fr.debian.org/debian stretch-updates InRelease +
-Atteint:4 http://ftp.fr.debian.org/debian stretch Release +
-Réception de:5 https://download.docker.com/linux/debian stretch InRelease [44,8 kB] +
-Atteint:6 https://packages.cloud.google.com/apt kubernetes-xenial InRelease +
-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'état... Fait +
-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'espace disque seront libérés. +
-Réception de:1 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubeadm amd64 1.25.0-00 [9 213 kB] +
-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 .../kubeadm_1.25.0-00_amd64.deb ... +
-Dépaquetage de kubeadm (1.25.0-00) sur (1.24.2-00) ... +
-Paramétrage de kubeadm (1.25.0-00) ...+
 </code> </code>
  
-<WRAP center round important 60%> +====2.2 - Consultation de la liste des plugins ====
-**Important** : Notez que l'utilisation de l'option **--allow-change-held-packages**. +
-</WRAP>+
  
-Vérifiez que la version désirée a été installée :+Mettez à jour la liste des plugins :
  
 <code> <code>
-root@kubemaster:~# kubeadm version +root@kubemaster:~# kubectl krew update 
-kubeadm version: &version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.0", GitCommit:"a866cbe2e5bbaa01cfd5e969aa3e033f3282a8a2", GitTreeState:"clean", BuildDate:"2022-08-23T17:43:25Z", GoVersion:"go1.19", Compiler:"gc", Platform:"linux/amd64"}+Updated the local copy of plugin index.
 </code> </code>
  
-Afin de connaître les version des composants du Control Plane compatibles avec la version 1.25.0 de kubeadmutilisez la commande **kubeadm upgrade plan** :+Pour visualiser la liste des pluginsutiisez la commande **search** :
  
 <code> <code>
-root@kubemaster:~# kubeadm upgrade plan +root@kubemaster:~# kubectl krew search 
-[upgrade/config] Making sure the configuration is correct: +NAME                            DESCRIPTION                                         INSTALLED 
-[upgrade/config] Reading configuration from the cluster... +access-matrix                   Show an RBAC access matrix for server resources     no 
-[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' +accurate                        Manage Accurate, a multi-tenancy controller         no 
-[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace +advise-policy                   Suggests PodSecurityPolicies and OPA Policies f...  no 
-[preflight] Running pre-flight checks+advise-psp                      Suggests PodSecurityPolicies for cluster.           no 
-[upgrade] Running cluster health checks +allctx                          Run commands on contexts in your kubeconfig         no 
-[upgrade] Fetching available versions to upgrade to +apparmor-manager                Manage AppArmor profiles for cluster.               no 
-[upgrade/versions] Cluster version: v1.24.2 +assert                          Assert Kubernetes resources                         no 
-[upgrade/versions] kubeadm version: v1.25.0 +auth-proxy                      Authentication proxy to a pod or service            no 
-[upgrade/versions] Target version: v1.25.0 +aws-auth                        Manage aws-auth ConfigMap                           no 
-[upgrade/versions] Latest version in the v1.24 series: v1.24.4 +azad-proxy                      Generate and handle authentication for azad-kub...  no 
- +bd-xray                         Run Black Duck Image Scans                          no 
-Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply': +blame                           Show who edited resource fields.                    no 
-COMPONENT   CURRENT       TARGET +bulk-action                     Do bulk actions on Kubernetes resources.            no 
-kubelet     3 x v1.24.2   v1.24.4 +ca-cert                         Print the PEM CA certificate of the current clu...  no 
- +capture                         Triggers a Sysdig capture to troubleshoot the r...  no 
-Upgrade to the latest version in the v1.24 series: +cert-manager                    Manage cert-manager resources inside your cluster   no 
- +change-ns                       View or change the current namespace via kubectl  no 
-COMPONENT                 CURRENT   TARGET +cilium                          Easily interact with Cilium agents.                 no 
-kube-apiserver            v1.24.  v1.24.4 +cluster-group                   Exec commands across a group of contexts.           no 
-kube-controller-manager   v1.24.2   v1.24.4 +clusternet                      Wrap multiple kubectl calls to Clusternet           no 
-kube-scheduler            v1.24.2   v1.24.4 +cm                              Provides commands for OCM/MCE/ACM                 no 
-kube-proxy                v1.24.2   v1.24.4 +cnpg                            Manage your CloudNativePG clusters                  no 
-CoreDNS                   v1.8.6    v1.9.3 +config-cleanup                  Automatically clean up your kubeconfig              no 
-etcd                      3.5.3-0   3.5.4-0 +config-registry                 Switch between registered kubeconfigs               no 
- +cost                            View cluster cost information                       no 
-You can now apply the upgrade by executing the following command: +creyaml                         Generate custom resource YAML manifest              no 
- +ctx                             Switch between contexts in your kubeconfig          no 
-        kubeadm upgrade apply v1.24.4 +custom-cols                     A "kubectl get" replacement with customizable c...  no 
- +cyclonus                        NetworkPolicy analysis tool suite                   no 
-_____________________________________________________________________ +datadog                         Manage the Datadog Operator                         no 
- +datree                          Scan your cluster resources for misconfigurations   no 
-Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply': +dds                             Detect if workloads are mounting the docker socket  no 
-COMPONENT   CURRENT       TARGET +debug-shell                     Create pod with interactive kube-shell            no 
-kubelet     3 x v1.24.2   v1.25.0 +deprecations                    Checks for deprecated objects in a cluster          no 
- +df-pv                           Show disk usage (like unix df) for persistent v...  no 
-Upgrade to the latest stable version: +direct-csi                      CSI driver to manage drives in k8s cluster as v...  no 
- +directpv                        Deploys and manages the lifecycle of DirectPV C...  no 
-COMPONENT                 CURRENT   TARGET +doctor                          Scans your cluster and reports anomalies.           no 
-kube-apiserver            v1.24.2   v1.25.0 +dtlogin                         Login to a cluster via openid-connect               no 
-kube-controller-manager   v1.24.2   v1.25.0 +duck                            List custom resources with ducktype support         no 
-kube-scheduler            v1.24.2   v1.25.0 +edit-status                     Edit /status subresources of CRs                    no 
-kube-proxy                v1.24.2   v1.25.0 +eds                             Interact and manage ExtendedDaemonset resources     no 
-CoreDNS                   v1.8.6    v1.9.3 +eksporter                       Export resources and removes a pre-defined set ...  no 
-etcd                      3.5.3-0   3.5.4-0 +emit-event                      Emit Kubernetes Events for the requested object     no 
- +evict-pod                       Evicts the given pod                                no 
-You can now apply the upgrade by executing the following command: +example                         Prints out example manifest YAMLs                   no 
- +exec-as                         Like kubectl exec, but offers a `user` flag to ...  no 
-        kubeadm upgrade apply v1.25.0 +exec-cronjob                    Run a CronJob immediately as Job                    no 
- +explore                         A better kubectl explain with the fuzzy finder      no 
-_____________________________________________________________________ +fields                          Grep resources hierarchy by field name              no 
- +flame                           Generate CPU flame graphs from pods                 no 
- +fleet                           Shows config and resources of a fleet of clusters   no 
-The table below shows the current state of component configs as understood by this version of kubeadm+flyte                           Monitor, launch and manage flyte executions         no 
-Configs that have a "yesmark in the "MANUAL UPGRADE REQUIRED" column require manual config upgrade or +fuzzy                           Fuzzy and partial string search for kubectl         no 
-resetting to kubeadm defaults before successful upgrade can be performedThe version to manually +gadget                          Gadgets for debugging and introspecting apps        no 
-upgrade to is denoted in the "PREFERRED VERSION" column+get-all                         Like `kubectl get all` but _really_ everything      no 
- +gke-credentials                 Fetch credentials for GKE clusters                  no 
-API GROUP                 CURRENT VERSION   PREFERRED VERSION   MANUAL UPGRADE REQUIRED +gopass                          Imports secrets from gopass                         no 
-kubeproxy.config.k8s.io   v1alpha1          v1alpha1            no +graph                           Visualize Kubernetes resources and relationships.   no 
-kubelet.config.k8s.io     v1beta1           v1beta1             no +grep                            Filter Kubernetes resources by matching their n...  no 
-_____________________________________________________________________ +gs                              Handle custom resources with Giant Swarm            no 
 +hlf                             Deploy and manage Hyperledger Fabric components     no 
 +hns                             Manage hierarchical namespaces (part of HNC)        no 
 +htpasswd                        Create nginx-ingress compatible basic-auth secrets  no 
 +ice                             View configuration settings of containers insid...  no 
 +iexec                           Interactive selection tool for `kubectl exec`       no 
 +images                          Show container images used in the cluster         no 
 +ingress-nginx                   Interact with ingress-nginx                         no 
 +ingress-rule                    Update Ingress rules via command line               no 
 +ipick                           A kubectl wrapper for interactive resource sele...  no 
 +istiolog                        Manipulate istio-proxy logging level without is...  no 
 +janitor                         Lists objects in a problematic state                no 
 +kadalu                          Manage Kadalu Operator, CSI and Storage pods        no 
 +karbon                          Connect to Nutanix Karbon cluster                   no 
 +karmada                         Manage clusters with Karmada federation           no 
 +konfig                          Merge, split or import kubeconfig files             no 
 +krew                            Package manager for kubectl plugins               yes 
 +kruise                          Easily handle OpenKruise workloads                  no 
 +ks                              Simple management of KubeSphere components          no 
 +ktop                            A top tool to display workload metrics              no 
 +kubesec-scan                    Scan Kubernetes resources with kubesec.io         no 
 +kudo                            Declaratively build, install, and run operators...  no 
 +kuota-calc                      Calculate needed quota to perform rolling updates no 
 +kurt                            Find what's restarting and why                      no 
 +kuttl                           Declaratively run and test operators                no 
 +kyverno                         Kyverno is a policy engine for kubernetes           no 
 +lineage                         Display all dependent resources or resource dep...  no 
 +linstor                         View and manage LINSTOR storage resources           no 
 +liqo                            Install and manage Liqo on your clusters            no 
 +log2rbac                        Fine-tune your RBAC using log2rbac operator         no 
 +match-name                      Match names of pods and other API objects           no 
 +mc                              Run kubectl commands against multiple clusters ...  no 
 +minio                           Deploy and manage MinIO Operator and Tenant(s)      no 
 +moco                            Interact with MySQL operator MOCO.                  no 
 +modify-secret                   modify secret with implicit base64 translations     no 
 +mtail                           Tail logs from multiple pods matching label sel...  no 
 +multiforward                    Port Forward to multiple Kubernetes Services        no 
 +multinet                        Shows pods' network-status of multi-net-spec        no 
 +neat                            Remove clutter from Kubernetes manifests to mak...  no 
 +net-forward                     Proxy to arbitrary TCP services on a cluster ne...  no 
 +node-admin                      List nodes and run privileged pod with chroot       no 
 +node-restart                    Restart cluster nodes sequentially and gracefully   no 
 +node-shell                      Spawn a root shell on a node via kubectl            no 
 +np-viewer                       Network Policies rules viewer                       no 
 +ns                              Switch between Kubernetes namespaces                no 
 +nsenter                         Run shell command in Pod's namespace on the nod...  no 
 +oidc-login                      Log in to the OpenID Connect provider               no 
 +open-svc                        Open the Kubernetes URL(s) for the specified se...  no 
 +openebs                         View and debug OpenEBS storage resources            no 
 +operator                        Manage operators with Operator Lifecycle Manager    no 
 +oulogin                         Login to a cluster via OpenUnison                   no 
 +outdated                        Finds outdated container images running in a cl...  no 
 +passman                         Store kubeconfig credentials in keychains or pa...  no 
 +pexec                           Execute process with privileges in a pod            no 
 +pod-dive                        Shows a pod's workload tree and info inside a node  no 
 +pod-inspect                     Get all of a pod's details at a glance              no 
 +pod-lens                        Show pod-related resources                          no 
 +pod-logs                        Display a list of pods to get logs from             no 
 +pod-shell                       Display a list of pods to execute a shell in        no 
 +podevents                       Show events for pods                                no 
 +popeye                          Scans your clusters for potential resource issues   no 
 +preflight                       Executes application preflight tests in a cluster   no 
 +print-env                       Build config files from k8s environments          no 
 +profefe                         Gather and manage pprof profiles from running pods  no 
 +promdump                        Dumps the head and persistent blocks of Prometh...  no 
 +prompt                          Prompts for user confirmation when executing co...  no 
 +prune-unused                    Prune unused resources                              no 
 +psp-util                        Manage Pod Security Policy(PSP) and the related...  no 
 +pv-migrate                      Migrate data across persistent volumes              no 
 +pvmigrate                       Migrates PVs between StorageClasses                 no 
 +rabbitmq                        Manage RabbitMQ clusters                            no 
 +rbac-lookup                     Reverse lookup for RBAC                             no 
 +rbac-tool                       Plugin to analyze RBAC permissions and generate...  no 
 +rbac-view                       A tool to visualize your RBAC permissions         no 
 +realname-diff                   Diffs live and local resources ignoring Kustomi...  no 
 +reap                            Delete unused Kubernetes resources                no 
 +relay                           Drop-in "port-forward" replacement with UDP and...  no 
 +reliably                        Surfaces reliability issues in Kubernetes           no 
 +rename-pvc                      Rename a PersistentVolumeClaim (PVC)                no 
 +resource-capacity               Provides an overview of resource requests, limi...  no 
 +resource-snapshot               Prints a snapshot of nodes, pods and HPAs resou...  no 
 +resource-versions               Print supported API resource versions               no 
 +restart                         Restarts a pod with the given name                  no 
 +rm-standalone-pods              Remove all pods without owner references            no 
 +rolesum                         Summarize RBAC roles for subjects                   no 
 +roll                            Rolling restart of all persistent pods in a nam...  no 
 +rook-ceph                       Rook plugin for Ceph management                     no 
 +safe                            Prompts before running edit commands                no 
 +schemahero                      Declarative database schema migrations via YAML     no 
 +score                           Kubernetes static code analysis.                    no 
 +secretdata                      Viewing decoded Secret data with search flags       no 
 +service-tree                    Status for ingresses, services, and their backends  no 
 +shovel                          Gather diagnostics for .NET Core applications       no 
 +sick-pods                       Find and debug Pods that are "Not Ready           no 
 +skew                            Find if your cluster/kubectl version is skewed      no 
 +slice                           Split a multi-YAML file into individual files.      no 
 +snap                            Delete half of the pods in a namespace or cluster   no 
 +sniff                           Start remote packet capture on pods using tcp...  no 
 +socks5-proxy                    SOCKS5 proxy to Services or Pods in the cluster     no 
 +sort-manifests                  Sort manifest files in a proper order by Kind       no 
 +split-yaml                      Split YAML output into one file per resource      no 
 +spy                             pod debugging tool for kubernetes clusters with...  no 
 +sql                             Query the cluster via pseudo-SQL                    no 
 +ssh-jump                        Access nodes or services using SSH jump Pod         no 
 +sshd                            Run SSH server in a Pod                             no 
 +ssm-secret                      Import/export secrets from/to AWS SSM param store   no 
 +starboard                       Toolkit for finding risks in kubernetes resources   no 
 +status                          Show status details of a given resource           no 
 +stern                           Multi pod and container log tailing                 no 
 +strace                          Capture strace logs from a running workload         no 
 +sudo                            Run Kubernetes commands impersonated as group s...  no 
 +support-bundle                  Creates support bundles for off-cluster analysis    no 
 +switch-config                   Switches between kubeconfig files                   no 
 +tail                            Stream logs from multiple pods and containers u...  no 
 +tap                             Interactively proxy Kubernetes Services with ease   no 
 +tmux-exec                       An exec multiplexer using Tmux                      no 
 +topology                        Explore region topology for nodes or pods           no 
 +trace                           Trace Kubernetes pods and nodes with system tools   no 
 +tree                            Show a tree of object hierarchies through owner...  no 
 +tunnel                          Reverse tunneling between cluster and your machine  no 
 +unused-volumes                  List unused PVCs                                    no 
 +vela                            Easily interact with KubeVela                       no 
 +view-allocations                List allocations per resources, nodes, pods.        no 
 +view-cert                       View certificate information stored in secrets      no 
 +view-secret                     Decode Kubernetes secrets                           no 
 +view-serviceaccount-kubeconfig  Show a kubeconfig setting to access the apiserv...  no 
 +view-utilization                Shows cluster cpu and memory utilization            no 
 +view-webhook                    Visualize your webhook configurations               no 
 +viewnode                        Displays nodes with their pods and containers a...  no 
 +virt                            Control KubeVirt virtual machines using virtctl     no 
 +volsync                         Manage replication with the VolSync operator        no 
 +vpa-recommendation              Compare VPA recommendations to actual resources...  no 
 +warp                            Sync and execute local files in Pod                 no 
 +whisper-secret                  Create secrets with improved privacy                no 
 +who-can                         Shows who has RBAC permissions to access Kubern...  no 
 +whoami                          Show the subject that's currently authenticated...  no
 </code> </code>
  
-Procédez donc à la mise-à-jour de kubeadm vers la version **1.25.0** :+====2.3 Installation et utilisation de plugins====
  
-<code> +Installez les plugins **ctx**, **ns**, **view-allocations** et **pod-logs** :
-root@kubemaster:~# kubeadm upgrade apply v1.25.0 +
-[upgrade/config] Making sure the configuration is correct: +
-[upgrade/config] Reading configuration from the cluster... +
-[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' +
-[preflight] Running pre-flight checks. +
-[upgrade] Running cluster health checks +
-[upgrade/version] You have chosen to change the cluster version to "v1.25.0" +
-[upgrade/versions] Cluster version: v1.24.2 +
-[upgrade/versions] kubeadm version: v1.25.0 +
-[upgrade] Are you sure you want to proceed? [y/N]: y +
-</code> +
- +
-A l'issu de processus, vous verrez les deux lignes suivantes :+
  
 <code> <code>
-... +root@kubemaster:~# kubectl krew install ctx ns view-allocations pod-logs 
-[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.25.0"Enjoy! +Updated the local copy of plugin index. 
- +Installing plugin: ctx 
-[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so+Installed plugin: ctx 
-root@kubemaster:~#+
 + | Use this plugin: 
 +      kubectl ctx 
 + | Documentation: 
 +      https://github.com/ahmetb/kubectx 
 + | Caveats: 
 + | \ 
 +  | If fzf is installed on your machine, you can interactively choose 
 +  | between the entries using the arrow keys, or by fuzzy searching 
 +  | as you type
 + |  | See https://github.com/ahmetb/kubectx for customization and details. 
 + | / 
 +
 +WARNING: You installed plugin "ctxfrom the krew-index plugin repository
 +   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: 
 +      kubectl ns 
 + | Documentation: 
 +      https://github.com/ahmetb/kubectx 
 + | Caveats: 
 + | \ 
 +  | If fzf is installed on your machine, you can interactively choose 
 +  | between the entries using the arrow keys, or by fuzzy searching 
 +  | as you type
 + | / 
 +
 +WARNINGYou installed plugin "ns" from the krew-index plugin repository. 
 +   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: 
 +      kubectl view-allocations 
 + | Documentation: 
 +      https://github.com/davidB/kubectl-view-allocations 
 +
 +WARNING: You installed plugin "view-allocations" from the krew-index plugin repository. 
 +   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: 
 +      kubectl pod-logs 
 + | Documentation: 
 +      https://github.com/danisla/kubefunc 
 +
 +WARNING: You installed plugin "pod-logs" from the krew-index plugin repository. 
 +   These plugins are not audited for security by the Krew maintainers. 
 +   Run them at your own risk.
 </code> </code>
  
-Mettez-à-jour maintenant **kubelet** et **kubectl** :+Le plugin **ctx** permet de basculer entre les **contextes** facilement. Un contexte est un élément qui regroupe les paramètres d'accès sous un nom. Les paramètres d'accès sont au nombre de trois, à savoir le cluster, le namespace et l'utilisateur. La commande kubectl utilise les paramètres du contexte courant pour communiquer avec le cluster. Listez donc les contextes dans le cluster :
  
 <code> <code>
-root@kubemaster:~# apt-get update && apt-get install -y --allow-change-held-packages kubelet=1.25.0-00 kubectl=1.25.0-00 +root@kubemaster:~# kubectl ctx 
-...+kubernetes-admin@kubernetes
 </code> </code>
  
-Au cas où le fichier du service de kubelet a subi des modifications, re-démarrez le daemon systemctl ainsi que le service kubelet :+Le plugin **ns** permet de basculer entre les **namespaces** facilement.
  
-<code> +Les Namespaces :
-root@kubemaster:~# systemctl daemon-reload+
  
-root@kubemaster:~# systemctl restart kubelet +  * peuvent être considérées comme des clusters virtuels, 
-</code>+  * permettent l'isolation et la segmentation logique, 
 +  * permettent le regroupement d'utilisateurs, de rôles et de ressources, 
 +  * sont utilisés avec des applications, des clients, des projets ou des équipes.
  
-Annulez le drain de kubemaster :+Listez les namespaces dans le cluster :
  
 <code> <code>
-root@kubemaster:~# kubectl uncordon kubemaster.ittraining.loc +root@kubemaster:~# kubectl ns 
-node/kubemaster.ittraining.loc uncordoned+default 
 +kube-node-lease 
 +kube-public 
 +kube-system
 </code> </code>
  
-Constatez maintenant l'état des noeuds :+Le plugin **view-allocations** permet de visualiser les allocations de ressources telles le CPU, la mémoire, le stockage etc :
  
 <code> <code>
-root@kubemaster:~# kubectl get nodes +root@kubemaster:~# kubectl view-allocations 
-NAME                        STATUS   ROLES           AGE     VERSION + Resource                                                     Requested         Limit  Allocatable    Free 
-kubemaster.ittraining.loc   Ready    control-plane   3h15m   v1.25.0 +  cpu                                                         (13%) 1.6            __         12.0    10.4 
-kubenode1.ittraining.loc    Ready    <none>          3h4m    v1.24.2 +  ├─ kubemaster.ittraining.loc                                (28%) 1.1            __          4.0     2.9 
-kubenode2.ittraining.loc    Ready    <none>          3h6m    v1.24.2+  │  ├─ calico-node-688lw                                        250.0m            __           __      __ 
 +  │  ├─ coredns-6d4b75cb6d-dw4ph                                 100.0m            __           __      __ 
 +  │  ├─ coredns-6d4b75cb6d-ms2jm                                 100.0m            __           __      __ 
 +  │  ├─ etcd-kubemaster.ittraining.loc                           100.0m            __           __      __ 
 +  │  ├─ kube-apiserver-kubemaster.ittraining.loc                 250.0m            __           __      __ 
 +  │  ├─ kube-controller-manager-kubemaster.ittraining.loc        200.0m            __           __      __ 
 +  │  └─ kube-scheduler-kubemaster.ittraining.loc                 100.0m            __           __      __ 
 +  ├─ kubenode1.ittraining.loc                               (6%) 250.0m            __          4.0     3.
 +  │  └─ calico-node-5mrjl                                        250.0m            __           __      __ 
 +  └─ kubenode2.ittraining.loc                               (6%) 250.0m            __          4.0     3.
 +     └─ calico-node-j25xd                                        250.0m            __           __      __ 
 +  ephemeral-storage                                                  __            __        50.9G      __ 
 +  ├─ kubemaster.ittraining.loc                                       __            __        17.0G      __ 
 +  ├─ kubenode1.ittraining.loc                                        __            __        17.0G      __ 
 +  └─ kubenode2.ittraining.loc                                        __            __        17.0G      __ 
 +  memory                                                   (1%) 240.0Mi  (1%) 340.0Mi       31.0Gi  30.7Gi 
 +  ├─ kubemaster.ittraining.loc                             (2%) 240.0Mi  (2%) 340.0Mi       15.6Gi  15.2Gi 
 +  │  ├─ coredns-6d4b75cb6d-dw4ph                                 70.0Mi       170.0Mi           __      __ 
 +  │  ├─ coredns-6d4b75cb6d-ms2jm                                 70.0Mi       170.0Mi           __      __ 
 +  │  └─ etcd-kubemaster.ittraining.loc                          100.0Mi            __           __      __ 
 +  ├─ kubenode1.ittraining.loc                                        __            __        7.7Gi      __ 
 +  └─ kubenode2.ittraining.loc                                        __            __        7.7Gi      __ 
 +  pods                                                        (5%) 17.0     (5%) 17.0        330.0   313.0 
 +  ├─ kubemaster.ittraining.loc                                 (7%) 8.0      (7%) 8.0        110.0   102.0 
 +  ├─ kubenode1.ittraining.loc                                  (4%) 4.0      (4%) 4.0        110.0   106.0 
 +  └─ kubenode2.ittraining.loc                                  (5%) 5.0      (5%) 5.0        110.0   105.0
 </code> </code>
  
-<WRAP center round important 60%> +Le plugin **pod-logs** vous fourni avec une liste de pods en cours d'exécution et vous demande d'en choisir une :
-**Important** : Notez que le Control Plane est à la version 1.25.0 tandis que les Travailleurs sont à la version 1.24.2. +
-</WRAP> +
- +
-====5.2 - Mise-à-jour des Travailleurs==== +
- +
-Afin de mettre à jour un Travailleur, il convient de faire un drain du Travailleur concerné :+
  
 <code> <code>
-root@kubemaster:~# kubectl drain kubenode1.ittraining.loc --ignore-daemonsets --force +root@kubemaster:~# kubectl pod-logs 
-node/kubenode1.ittraining.loc cordoned +1)   myapp-deployment-57c6cb89d9-dh4cb                  default      Running 
-Warning: ignoring DaemonSet-managed Pods: kube-system/calico-node-5htrc, kube-system/kube-proxy-x5j2r +2)   myapp-deployment-57c6cb89d9-f69nk                  default      Running 
-evicting pod kube-system/coredns-565d847f94-rh7vb +3)   myapp-deployment-57c6cb89d9-q7d4p                  default      Running 
-evicting pod kube-system/calico-kube-controllers-6799f5f4b4-6ng7z +4)   calico-kube-controllers-6766647d54-v4hrm           kube-system  Running 
-pod/calico-kube-controllers-6799f5f4b4-6ng7z evicted +5)   calico-node-5mrjl                                  kube-system  Running 
-pod/coredns-565d847f94-rh7vb evicted +6)   calico-node-688lw                                  kube-system  Running 
-node/kubenode1.ittraining.loc drained+7)   calico-node-j25xd                                  kube-system  Running 
 +8)   coredns-6d4b75cb6d-dw4ph                           kube-system  Running 
 +9)   coredns-6d4b75cb6d-ms2jm                           kube-system  Running 
 +10)  etcd-kubemaster.ittraining.loc                     kube-system  Running 
 +11)  kube-apiserver-kubemaster.ittraining.loc           kube-system  Running 
 +12)  kube-controller-manager-kubemaster.ittraining.loc  kube-system  Running 
 +13)  kube-proxy-bwctz                                   kube-system  Running 
 +14)  kube-proxy-j89vg                                   kube-system  Running 
 +15)  kube-proxy-jx76x                                   kube-system  Running 
 +16)  kube-scheduler-kubemaster.ittraining.loc           kube-system  Running 
 +17)  metrics-server-7cb867d5dc-g55k5                    kube-system  Running 
 +Select a Pod:
 </code> </code>
  
-Conectez-vous à kubenode1 :+Choisissez le pod **17**. Vous verrez la sortie de la commande logs :
  
 <code> <code>
-root@kubemaster:~# ssh -l trainee kubenode1 +Select a Pod17 
-trainee@kubenode1's passwordtrainee +I0713 03:28:27.452157       serving.go:325] Generated self-signed cert (/tmp/apiserver.crt, /tmp/apiserver.key
-Linux kubenode1.ittraining.loc 4.9.0-19-amd64 #SMP Debian 4.9.320-(2022-06-30x86_64 +I0713 03:28:28.433807       1 secure_serving.go:197] Serving securely on [::]:4443 
- +I0713 03:28:28.433876       1 requestheader_controller.go:169] Starting RequestHeaderAuthRequestController 
-The programs included with the Debian GNU/Linux system are free software; +I0713 03:28:28.433901       1 shared_informer.go:240] Waiting for caches to sync for RequestHeaderAuthRequestController 
-the exact distribution terms for each program are described in the +I0713 03:28:28.433938       1 dynamic_serving_content.go:130] Starting serving-cert::/tmp/apiserver.crt::/tmp/apiserver.key 
-individual files in /usr/share/doc/*/copyright+I0713 03:28:28.433984       1 tlsconfig.go:240] Starting DynamicServingCertificateController 
- +I0713 03:28:28.435681       1 configmap_cafile_content.go:202] Starting client-ca::kube-system::extension-apiserver-authentication::client-ca-file 
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent +I0713 03:28:28.435702       1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::client-ca-file 
-permitted by applicable law+I0713 03:28:28.435727       1 configmap_cafile_content.go:202] Starting client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file 
-Last loginSun Sep  4 09:40:17 2022 from 192.168.56.2 +I0713 03:28:28.435735       1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file 
-trainee@kubenode1:~$ su - +I0713 03:28:28.534094       1 shared_informer.go:247] Caches are synced for RequestHeaderAuthRequestController 
-Mot de passe fenestros +I0713 03:28:28.535893       1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file 
-root@kubenode1:~#+I0713 03:28:28.535937       1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::client-ca-file
 </code> </code>
  
-Mettez-à-jour le paquet **kubeadm** :+Pour lister les plugins installés, utilisez la commande **list** :
  
 <code> <code>
-root@kubenode1:~# apt-get update && apt-get install -y --allow-change-held-packages kubeadm=1.25.0-00 +root@kubemaster:~# kubectl krew list 
-...+PLUGIN            VERSION 
 +ctx               v0.9.4 
 +krew              v0.4.3 
 +ns                v0.9.4 
 +pod-logs          v1.0.1 
 +view-allocations  v0.14.8
 </code> </code>
  
-Mettez-jour la configuration de kubelet :+====2.4 Mise à jour et suppression de plugins====
  
-<code> +Pour mettre à jour les plugins installés, utilisez la commande **upgrade** :
-root@kubenode1:~# kubeadm upgrade node +
-[upgrade] Reading configuration from the cluster... +
-[upgrade] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' +
-[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 "/var/lib/kubelet/config.yaml" +
-[upgrade] The configuration for this node was successfully updated! +
-[upgrade] Now you should go ahead and upgrade the kubelet package using your package manager. +
-</code> +
- +
-Mettez-à-jour maintenant **kubelet** et **kubectl** :+
  
 <code> <code>
-root@kubenode1:~# apt-get update && apt-get install -y --allow-change-held-packages kubelet=1.25.0-00 kubectl=1.25.0-00 +root@kubemaster:~# kubectl krew upgrade 
-...+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, it is already on the newest version
 </code> </code>
  
-Au cas où le fichier du service de kubelet a subi des modificationsre-démarrez le daemon systemctl ainsi que le service kubelet :+Pour supprimer un pluginutilisez la commande **remove** :
  
 <code> <code>
-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            VERSION 
 +ctx               v0.9.4 
 +krew              v0.4.3 
 +ns                v0.9.4 
 +view-allocations  v0.14.8
 </code> </code>
  
-Retournez à la machine **kubemaster** :+=====LAB #3 - Géstion des patchs avec la Commande kustomize==== 
 + 
 +Commencez par installer l'exécutable **tree** que vous utiliserez ultérieurement pour visualiser l'arborescence des répertoires et des fichiers que vous allez créer :
  
 <code> <code>
-root@kubenode1:~# exit +root@kubemaster:~# apt install tree
-déconnexion +
-trainee@kubenode1:~$ exit +
-déconnexion +
-Connection to kubenode1 closed. +
-root@kubemaster:~#+
 </code> </code>
  
-Annulez le drain de kubenode1 :+Créez ensuite le répertoire **kustomize** contenant le répertoire **base** et placez-vous dans ce dernier :
  
 <code> <code>
-root@kubemaster:~# kubectl uncordon kubenode1.ittraining.loc +root@kubemaster:~# mkdir -p kustomize/base 
-node/kubenode1.ittraining.loc uncordoned+root@kubemaster:~# cd kustomize/base/ 
 +root@kubemaster:~/kustomize/base#
 </code> </code>
  
-Constatez maintenant l'état des noeuds :+Créez le manifest **deployment.yaml** :
  
 <code> <code>
-root@kubemaster:~# kubectl get nodes +root@kubemaster:~/kustomize/basevi deployment.yaml 
-NAME                        STATUS   ROLES           AGE     VERSION +root@kubemaster:~/kustomize/base# cat deployment.yaml 
-kubemaster.ittraining.loc   Ready    control-plane   3h43m   v1.25.0 +apiVersion: apps/v1 
-kubenode1.ittraining.loc    Ready    <none>          3h32m   v1.25.0 +kind: Deployment 
-kubenode2.ittraining.loc    Ready    <none>          3h34m   v1.24.2+metadata: 
 +  name: nginx 
 +  labels: 
 +    app: 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: "kubernetes.io/hostname" 
 +      containers: 
 +      - image: nginx:1.18.0 
 +        imagePullPolicy: IfNotPresent 
 +        name: nginx
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Notez que le Control Plane et kubenode1 sont à la version 1.25.0 tandis que kubenode2 est à la version 1.24.2.+**Important** le contenu de ce fichier crée un **deployment** de 1 **replica** du pod **nginx** à partir de l'image **nginx:1.18.0**.
 </WRAP> </WRAP>
  
-Faites un drain du kubenode2 :+Créez ensuite le manifest **service.yaml** :
  
 <code> <code>
-root@kubemaster:~# kubectl drain kubenode2.ittraining.loc --ignore-daemonsets --force +root@kubemaster:~/kustomize/basevi service.yaml 
-node/kubenode2.ittraining.loc cordoned +root@kubemaster:~/kustomize/base# cat service.yaml 
-Warningignoring DaemonSet-managed Podskube-system/calico-node-qk5kt, kube-system/kube-proxy-ggmt6 +apiVersionv1 
-evicting pod kube-system/coredns-565d847f94-phx7b +kindService 
-evicting pod default/myapp-deployment-689f9d59-5446p +metadata: 
-evicting pod default/myapp-deployment-689f9d59-9pkjz +  name: nginx 
-evicting pod default/myapp-deployment-689f9d59-l7lkd +  labels: 
-evicting pod kube-system/calico-kube-controllers-6799f5f4b4-pg6rm +    app: nginx 
-pod/myapp-deployment-689f9d59-5446p evicted +spec: 
-pod/calico-kube-controllers-6799f5f4b4-pg6rm evicted +  type: ClusterIP 
-pod/myapp-deployment-689f9d59-9pkjz evicted +  ports: 
-pod/myapp-deployment-689f9d59-l7lkd evicted +  port: 80 
-pod/coredns-565d847f94-phx7b evicted +    protocol: TCP 
-node/kubenode2.ittraining.loc drained+    targetPort: 80 
 +  selector: 
 +    app: nginx
 </code> </code>
  
-Connectez-vous à kubenode2 :+<WRAP center round important 60%> 
 +**Important** le contenu de ce fichier crée un **service** de type **ClusterIP** en utilisant le **deployment** précédent. Le Service ClusterIP permet de regrouper les PODs offrant le même service afin de faciliter la communication. 
 +</WRAP>
  
-<code> +Dernièrementcréez le manifest **kustomization.yaml** :
-root@kubemaster:~# ssh -l trainee kubenode2 +
-The authenticity of host 'kubenode2 (192.168.56.4)' can't be established. +
-ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/aJgUc9jg56slNaZQdAUcvBOvE. +
-Are you sure you want to continue connecting (yes/no)? yes +
-Warning: Permanently added 'kubenode2,192.168.56.4' (ECDSA) to the list of known hosts. +
-trainee@kubenode2's password: trainee +
-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 /usr/share/doc/*/copyright. +
- +
-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:~$ su - +
-Mot de passe : fenestros +
-root@kubenode2:~# +
-</code> +
- +
-Mettez-à-jour le paquet **kubeadm** :+
  
 <code> <code>
-root@kubenode2:~# apt-get update && apt-get install -y --allow-change-held-packages kubeadm=1.25.0-00 +root@kubemaster:~/kustomize/basevi kustomization.yaml 
-... +root@kubemaster:~/kustomize/base# cat kustomization.yaml 
-</code>+apiVersion: kustomize.config.k8s.io/v1beta1 
 +kind: Kustomization
  
-Mettez-à-jour la configuration de kubelet :+images: 
 +name: nginx 
 +  newTag1.19.1
  
-<code> +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 'kubectl -n kube-system get cm kubeadm-config -o yaml' +
-[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 "/var/lib/kubelet/config.yaml+
-[upgrade] The configuration for this node was successfully updated! +
-[upgrade] Now you should go ahead and upgrade the kubelet package using your package manager.+
 </code> </code>
  
-Mettez-à-jour maintenant **kubelet** et **kubectl** +<WRAP center round important 60%> 
- +**Important** le contenu de ce fichier contient un **patch** pour l'application **nginx** créée par les deux fichiers précédentNotez le tag **newTag** dans la section **images**Dans la section **resources** se trouve la liste des manifests concernés par le patchNotez que seul le manifest **deployment.yaml** fait référence à une imageCependant, le fichier **service.yaml** est inclus ici car il sera nécessaire par la suite
-<code> +</WRAP>
-root@kubenode2:~# apt-get update && apt-get install -y --allow-change-held-packages kubelet=1.25.0-00 kubectl=1.25.0-00 +
-... +
-</code>+
  
-Au cas où le fichier du service de kubelet a subi des modifications, re-démarrez le daemon systemctl ainsi que le service kubelet :+Consultez donc l'arborescence du répertoire **kustomize** :
  
 <code> <code>
-root@kubenode2:~# systemctl daemon-reload+root@kubemaster:~/kustomize/basecd .. 
 +root@kubemaster:~/kustomize# tree 
 +
 +└── base 
 +    ├── deployment.yaml 
 +    ├── kustomization.yaml 
 +    └── service.yaml
  
-root@kubenode2:~# systemctl restart kubelet+1 directory, 3 files
 </code> </code>
  
-Retournez à la machine **kubemaster** :+Exécutez maintenant la commande **kustomize** pour créer un **patch** pour les fichiers se trouvant dans le répertoire **base** :
  
 <code> <code>
-root@kubenode2:~# exit +root@kubemaster:~/kustomizekubectl kustomize base 
-déconnexion +apiVersion: v1 
-trainee@kubenode2:~$ exit +kindService 
-déconnexion +metadata: 
-Connection to kubenode2 closed+  labels: 
-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: kubernetes.io/hostname 
 +      containers: 
 +      - image: nginx:1.19.1 
 +        imagePullPolicy: IfNotPresent 
 +        name: nginx
 </code> </code>
  
-Annulez le drain de kubenode1 :+<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'image a été modifiée de **imagenginx:1.18.0** vers **image: nginx:1.19.1** dans le contenu du fichier **deployment.yaml**. Notez que les deux fichiers d'origine n'ont **pas** été modifiés. 
 +</WRAP>
  
-<code> +Imaginons maintenant que vous souhaitez déployer deux environnements **différents** de la même application, un pour la production et un pour le développementLa commande **kustomize** permet de faire ceci en utilisant des **overlays**.
-root@kubemaster:~# kubectl uncordon kubenode2.ittraining.loc +
-node/kubenode2.ittraining.loc uncordoned +
-</code>+
  
-Constatez maintenant l'état des noeuds :+Créez les répertoires **kustomize/overlays/development** et **kustomize/overlays/production** :
  
 <code> <code>
-root@kubemaster:~# kubectl get nodes +root@kubemaster:~/kustomizemkdir -p overlays/development 
-NAME                        STATUS   ROLES           AGE     VERSION +root@kubemaster:~/kustomize# mkdir overlays/production
-kubemaster.ittraining.loc   Ready    control-plane   3h56m   v1.25.0 +
-kubenode1.ittraining.loc    Ready    <none>          3h45m   v1.25.0 +
-kubenode2.ittraining.loc    Ready    <none>          3h47m   v1.25.0+
 </code> </code>
  
-<WRAP center round important 60%> +Consultez l'arborescence du répertoire **kustomize** :
-**Important** : Notez que tout a été mis-à-jour. +
-</WRAP>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# tree
 +.
 +├── base
 +│   ├── deployment.yaml
 +│   ├── kustomization.yaml
 +│   └── service.yaml
 +└── overlays
 +    ├── development
 +    └── production
  
 +4 directories, 3 files
 </code> </code>
  
-<code> +Créez le fichier **dev_kustomization.yaml** :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# vi overlays/development/kustomization.yaml
 +root@kubemaster:~/kustomize# cat overlays/development/kustomization.yaml
 +apiVersion: kustomize.config.k8s.io/v1beta1
 +kind: Kustomization
  
-</code>+bases: 
 +- ../../base  # <---------------------indique où sont stockés les manifests principaux
  
-<code>+nameSuffix: -development # <----------met à jour le nom du service/deployment
  
-</code> +commonLabels: 
- +  environment: development # <--------ajoute une étiquette supplémentaire
-<code>+
  
 +namespace: nginx-dev # <--------------indique le nom du namespace
 </code> </code>
 +
 +Appliquez ces modifications :
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl kustomize overlays/development/ 
 +apiVersion: v1 
 +kind: Service 
 +metadata: 
 +  labels: 
 +    app: nginx 
 +    environment: development # <-----------étiquette supplémentaire 
 +  name: nginx-development # <--------------mise à jour du nom du service 
 +  namespace: nginx-dev # <-----------------indique le nom du namespace 
 +spec: 
 +  ports: 
 +  - port: 80 
 +    protocol: TCP 
 +    targetPort: 80 
 +  selector: 
 +    app: nginx 
 +    environment: development # <-----------étiquette supplémentaire 
 +  type: ClusterIP 
 +--- 
 +apiVersion: apps/v1 
 +kind: Deployment 
 +metadata: 
 +  labels: 
 +    app: nginx 
 +    environment: development 
 +  name: nginx-development 
 +  namespace: nginx-dev 
 +spec: 
 +  replicas: 1 
 +  selector: 
 +    matchLabels: 
 +      app: nginx 
 +      environment: development 
 +  template: 
 +    metadata: 
 +      labels: 
 +        app: nginx 
 +        environment: development 
 +    spec: 
 +      affinity: 
 +        podAntiAffinity: 
 +          requiredDuringSchedulingIgnoredDuringExecution: 
 +          - labelSelector: 
 +              matchExpressions: 
 +              - key: app 
 +                operator: In 
 +                values: 
 +                - nginx 
 +            topologyKey: kubernetes.io/hostname 
 +      containers: 
 +      - image: nginx:1.19.1 # <-------------utilise l'image spécifiée dans le fichier /kustomize/base/kustomization.yaml 
 +        imagePullPolicy: IfNotPresent 
 +        name: nginx
 </code> </code>
  
-<code> +Maintenant créez le fichier **prod_kustomization.yaml** :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# vi overlays/production/kustomization.yaml
 +root@kubemaster:~/kustomize# cat overlays/production/kustomization.yaml
 +apiVersion: kustomize.config.k8s.io/v1beta1
 +kind: Kustomization
  
-</code>+bases: 
 +- ../../base # <---------------------indique où sont stockés les manifests principaux
  
-<code>+nameSuffix: -production # <----------met à jour le nom du service/deployment
  
-</code>+commonLabels: 
 +  environment: production # <--------ajoute une étiquette supplémentaire
  
-<code>+namespace: nginx-prod # <------------indique le nom du namespace
  
 +images:
 +- name: nginx
 +  newTag: 1.19.2 # <-----------------modifie l'image spécifiée dans le fichier /kustomize/base/kustomization.yaml
 </code> </code>
  
-<code> +Appliquez ces modifications :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl kustomize overlays/production/ 
 +apiVersion: v1 
 +kind: Service 
 +metadata: 
 +  labels: 
 +    app: nginx 
 +    environment: production # <-----------étiquette supplémentaire 
 +  name: nginx-production # <--------------mise à jour du nom du service 
 +  namespace: nginx-prod # <---------------indique le nom du namespace 
 +spec: 
 +  ports: 
 +  - port: 80 
 +    protocol: TCP 
 +    targetPort: 80 
 +  selector: 
 +    app: nginx 
 +    environment: production # <-----------étiquette supplémentaire 
 +  type: ClusterIP 
 +--- 
 +apiVersion: apps/v1 
 +kind: Deployment 
 +metadata: 
 +  labels: 
 +    app: nginx 
 +    environment: production 
 +  name: nginx-production 
 +  namespace: nginx-prod 
 +spec: 
 +  replicas: 1 
 +  selector: 
 +    matchLabels: 
 +      app: nginx 
 +      environment: production 
 +  template: 
 +    metadata: 
 +      labels: 
 +        app: nginx 
 +        environment: production 
 +    spec: 
 +      affinity: 
 +        podAntiAffinity: 
 +          requiredDuringSchedulingIgnoredDuringExecution: 
 +          - labelSelector: 
 +              matchExpressions: 
 +              - key: app 
 +                operator: In 
 +                values: 
 +                - nginx 
 +            topologyKey: kubernetes.io/hostname 
 +      containers: 
 +      - image: nginx:1.19.2 # <-------------utilise l'image spécifiée dans le fichier overlays/production/kustomization.yaml 
 +        imagePullPolicy: IfNotPresent 
 +        name: nginx
 </code> </code>
  
-<code> +Créez maintenant le namespace **nginx-prod** :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl create ns nginx-prod 
 +namespace/nginx-prod created
 </code> </code>
  
-<code> +Installez l'application **production** :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl apply -k overlays/production/ 
 +service/nginx-production created 
 +deployment.apps/nginx-production created
 </code> </code>
  
-<code> +Constatez le résultat de l'installation :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl get pods -n nginx-prod
 +NAME                                READY   STATUS    RESTARTS   AGE
 +nginx-production-75d9486bb9-7xpr6   1/    Running            45s
  
-</code> +root@kubemaster:~/kustomize# kubectl get deployments -n nginx-prod 
- +NAME               READY   UP-TO-DATE   AVAILABLE   AGE 
-<code>+nginx-production   1/               1           62s
  
 +root@kubemaster:~/kustomize# kubectl get services -n nginx-prod
 +NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
 +nginx-production   ClusterIP   10.97.147.125   <none>        80/TCP    79s
 </code> </code>
  
-<code> +Supprimez le deployment et le service nginx-production :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl delete deployments/nginx-production -n nginx-prod
 +deployment.apps "nginx-production" deleted
  
-</code>+root@kubemaster:~/kustomize# kubectl get deployments -n nginx-prod 
 +No resources found in nginx-prod namespace.
  
-<code>+root@kubemaster:~/kustomize# kubectl get services -n nginx-prod 
 +NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE 
 +nginx-production   ClusterIP   10.97.147.125   <none       80/TCP    2m54s
  
-</code>+root@kubemaster:~/kustomize# kubectl get pods -n nginx-prod 
 +No resources found in nginx-prod namespace.
  
-<code>+root@kubemaster:~/kustomize# kubectl delete services/nginx-production -n nginx-prod 
 +service "nginx-production" deleted
  
 +root@kubemaster:~/kustomize# kubectl get services -n nginx-prod
 +No resources found in nginx-prod namespace.
 </code> </code>
  
-<code> +Installez l'application **development** :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl create ns nginx-dev 
 +namespace/nginx-dev created 
 +root@kubemaster:~/kustomize# kubectl apply -k overlays/development/ 
 +service/nginx-development created 
 +deployment.apps/nginx-development created
 </code> </code>
  
-<code> +Constatez le résultat :
- +
-</code>+
  
 <code> <code>
 +root@kubemaster:~/kustomize# kubectl get pods -n nginx-dev
 +NAME                                 READY   STATUS    RESTARTS   AGE
 +nginx-development-5f8d7bdd88-fsnc6   1/    Running            37s
  
-</code> +root@kubemaster:~/kustomize# kubectl get deployments -n nginx-dev 
- +NAME                READY   UP-TO-DATE   AVAILABLE   AGE 
-<code>+nginx-development   1/               1           58s
  
 +root@kubemaster:~/kustomize# kubectl get services -n nginx-dev
 +NAME                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
 +nginx-development   ClusterIP   10.98.227.222   <none>        80/TCP    70s
 </code> </code>
  
 ---- ----
-Copyright © 2022 Hugh Norris+Copyright © 2024 Hugh Norris 
Menu