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:k8s10 [2022/12/12 06:33] adminelearning:workbooks:kubernetes:k8s10 [2024/12/15 07:21] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version **2022.02**+Version **2024.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======DOF311 - Kubernetes Avancé======+======DOF311 - Validation de la Formation======
  
-=====Contenu du Module=====+=====Rappel de l'Infrastructure Utilisée=====
  
-  * **DOF311 - Kubernetes Avancé** +^  VM  ^  FQDN  ^  IP  ^  OS  ^  Version  ^  vCPUs  ^  RAM (Mo)  ^  HDD (Go)  ^  User  ^  MdP  ^  MdP root  ^ 
-    * Contenu du Module+| Gateway_10.0.2.40 | gateway.ittraining.loc | 10.0.2.40 |  Debian  |  11.8  |  4  |  4096  |  32 / 4 / 64  |  trainee  |  trainee  |  fenestros 
 +| CentOS_10.0.2.45 | centos8.ittraining.loc | 10.0.2.45 |  CentOS  |  8.5.2111  |  4  |  4096  |  500 / 4 / 64 / 32 |  trainee  |  trainee  |  fenestros 
 +| Kubemaster_10.0.2.65 | kubemaster.ittraining.loc | 192.168.56.2 |  Debian  |  9.13  |  4  |  4096  |  20  |  trainee  |  trainee  |  fenestros 
 +| Kubenode01_10.0.2.66 | kubenode01.ittraining.loc | 192.168.56.3 |  Debian  |  9.13  |  4  |  4096  |  20  |  trainee  |  trainee  |  fenestros 
 +| Kubenode02_10.0.2.67 | kubenode02.ittraining.loc | 192.168.56.4 |  Debian  |  9.13  |  4  |  4096  |  20  |  trainee  |  trainee  |  fenestros 
 + 
 +Dans votre VirtualBox vous **devez** créer un **Réseau privé hôte** dénommé **vboxnet0** ayant l'adresse **192.168.56.1/24**. 
 + 
 +Les VMs **[[https://www.virtualbox.org/wiki/Downloads|VirtualBox]]** pré-configurées peuvent être téléchargées gratuitement ici : 
 + 
 +  * **[[https://www.dropbox.com/scl/fi/ddmhonaiwqy1ncw19zxpi/Gateway_10.0.2.40.ova?rlkey=rxtx52xu2mx49n9oo374i7bd5|Gateway_10.0.2.40]]**, 
 +  * **[[https://www.dropbox.com/scl/fi/fy2s50mx1nxucgbq9p90m/CentOS_10.0.2.45.ova?rlkey=y7q2gxszo6m14m47wfugvwe2f|CentOS_10.0.2.45]]**, 
 +  * **[[https://www.dropbox.com/scl/fi/c0paazsdtmyp83jh8zfuw/Kubemaster_10.0.2.65.ova?rlkey=vyc0mk4hgrwfzjn1gcvxqivxf|Kubemaster_10.0.2.65]]**, 
 +  * **[[https://www.dropbox.com/scl/fi/s5t95lzt0vbj45olfwzpr/Kubenode01_10.0.2.66.ova?rlkey=58n7yl8mb5gi1s3u3g9zp8b8s|Kubenode01_10.0.2.66]]**, 
 +  * **[[https://www.dropbox.com/scl/fi/3juqu67ozwztgzigpou4d/Kubenode02_10.0.2.67.ova?rlkey=fi3wz1vbqlajxlz0s4ng6tytv|Kubenode02_10.0.2.67]]**. 
 + 
 +=====Rappel du Contenu de la Formation===== 
 + 
 +  * **DOF301 - Création de Clusters Kubernetes** 
 +    * L'Orchestration de Conteneurs 
 +    * Présentation de Kubernetes (k8s) 
 +      * Master 
 +      * Nœuds (Minions) 
 +    * LAB #1 - Création du Cluster Kubernetes avec des Machines Virtuelles 
 +      * 1.1 - Présentation 
 +      * 1.2 - Connexion à la Machine Virtuelle kubemaster 
 +      * 1.3 - Tester le Réseau 
 +      * 1.4 - Initialisation du Maître du Cluster 
 +      * 1.5 - Installation d'une Extension Réseau pour la Communication entre des PODs 
 +      * 1.6 - Connexion des Travailleurs au Maître  
 +      * 1.7 - K8s et la Haute Disponibilité 
 +    * LAB #2 - Création du Cluster Kubernetes avec Minikube 
 +      * 2.1 - Présentation de Minikube 
 +      * 2.2 - Installation de Minikube 
 +      * 2.3 - Configuration de Minikube 
 +      * 2.4 - Installation de Docker 
 +      * 2.5 - Installation de kubectl 
 +      * 2.6 - La Commande minikube addons 
 +      * 2.7 - La Commande minikube dashboard 
 + 
 +  * **DOF302 - Gestion des PODs, Contrôleurs de Réplication, ReplicaSets, Deployments, de la Maintenance et des Mises-à-jour du Cluster** 
 +    * LAB #1 - Création d'un POD 
 +      * 1.1 - Présentation d'un POD 
 +      * 1.2 - Création Manuelle d'un POD 
 +      * 1.3 - Création d'un POD à l'aide d'un fichier YAML 
 +        * apiVersion 
 +        * kind 
 +        * metadata 
 +        * spec 
 +        * Utilisation du Fichier YAML 
 +    * LAB #2 - Utilisation de Contrôleurs de Réplication et ReplicaSets 
 +      * 2.1 - Contrôleurs de Réplication 
 +        * Présentation d'un Contrôleur de Réplication 
 +        * Mise en Application 
 +      * 2.2 - ReplicaSets 
 +        * Présentation d'un ReplicaSet 
 +        * Mise en Application 
 +    * LAB #3 - Gestion des Deployments 
 +      * 3.1 - Présentation d'un Deployment 
 +      * 3.2 - Mise en Application 
 +        * Rollouts 
 +        * Rolling Updates 
 +        * Rollbacks 
 +    * LAB #4 - Gestion de la Maintenance 
 +      * 4.1 - La Commande drain 
 +      * 4.2 - La Commande uncordon 
 +    * LAB #5 - Gestion des Mises-à-jour 
 +      * 5.1 - Mise-à-jour de kubeadm 
 +      * 5.2 - Mise-à-jour des Travailleurs 
 + 
 +  * **DOF303 - Les Commandes kubectl, krew et kustomize** 
 +    * LAB #1 - Utilisation de la Commande kubectl 
 +      * 1.1 - Obtenir de l'Aide sur les Commandes de kubectl 
 +      * 1.2 - Obtenir de l'Information sur le Cluster 
 +        * La Commande version 
 +        * La Commande cluster-info 
 +        * La Commande api-versions 
 +        * La Commande api-resources 
 +      * 1.3 - Obtenir de l'Information sur les Nœuds 
 +        * La Commande describe node 
 +        * La Commande top 
 +      * 1.4 - Obtenir de l'Information sur les Pods 
 +        * La Commande describe pod 
 +        * La Commande top 
 +      * 1.5 - Travailler avec la commande kubectl 
 +        * La Commande apply 
 +        * La Commande create 
 +        * La Commande get 
 +        * Utilisation des Options 
 +        * La Commande exec 
 +        * Commandes Impératives 
 +    * LAB #2 - Gestion les plugins de kubectl avec la Commande krew 
 +      * 2.1 - Installation de krew 
 +      * 2.2 - Consultation de la liste des plugins 
 +      * 2.3 - Installation et utilisation de plugins 
 +      * 2.4 - Mise à jour et suppression de plugins 
 +    * LAB #3 - Gestion des patchs avec la Commande kustomize 
 + 
 +   * **DOF304 - Travailler avec des Pods et des Conteneurs** 
 +      * LAB #1 - Application Configuration 
 +        * 1.1 - Présentation 
 +        * 1.2 - Création d'une ConfigMap 
 +        * 1.3 - Création d'un Secret 
 +        * 1.4 - Utilisation de ConfigMaps et de Secrets 
 +          * Utilisation de Variables d'environnement 
 +          * Utilisation de Volumes de Configuration 
 +      * LAB #2 - Gestion des Ressources des Conteneurs 
 +        * 2.1 - Présentation 
 +        * 2.2 - Resource Requests 
 +        * 2.3 - Resource Limits 
 +      * LAB #3 - Supervision des Conteneurs 
 +        * 3.1 - Présentation 
 +        * 3.2 - Liveness Probes 
 +          * Le Probe exec 
 +          * Le Probe httpGet 
 +        * 3.3 - Startup Probes 
 +        * 3.4 - Readiness Probes 
 +      * LAB #4 - Gestion des Politiques de Redémarrage 
 +        * 4.1 - Présentation 
 +        * 4.2 - Always 
 +        * 4.3 - OnFailure 
 +        * 4.4 - Never 
 +      * LAB #5 - Création de Pods Multi-conteneurs 
 +        * 5.1 - Présentation 
 +        * 5.2 - Mise en Place 
 +      * LAB #6 - Conteneurs Init 
 +        * 6.1 - Présentation 
 +        * 6.2 - Mise en Place 
 +      * LAB #7 - Scheduling 
 +        * 7.1 - Présentation 
 +        * 7.2 - Mise en Place 
 +      * LAB #8 - DaemonSets 
 +        * 8.1 - Présentation 
 +        * 8.2 - Mise en Place 
 +      * LAB #9 - Pods Statiques 
 +        * 9.1 - Présentation 
 +        * 9.2 - Mise en Place 
 + 
 +  * **DOF305 - Gestion du Réseau, des Services et d'une Architecture de Microservices** 
 +    * LAB #1 - Gestion du Réseau et des Services 
 +      * 1.1 - Présentation des Extensions Réseau 
 +      * 1.2 - DNS K8s 
 +        * Présentation 
 +        * Mise en Application 
 +      * 1.3 - Network Policies 
 +        * Présentation 
 +        * Mise en Application 
 +      * 1.4 - Services 
 +        * Le Service NodePort 
 +          * Présentation 
 +          * Mise en Application 
 +        * Le Service ClusterIP 
 +          * Présentation 
 +          * Mise en Application 
 +      * 1.5 - Services et le DNS k8s  
 +        * Présentation 
 +        * Mise en Application 
 +      * 1.6 - Gestion de K8s Ingress 
 +        * Présentation 
 +        * Mise en Application 
 +    * LAB #2 - Gestion de l'Architecture des Microservices 
 +      * 2.1 - Présentation 
 +      * 2.2 - Création des Deployments 
 +      * 2.3 - Création des Services 
 +      * 2.4 - Déployer l'Application 
 +      * 2.5 - Scaling Up 
 + 
 +  * **DOF306 - Gestion des Volumes sous K8s** 
 +    * Présentation 
 +      * Volumes 
 +      * Persistent Volumes 
 +      * Types de Volumes 
 +    * LAB #1 - Utiliser des Volumes K8s 
 +      * 1.1 - Volumes et volumeMounts 
 +      * 1.2 - Partager des volumes entre conteneurs 
 +    * LAB #2 - Volumes Persistants 
 +      * 2.1 - Storage Classes 
 +      * 2.2 - Persistent Volumes 
 +      * 2.3 - Persistent Volume Claims 
 +      * 2.4 - Utiliser un PersistentVolumeClaim dans un pod 
 +      * 2.5 - Redimensionnement d'un PersistentVolumeClaim 
 + 
 +  * **DOF307 - Troubleshooting K8s** 
 +    * LAB #1 - Le Serveur API 
 +      * 1.1 - Connexion Refusée 
 +      * 1.2 - Journaux des Pods Système 
 +    * LAB #2 - Les Noeuds 
 +      * 2.1 - Le Statut NotReady 
 +    * LAB #3 - Les Pods 
 +      * 3.1 - L'Erreur ImagePullBackOff 
 +      * 3.2 - L'Erreur CrashLoopBackOff 
 +    * LAB #4 - Les Conteneurs 
 +      * 4.1 - La Commande exec 
 +    * LAB #5 - Le Réseau 
 +      * 5.1 - kube-proxy et le DNS 
 +      * 5.2 - Le Conteneur netshoot 
 + 
 +  * **DOF308 - Introduction à la Sécurisation de K8s** 
 +    * LAB #1 - Role Based Acces Control et Certificats TLS 
 +      * 1.1 - Présentation 
 +      * 1.2 - Le Fichier /etc/kubernetes/manifests/kube-apiserver.yaml 
 +      * 1.3 - Création d'un serviceAccount 
 +      * 1.4 - Création d'un Utilisateur 
 +      * 1.5 - Certificats TLS 
 +    * LAB #2 - Implémentation de la Sécurité au niveau des Pods 
 +      * 2.1 - Présentation 
 +      * 2.2 - Kubernetes Security Context 
 +        * ReadOnlyRootFilesystem 
 +        * drop 
 +      * 2.3 - K8s Network Policies 
 +      * 2.4 - K8s Resource Allocation Management 
 + 
 +  * **DOF309 - Gestion de Paquets pour K8s avec Helm** 
 +    * Présentation de Helm 
 +    * LAB #1 - Travailler avec Helm 
 +      * 1.1 - Installation de Helm 
 +      * 1.2 - La Commande helm search hub 
 +      * 1.3 - Rechercher dans le Helm Hub 
 +      * 1.4 - Ajouter et supprimer un Dépôt 
 +      * 1.5 - La Commande helm search repo 
 +      * 1.6 - La Commande helm show 
 +      * 1.7 - Installation d'un Chart 
 +      * 1.8 - La Commande helm get 
 +      * 1.9 - Utilisation des NOTES 
 +      * 1.10 - La Commande helm upgrade 
 +      * 1.11 - La Commande helm history 
 +      * 1.12 - La Commande helm rollback 
 +      * 1.13 - La Commande helm uninstall 
 +    * LAB #2 - Supervision de K8s avec le Stack EFK 
 +      * 2.1 - Présentation du Stack EFK 
 +      * 2.2 - Installation du Chart elasticsearch 
 +      * 2.3 - Installation du Chart fluentd-elasticsearch 
 +      * 2.4 - Installation du Chart kibana 
 +      * 2.5 - Génération de Traces dans K8s 
 +      * 2.6 - Visualisation des Données avec Kibana 
 + 
 +  * **DOF310 - StatefulSets, StorageClass Avancé, Helm Avancé et Monitoring**
     * StatefulSets     * StatefulSets
       * LAB #1 - Mise en Place d'un StatefulSet Simple       * LAB #1 - Mise en Place d'un StatefulSet Simple
Ligne 36: Ligne 272:
         * 4.2 - Consultation des Données avec Grafana         * 4.2 - Consultation des Données avec Grafana
         * 4.3 - Consultation des Alertes avec le Web UI de Prometheus          * 4.3 - Consultation des Alertes avec le Web UI de Prometheus 
-    * Harbor 
-      * LAB #5 - Installation et Configuration de Harbor 
-        * 5.1 - Installation de Docker et de Docker Compose 
-        * 5.2 - Installation de Harbor 
-        * 5.3 - Création d'un Nouveau Projet 
-        * 5.4 - Création d'un Dépôt 
-        * 5.5 - Pousser des Images Supplémentaires 
-        * 5.6 - Travailler avec des Artefacts 
-        * 5.7 - Copier un Artefact d'un Projet vers un autre Projet 
-        * 5.8 - Utilisation de Labels 
-        * 5.9 - Authentification et RBAC 
-        * 5.10 - Utilisation d'Images Docker Personalisées 
-        * 5.11 - Rétention de Tags 
-        * 5.12 - Immutabilité des Tags 
  
-=====StatefulSets=====+  * **DOF311 - Validation des Acquis** 
 +    * 60 questions issues d'un pool de 104 questions
  
-Un StatefulSet est un composant de Kubernetes qui est utilisé pour des applications avec état (//Stateful Applications//).+=====Évaluation de la Formation et la Validation des Acquis=====
  
-Des exemples d'applications avec état sont : +Afin de valider votre formationveuillez compléter l’Évaluation de la Formation ainsi que la Validation des Acquis.
- +
-  * MySQL +
-  * elasticsearch +
-  * mongoDB +
- +
-Ces applications enregistrent les données client des activités d'une session pour les utiliser lors de la session suivante. Les données enregistrées sont appelées l'état de l'application. +
- +
-Les applications avec état sont déployées en utilisant un StatefulSet tandis que des applications **sans** état sont déployées en utilisant un **Deployment**. +
- +
-Les StatefulSets et les Deployments sont similaires dans la mesure où les deux répliquent de multiples pods basés sur une spécification **identique** d'un conteneur. +
- +
-La différence entre un StatefulSet et un Deployment est que dans un StatefulSet les pods ne sont **pas** identiques et possèdent ce que l'on appelle un **Pod Identity**. De ce fait les pods : +
- +
-  * ne peuvent pas être créés ou supprimés en même temps, +
-  * ne peuvent pas être adressés d'une manière aléatoire. +
- +
-Prenons le cas d'un StatfulSet contenant trois répliques d'un pod MySQL : +
- +
-  * mysql-0 +
-  * mysql-1 +
-  * mysql-2 +
- +
-Notez que : +
- +
-  * le nom du pod prend la forme **$(Nom_du_StatefulSet)-$(ordinal)** où l'ordinal commence à **0** +
-  * le StatefulSet ne créera pas le pod suivant tant que le pod précédent n'est pas dans un état de **Running** +
-  * dans le cas de la suppression du StatefulSet ou bien dans le cas d'un **scale down**, les pods sont supprimés dans l'ordre inverse de leur création, par exemple **mysql-2 > mysql-1 > mysql-0**. Chaque pod doit être complètement supprimé avant que K8s procède à la suppression du suivant +
- +
-Dans ce cas de notre StatefulSet, les trois pods : +
- +
-  * ne peuvent pas tous accepter des requêtes d'écriture car ceci donnerait des données incohérentes, +
-  * peuvent tous accepter des requêtes de lecture. +
- +
-De ce fait, un mécanisme du StatefulSet choisit un **maître** pour accepter des requêtes d'écriture, par exemple : +
- +
-  * mysql-0 - écriture / lecture - **Maître** +
-  * mysql-1 - lecture seulement - **Esclave** +
-  * mysql-2 - lecture seulement - **Esclave** +
- +
-Il existe donc une différence précise entre le pod Maître et les deux pods Esclaves. +
- +
-La différence entre les deux pods Esclaves s'expliquent par le fait que les pods n'utilisent **pas** le même stockage physique persistant et distant : +
- +
-  * mysql-0 - **/data/vol/pv1** +
-  * mysql-1 - **/data/vol/pv2** +
-  * mysql-2 - **/data/vol/pv3** +
- +
-De façon à ce que chaque pod contient les mêmes données, un mecanisme de réplication en continu doit être mis en place entre les deux pods Esclaves et le pod Maître. +
- +
-Dans le cas où un nouveau pod est ajouté au **cluster** MySQL, celui-ci doit commencer par cloner les données du dernier pod dans le cluster existant, puis il doit commencer la réplication des données avec le Maître : +
- +
-  * mysql-0 - données +
-  * mysql-1 - données répliquées de mysql-0 +
-  * mysql-2 - données répliquées de mysql-0 +
-  * mysql-3 - clone des données du pod mysql-2 puis, par la suite, données répliquées de mysql-0  +
- +
-L'état de chaque pod, incluant sa Pod Identity, est stocké dans le stockage physique à côté des données. De ce fait, quand un pod est remplacé, et un nouveau pod ajouté, ce pod nouveau hérite de l'identité de l'ancien pod. +
- +
-Par exemple, si on supprime le pod **mysql-1**, on obtient :  +
- +
-  * mysql-0 - /data/vol/pv1 +
-  * pod supprimé - /data/vol/pv2 = stockage physique persistant et distant **non-supprimé** +
-  * mysql-2 - /data/vol/pv3 +
-  * mysql-3 - /data/vol/pv4 +
- +
-En ajoutant un pod de remplaceement, on obtient : +
- +
-  * mysql-0 +
-  * mysql-1 <<<<<<<<<< Le /data/vol/pv2 est rattaché au pod. Le nouveau pod s'appelle **mysql-1** et non **mysql-4**.  +
-  * mysql-2 +
-  * mysql-3 +
- +
-Lors de la création d'un ReplicaSet, un service d'équilibrage de charge est créé. Ce service attribue un **Endpoint DNS** unique à chaque pod. L'Endpoint DNS prend la forme **$(Nom_du_pod).$(Nom_du_service).$(namespace).svc.cluster.local +
-** : +
- +
-  * mysql-0 - **mysql-0.mysvc.default.svc.cluster.local** +
-  * mysql-1 - **mysql-1.mysvc.default.svc.cluster.local** +
-  * mysql-2 - **mysql-2.mysvc.default.svc.cluster.local** +
-  * mysql-3 - **mysql-3.mysvc.default.svc.cluster.local** +
- +
-De cette façon, quand un pod est redémarré bien que son adresse IP changera : +
- +
-  * son nom ne changera **pas** +
-  * son Endpoint DNS ne changera **pas** +
- +
-Pour résumer : +
- +
-  * mysql-0 +
-    * Rôle : **Maître** +
-    * Données : écriture / lecture +
-    * Stockage : /data/vol/pv1 +
-    * Endpoint DNS : mysql-0..mysvc.default.svc.cluster.local +
-  * mysql-1 +
-    * Rôle : **Esclave** +
-    * Données : lecture seulement +
-    * Stockage : /data/vol/pv2 +
-    * Endpoint DNS : mysql-1.mysvc.default.svc.cluster.local +
-  * mysql-2 +
-    * Rôle : **Esclave** +
-    * Données : lecture seulement +
-    * Stockage : /data/vol/pv3 +
-    * Endpoint DNS : mysql-2.mysvc.default.svc.cluster.local +
-  * mysql-3 +
-    * Rôle : **Esclave** +
-    * Données : lecture seulement +
-    * Stockage : /data/vol/pv4 +
-    * Endpoint DNS : mysql-3.mysvc.default.svc.cluster.local +
- +
-Dernièrement, un StatefulSet est un composant K8s **compliqué** et difficile à mettre en oeuvre car Kubernetes ne s'occupe pas de certaines tâches telles : +
- +
-  * la configuration du clonage des données +
-  * la configuration de la réplication des données +
-  * la création et la configuration du stockage physique persistant et distant +
-  * la configuration et la gestion des sauvegardes des données +
- +
-====LAB #1 - Mise en Place d'un StatefulSet Simple==== +
- +
-Créez un Namespace **quarkus** puis modifiez le **context** de **kubernetes-admin@kubernetes** : +
- +
-<code> +
-root@kubemaster:~# kubectl create ns quarkus +
-namespace/quarkus created +
- +
-root@kubemaster:~# kubectl config set-context --current --namespace=quarkus +
-Context "kubernetes-admin@kubernetes" modified. +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Quarkus est un framework Java natif pour Kubernetes complet, conçu pour les machines virtuelles Java (JVM) et la compilation native, qui permet d'optimiser Java spécifiquement pour les conteneurs afin d'en faire une plateforme efficace pour les environnements serverless, cloud et Kubernetes. +
-</WRAP> +
- +
-Si vous souhaitez observer les résultats des commandes suivantes en temps réel, ouvrez un deuxième terminal et saisissez la commande suivante : +
- +
-<code> +
-root@kubemaster:~# watch -n 1 "kubectl get pods -o wide | awk '{print \$1 \" \" \$2 \" \" \$3 \" \" \$5 \" \" \$7}' | column -t" +
-</code> +
- +
-===1.1 - Création du Service et du StatefulSet=== +
- +
-Créez maintenant le fichier **quarkus-service.yaml** : +
- +
-<code> +
-root@kubemaster:~# vi quarkus-service.yaml +
-root@kubemaster:~# cat quarkus-service.yaml +
-apiVersion: v1 +
-kind: Service +
-metadata: +
-  name: quarkus  +
-  labels: +
-    app: quarkus-statefulset +
-spec: +
-  ports: +
-  - port: 8080 +
-    name: web +
-  clusterIP: None  +
-  selector: +
-    app: quarkus-statefulset +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez le nom du service - **quarkus**. La valeur **None** de l'entrée **ClusterIP** rend le service **headless**. Dans ce cas, le serveur DNS renverra les adresses IP des pods individuels au lieu de l'adresse IP du service. Le client peut alors se connecter à n'importe lequel d'entre eux. +
-</WRAP> +
- +
-Créez le service : +
- +
-<code> +
-root@kubemaster:~# kubectl apply -f quarkus-service.yaml +
-service/quarkus created +
-</code> +
- +
-Créez maintenant le fichier **statefulset.yaml** : +
- +
-<code> +
-root@kubemaster:~# vi statefulset.yaml +
-root@kubemaster:~# cat statefulset.yaml  +
-apiVersion: apps/v1 +
-kind: StatefulSet +
-metadata: +
-  name: quarkus-statefulset +
-  labels: +
-    app: quarkus-statefulset +
-spec: +
-  serviceName: "quarkus"  +
-  replicas: 2 +
-  template: +
-    metadata: +
-      labels: +
-        app: quarkus-statefulset +
-    spec: +
-      containers: +
-      - name: quarkus-statefulset +
-        image: quay.io/rhdevelopers/quarkus-demo:v1 +
-        ports: +
-        - containerPort: 8080 +
-          name: web +
-  selector: +
-    matchLabels: +
-      app: quarkus-statefulset +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que la valeur de **serviceName** est **quarkus**. +
-</WRAP> +
- +
-Créez le StatefulSet : +
- +
-<code> +
-root@kubemaster:~# kubectl apply -f statefulset.yaml +
-statefulset.apps/quarkus-statefulset created +
-</code> +
- +
-Constatez la présence des deux pods dans le Namespace : +
- +
-<code> +
-Every 1,0s: kubectl get pods -o wide | awk '{print $1 " " $2 " " $3 " " $5 " " $7}' | column -t                                                                kubemaster.ittraining.loc: Tue Dec  6 17:43:50 2022 +
- +
-NAME                   READY  STATUS   AGE    NODE +
-quarkus-statefulset-0  1/1    Running  2m17s  kubenode2.ittraining.loc +
-quarkus-statefulset-1  1/1    Running  106s   kubenode1.ittraining.loc +
-</code> +
- +
-Contrôlez l'état du StatefulSet : +
- +
-<code> +
-root@kubemaster:~# kubectl get statefulsets +
-NAME                  READY   AGE +
-quarkus-statefulset   2/    3m35s +
-</code> +
- +
-ainsi que la présence du service : +
- +
-<code> +
-root@kubemaster:~# kubectl get services +
-NAME      TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE +
-quarkus   ClusterIP   None         <none>        8080/TCP   12m +
-</code> +
- +
-===1.2 - Mise en Place d'un Scale Up=== +
- +
-Procédez à un scale up : +
- +
-<code> +
-root@kubemaster:~# kubectl scale sts quarkus-statefulset --replicas=3 +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que le nom court d'un **serviceName** est **sts**. +
-</WRAP> +
- +
-Constatez la présence des **trois** pods dans le Namespace : +
- +
-<code> +
-Every 1,0s: kubectl get pods -o wide | awk '{print $1 " " $2 " " $3 " " $5 " " $7}' | column -t                                                                kubemaster.ittraining.loc: Tue Dec  6 17:46:42 2022 +
- +
-NAME                   READY  STATUS   AGE    NODE +
-quarkus-statefulset-0  1/1    Running  5m9s   kubenode2.ittraining.loc +
-quarkus-statefulset-1  1/1    Running  4m38s  kubenode1.ittraining.loc +
-quarkus-statefulset-2  1/1    Running  13s    kubenode2.ittraining.loc +
-</code> +
- +
-Constatez l'ordre de création des pods : +
- +
-<code> +
-root@kubemaster:~# kubectl get events --sort-by=.metadata.creationTimestamp +
-LAST SEEN   TYPE     REASON             OBJECT                            MESSAGE +
-6m35s       Normal   SuccessfulCreate   statefulset/quarkus-statefulset   create Pod quarkus-statefulset-0 in StatefulSet quarkus-statefulset successful +
-6m35s       Normal   Scheduled          pod/quarkus-statefulset-0         Successfully assigned quarkus/quarkus-statefulset-0 to kubenode2.ittraining.loc +
-6m34s       Normal   Pulling            pod/quarkus-statefulset-0         Pulling image "quay.io/rhdevelopers/quarkus-demo:v1" +
-6m5s        Normal   Pulled             pod/quarkus-statefulset-0         Successfully pulled image "quay.io/rhdevelopers/quarkus-demo:v1" in 28.871622372s +
-6m4s        Normal   Created            pod/quarkus-statefulset-0         Created container quarkus-statefulset +
-6m4s        Normal   Started            pod/quarkus-statefulset-0         Started container quarkus-statefulset +
-6m3s        Normal   Scheduled          pod/quarkus-statefulset-1         Successfully assigned quarkus/quarkus-statefulset-1 to kubenode1.ittraining.loc +
-6m3s        Normal   SuccessfulCreate   statefulset/quarkus-statefulset   create Pod quarkus-statefulset-1 in StatefulSet quarkus-statefulset successful +
-5m58s       Normal   Pulling            pod/quarkus-statefulset-1         Pulling image "quay.io/rhdevelopers/quarkus-demo:v1" +
-5m22s       Normal   Pulled             pod/quarkus-statefulset-1         Successfully pulled image "quay.io/rhdevelopers/quarkus-demo:v1" in 35.551473165s +
-5m21s       Normal   Created            pod/quarkus-statefulset-1         Created container quarkus-statefulset +
-5m21s       Normal   Started            pod/quarkus-statefulset-1         Started container quarkus-statefulset +
-99s         Normal   Scheduled          pod/quarkus-statefulset-2         Successfully assigned quarkus/quarkus-statefulset-2 to kubenode2.ittraining.loc +
-99s         Normal   SuccessfulCreate   statefulset/quarkus-statefulset   create Pod quarkus-statefulset-2 in StatefulSet quarkus-statefulset successful +
-98s         Normal   Pulled             pod/quarkus-statefulset-2         Container image "quay.io/rhdevelopers/quarkus-demo:v1" already present on machine +
-97s         Normal   Created            pod/quarkus-statefulset-2         Created container quarkus-statefulset +
-97s         Normal   Started            pod/quarkus-statefulset-2         Started container quarkus-statefulset +
-</code> +
- +
-Créez maintenant un pod pour interroger le DNS de K8s : +
- +
-<code> +
-root@kubemaster:~# kubectl run -it --restart=Never --rm --image busybox:1.28 dns-test +
-If you don't see a command prompt, try pressing enter. +
-/ # nslookup quarkus-statefulset-0.quarkus +
-Server:    10.96.0.10 +
-Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local +
- +
-Name:      quarkus-statefulset-0.quarkus +
-Address 1: 192.168.150.2 quarkus-statefulset-0.quarkus.quarkus.svc.cluster.local +
-/ # exit +
-pod "dns-test" deleted +
-root@kubemaster:~# +
-</code> +
- +
-===1.3 - Mise en Place d'un Scale Down=== +
- +
-Procédez maintenant à un scale down : +
- +
-<code> +
-root@kubemaster:~# kubectl scale sts quarkus-statefulset --replicas=2 +
-statefulset.apps/quarkus-statefulset scaled +
-</code> +
- +
-Constatez la présence de **deux** pods dans le Namespace : +
- +
-<code> +
-Every 1,0s: kubectl get pods -o wide | awk '{print $1 " " $2 " " $3 " " $5 " " $7}' | column -t                                                                kubemaster.ittraining.loc: Tue Dec  6 18:02:27 2022 +
- +
-NAME                   READY  STATUS   AGE  NODE +
-quarkus-statefulset-0  1/1    Running  20m  kubenode2.ittraining.loc +
-quarkus-statefulset-1  1/1    Running  20m  kubenode1.ittraining.loc +
-</code> +
- +
-===1.4 - Suppression du StatefulSet=== +
- +
-Pour terminer, supprimez le StatefulSet, le service et le Namespace : +
- +
-<code> +
-root@kubemaster:~# kubectl delete -f statefulset.yaml  +
-statefulset.apps "quarkus-statefulset" deleted +
- +
-root@kubemaster:~# kubectl delete -f external-svc.yaml  +
-service "quarkus-statefulset-2" deleted +
- +
-root@kubemaster:~# kubectl config set-context --current --namespace=default +
-Context "kubernetes-admin@kubernetes" modified. +
-</code> +
- +
-=====StorageClass Avancé===== +
- +
-====LAB #2 - Provisionnement NFS dynamique==== +
- +
-===2.1 - Configuration du Serveur NFS=== +
- +
-Connectez-vous à la VM CentOS8 en tant que trainee au 10.0.2.46. +
- +
-Devenez root puis créez le répertoire **/srv/nfs/kubedata** : +
- +
-<code> +
-[root@centos8 ~]# mkdir -p /srv/nfs/kubedata +
-</code> +
- +
-Continuez maintenant par activer et démarrer le service **nfs-server** : +
- +
-<code> +
-[root@centos8 ~]# systemctl status nfs-server +
-● nfs-server.service - NFS server and services +
-   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor prese> +
-   Active: inactive (dead) +
- +
-[root@centos8 ~]# systemctl enable nfs-server.service +
-Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service. +
- +
-[root@centos8 ~]# systemctl start nfs-server.service +
- +
-[root@centos8 ~]# systemctl status nfs-server.service +
-● nfs-server.service - NFS server and services +
-   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled) +
-   Active: active (exited) since Mon 2022-11-21 11:02:13 CET; 9s ago +
-  Process: 3276 ExecStart=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited,+
-  Process: 3263 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS) +
-  Process: 3261 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) +
- Main PID: 3276 (code=exited, status=0/SUCCESS) +
- +
-Nov 21 11:02:12 centos8.ittraining.loc systemd[1]: Starting NFS server and services... +
-Nov 21 11:02:13 centos8.ittraining.loc systemd[1]: Started NFS server and services. +
-</code> +
- +
-Editez le fichier **/etc/exports** : +
- +
-<code> +
-[root@centos8 ~]# vi /etc/exports +
-[root@centos8 ~]# cat /etc/exports +
-/srv/nfs/kubedata       *(rw,sync,no_subtree_check,no_root_squash,no_all_squash,insecure) +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Dans ce cas, nous avons partagé le répertoire **/srv/nfs/kubedata** avec le monde. +
-</WRAP> +
- +
-Appliquez l'export : +
- +
-<code> +
-[root@centos8 ~]# exportfs -rav +
-exporting *:/srv/nfs/kubedata +
- +
-[root@centos8 ~]# exportfs -v +
-/srv/nfs/kubedata +
-                <world>(sync,wdelay,hide,no_subtree_check,sec=sys,rw,insecure,no_root_squash,no_all_squash) +
-</code> +
- +
-Passez SELinux en mode permissive : +
- +
-<code> +
-[root@centos8 ~]# getenforce +
-Enforcing +
- +
-[root@centos8 ~]# setenforce permissive +
- +
-</code> +
- +
-Configurez ensuite le pare-feu : +
- +
-<code>  +
-[root@centos8 ~]# firewall-cmd --permanent --add-service=nfs +
-success +
-[root@centos8 ~]# firewall-cmd --permanent --add-service=rpc-bind +
-success +
-[root@centos8 ~]# firewall-cmd --permanent --add-service=mountd +
-success +
-[root@centos8 ~]# firewall-cmd --reload +
-success +
-</code> +
- +
-===2.2 - Configuration des Clients NFS=== +
- +
-Revenez à votre gateway et connectez-vous en tant que l'utilisateur **trainee** à **kubenode2** au 192.168.56.4. Devenez ensuite l'utilisateur root : +
- +
-<code> +
-trainee@kubenode2:~$ su - +
-Mot de passe : fenestros +
-root@kubenode2:~# +
-</code> +
- +
-Installez le paquet **nfs-common** : +
- +
-<code> +
-root@kubenode2:~# apt update +
-... +
- +
-root@kubenode2:~# apt install nfs-common +
-... +
-</code> +
- +
-Vérifiez que vous pouvez voir le répertoire exporté par le 10.0.2.46 : +
- +
-<code> +
-root@kubenode2:~# showmount --exports 10.0.2.46 +
-Export list for 10.0.2.46: +
-/srv/nfs/kubedata * +
-</code> +
- +
-Vérifiez que vous pouvez monter le répertoire exporté par le 10.0.2.46 : +
- +
-<code> +
-root@kubenode2:~# mount -t nfs 10.0.2.46:/srv/nfs/kubedata /mnt +
-root@kubenode2:~# mount | grep kubedata +
-10.0.2.46:/srv/nfs/kubedata on /mnt type nfs4 (rw,relatime,vers=4.2,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.0.2.67,local_lock=none,addr=10.0.2.46) +
-</code> +
- +
-Démontez ensuite **10.0.2.46:/srv/nfs/kubedata** : +
- +
-<code> +
-root@kubenode2:~# umount /mnt +
- +
-root@kubenode2:~# mount | grep kubedata +
-</code> +
- +
-Connectez-vous à kubenode1 au 192.168.56.3 : +
- +
-<code> +
-root@kubenode2:~# ssh -trainee 192.168.56.3 +
-The authenticity of host '192.168.56.3 (192.168.56.3)' 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 '192.168.56.3' (ECDSA) to the list of known hosts. +
-trainee@192.168.56.3's password: trainee +
-Linux kubenode1.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: Wed Sep 28 09:54:21 2022 from 192.168.56.2 +
-trainee@kubenode1:~$ su - +
-Mot de passe : fenestros +
-root@kubenode1:~#  +
-</code> +
- +
-Installez ensuite le paquet **nfs-common** : +
- +
-<code> +
-root@kubenode1:~# apt update +
-... +
- +
-root@kubenode1:~# apt install nfs-common +
-... +
-</code> +
- +
-Revenez à votre gateway : +
- +
-<code> +
-root@kubenode1:~# exit +
-déconnexion +
-trainee@kubenode1:~$ exit +
-déconnexion +
-Connection to 192.168.56.3 closed. +
-root@kubenode2:~# exit +
-déconnexion +
-trainee@kubenode2:~$ exit +
-déconnexion +
-Connection to 192.168.56.4 closed. +
-</code> +
- +
-===2.3 - Configuration de K8s=== +
- +
-Connectez-vous à votre **kubemaster** au 192.168.56.2. +
- +
-Installez ensuite le paquet **nfs-common** : +
- +
-<code> +
-root@kubemaster:~# apt update +
-... +
- +
-root@kubemaster:~# apt install nfs-common +
-... +
-</code> +
- +
-Ajoutez le dépôt **nfs-subdir-external-provisioner** à **helm** : +
- +
-<code> +
-root@kubemaster:~# helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/ +
-"nfs-subdir-external-provisioner" has been added to your repositories +
-</code> +
- +
-Installez le chart helm **nfs-subdir-external-provisioner** : +
- +
-<code> +
-root@kubemaster:~# helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner --set nfs.server=10.0.2.46 --set nfs.path=/srv/nfs/kubedata +
-NAME: nfs-subdir-external-provisioner +
-LAST DEPLOYED: Wed Dec  7 11:12:23 2022 +
-NAMESPACE: default +
-STATUS: deployed +
-REVISION: 1 +
-TEST SUITE: None +
-</code> +
- +
-Contrôlez l'état du pod créé : +
- +
-<code> +
-root@kubemaster:~# kubectl get pods -o wide +
-NAME                                               READY   STATUS              RESTARTS      AGE   IP               NODE                       NOMINATED NODE   READINESS GATES +
-netshoot                                           1/    Running             3 (25h ago)   70d   192.168.239.58   kubenode1.ittraining.loc   <none>           <none> +
-nfs-subdir-external-provisioner-59b4b5c476-wxkp4   0/    ContainerCreating               19m   <none>           kubenode1.ittraining.loc   <none>           <none> +
-nginx-netshoot                                     1/    Running             3 (25h ago)   70d   192.168.239.59   kubenode1.ittraining.loc   <none>           <none> +
-postgresql-6f885d8957-tnlbb                        1/1     Running             3 (25h ago)   70d   192.168.239.62   kubenode1.ittraining.loc   <none>           <none> +
-sharedvolume                                       2/    Running             6 (25h ago)   78d   192.168.150.60   kubenode2.ittraining.loc   <none>           <none> +
-troubleshooting                                    1/1     Running             3 (25h ago)   70d   192.168.239.60   kubenode1.ittraining.loc   <none>           <none> +
-volumepod                                          0/1     Completed                       78d   192.168.150.41   kubenode2.ittraining.loc   <none>           <none> +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Si le pod **nfs-subdir-external-provisioner-yyyyyyyyyy-xxxxx** reste dans un état de **ContainerCreating** pour plus de 5 minutes, supprimez les trois pods **calico-node-xxxxx** du Namespace **kube-system** et attendez qu'ils soient recréés. +
-</WRAP> +
- +
-Une fois recréés, vous pouvez constater que le pod **nfs-subdir-external-provisioner-yyyyyyyyyy-xxxxx** est dans un état de Running : +
- +
-<code> +
-root@kubemaster:~# kubectl get pods -o wide +
-NAMESPACE          NAME                                                READY   STATUS      RESTARTS         AGE     IP               NODE                        NOMINATED NODE   READINESS GATES +
-default            netshoot                                            1/1     Running     3 (25h ago)      70d     192.168.239.58   kubenode1.ittraining.loc    <none>           <none> +
-default            nfs-subdir-external-provisioner-59b4b5c476-wxkp4    1/1     Running     1 (3m18s ago)    36m     192.168.239.63   kubenode1.ittraining.loc    <none>           <none> +
-default            nginx-netshoot                                      1/1     Running     3 (25h ago)      70d     192.168.239.59   kubenode1.ittraining.loc    <none>           <none> +
-default            postgresql-6f885d8957-tnlbb                         1/    Running     3 (25h ago)      70d     192.168.239.62   kubenode1.ittraining.loc    <none>           <none> +
-default            sharedvolume                                        2/2     Running     6 (25h ago)      78d     192.168.150.60   kubenode2.ittraining.loc    <none>           <none> +
-default            troubleshooting                                     1/    Running     3 (25h ago)      70d     192.168.239.60   kubenode1.ittraining.loc    <none>           <none> +
-default            volumepod                                           0/    Completed                  78d     192.168.150.41   kubenode2.ittraining.loc    <none>           <none> +
-</code> +
- +
-L'examen du log du pod **nfs-subdir-external-provisioner-yyyyyyyyyy-xxxxx** démontre que tout fonctionne : +
- +
-<code> +
-root@kubemaster:~# kubectl logs nfs-subdir-external-provisioner-59b4b5c476-wxkp4 +
-I1207 10:45:38.321263       1 leaderelection.go:242] attempting to acquire leader lease  default/cluster.local-nfs-subdir-external-provisioner... +
-I1207 10:45:59.097918       1 leaderelection.go:252] successfully acquired lease default/cluster.local-nfs-subdir-external-provisioner +
-I1207 10:45:59.097979       1 event.go:278] Event(v1.ObjectReference{Kind:"Endpoints", Namespace:"default", Name:"cluster.local-nfs-subdir-external-provisioner", UID:"986e4938-a054-4bf9-bfdd-903749c7f63f", APIVersion:"v1", ResourceVersion:"6690493", FieldPath:""}): type: 'Normal' reason: 'LeaderElection' nfs-subdir-external-provisioner-59b4b5c476-wxkp4_1d17de3a-ac5b-442c-aa63-8253d33c2857 became leader +
-I1207 10:45:59.098098       1 controller.go:820] Starting provisioner controller cluster.local/nfs-subdir-external-provisioner_nfs-subdir-external-provisioner-59b4b5c476-wxkp4_1d17de3a-ac5b-442c-aa63-8253d33c2857! +
-I1207 10:45:59.198332       1 controller.go:869] Started provisioner controller cluster.local/nfs-subdir-external-provisioner_nfs-subdir-external-provisioner-59b4b5c476-wxkp4_1d17de3a-ac5b-442c-aa63-8253d33c2857! +
-</code> +
- +
-Consultez maintenant la liste des StorageClasses : +
- +
-<code> +
-root@kubemaster:~# kubectl get storageclass +
-NAME         PROVISIONER                                     RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE +
-localdisk    kubernetes.io/no-provisioner                    Delete          Immediate           true                   77d +
-nfs-client   cluster.local/nfs-subdir-external-provisioner   Delete          Immediate           true                   52m +
-</code> +
- +
-===2.4 - Création d'un PersistentVolumeClaim=== +
- +
-Créez maintenant le fichier **pvc.yaml** :  +
- +
-<code> +
-root@kubemaster:~# vi pvc.yaml +
-root@kubemaster:~# cat pvc.yaml +
-apiVersion: v1 +
-kind: PersistentVolumeClaim +
-metadata: +
-  name: pvc1 +
-spec: +
-  storageClassName: nfs-client  +
-  accessModes: +
-    - ReadWriteMany +
-  resources: +
-    requests: +
-      storage: 500Mi +
-</code> +
- +
-Appliquez le fichier pvc.yaml : +
- +
-<code> +
-root@kubemaster:~# kubectl apply -f pvc.yaml  +
-persistentvolumeclaim/pvc1 created +
-</code> +
- +
-Constatez maintenant la liste de PersistentVolumes et de PersistentVolumeClaims : +
- +
-<code> +
-root@kubemaster:~# kubectl get pv,pvc +
-NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM          STORAGECLASS   REASON   AGE +
-persistentvolume/mypv                                       1Gi        RWO            Recycle          Available                  localdisk               77d +
-persistentvolume/pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da   500Mi      RWX            Delete           Bound       default/pvc1   nfs-client              66s +
- +
-NAME                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE +
-persistentvolumeclaim/pvc1   Bound    pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da   500Mi      RWX            nfs-client     67s +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que le PersistentVolume **persistentvolume/pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da** a été créé automatiquement. +
-</WRAP> +
- +
-Connectez-vous au serveur NFS et constatez le contenu du répertoire **/srv/nfs/kubedata** : +
- +
-<code> +
-root@kubemaster:~# ssh -l trainee 10.0.2.46 +
-The authenticity of host '10.0.2.46 (10.0.2.46)' can't be established. +
-ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. +
-Are you sure you want to continue connecting (yes/no)? yes +
-Warning: Permanently added '10.0.2.46' (ECDSA) to the list of known hosts. +
-trainee@10.0.2.46's password: trainee +
-Activate the web console with: systemctl enable --now cockpit.socket +
- +
-Last login: Wed Dec  7 10:34:25 2022 from 10.0.2.65 +
- +
-[trainee@centos8 ~]$ ls -l /srv/nfs/kubedata/ +
-total 0 +
-drwxrwxrwx. 2 root root 6 Dec  7 12:32 default-pvc1-pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da +
-[trainee@centos8 ~]$ exit +
-logout +
-Connection to 10.0.2.46 closed. +
-</code> +
- +
-===2.5 - Utilisation du PersistentVolumeClaim avec un pod=== +
- +
-Créez maintenant le fichier **nfs-busybox.yaml** : +
- +
-<code> +
-root@kubemaster:~# vi nfs-busybox.yaml +
-root@kubemaster:~# cat nfs-busybox.yaml +
-apiVersion: v1 +
-kind: Pod +
-metadata: +
-  name: nfs-pv-pod +
-spec: +
-  restartPolicy: Never +
-  containers: +
-  - name: busybox +
-    image: busybox +
-    command: ['sh', '-c', 'while true; do sleep 3600; done'+
-    volumeMounts: +
-    - name: pv-storage +
-      mountPath: /pv-pod-storage +
-  volumes: +
-  - name: pv-storage +
-    persistentVolumeClaim: +
-      claimName: pvc1 +
-</code> +
- +
-Appliquez le fichier nfs-busybox.yaml : +
- +
-<code> +
-root@kubemaster:~# kubectl apply -f nfs-busybox.yaml +
-pod/nfs-pv-pod created +
-</code> +
- +
-Vérifiez que le statut du pod **nfs-pv-pod** est **Running** : +
- +
-<code> +
-root@kubemaster:~# kubectl get pods +
-NAME                                               READY   STATUS      RESTARTS      AGE +
-netshoot                                           1/    Running     3 (26h ago)   70d +
-nfs-pv-pod                                         1/    Running                 2m9s +
-nfs-subdir-external-provisioner-59b4b5c476-wxkp4   1/    Running     1 (80m ago)   113m +
-nginx-netshoot                                     1/    Running     3 (26h ago)   70d +
-postgresql-6f885d8957-tnlbb                        1/1     Running     3 (26h ago)   70d +
-sharedvolume                                       2/    Running     6 (26h ago)   78d +
-troubleshooting                                    1/1     Running     3 (26h ago)   70d +
-volumepod                                          0/1     Completed               78d +
-</code> +
- +
-Connectez-vous au conteneur du pod **nfs-pv-pod** : +
- +
-<code> +
-root@kubemaster:~# kubectl exec -it nfs-pv-pod -- sh +
-/ #  +
-</code> +
- +
-Créez le fichier **hello** dans le répertoire **pv-pod-storage** :  +
- +
-<code> +
-root@kubemaster:~# kubectl exec -it nfs-pv-pod -- sh +
-/ # ls +
-bin             dev             etc             home            lib             lib64           proc            pv-pod-storage  root            sys             tmp             usr             var +
-/ # touch /pv-pod-storage/hello +
-/ # ls /pv-pod-storage/ +
-hello +
-/ # exit +
-</code> +
- +
-Connectez-vous au serveur NFS et constatez le contenu du répertoire **/srv/nfs/kubedata** : +
- +
-<code> +
-root@kubemaster:~# ssh -l trainee 10.0.2.46 +
-trainee@10.0.2.46's password:  +
-Activate the web console with: systemctl enable --now cockpit.socket +
- +
-Last login: Wed Dec  7 12:37:00 2022 from 10.0.2.65 +
-[trainee@centos8 ~]$ ls -lR /srv/nfs/kubedata/ +
-/srv/nfs/kubedata/: +
-total 0 +
-drwxrwxrwx. 2 root root 19 Dec  7 13:13 default-pvc1-pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da +
- +
-/srv/nfs/kubedata/default-pvc1-pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da: +
-total 0 +
--rw-r--r--. 1 root root 0 Dec  7 13:13 hello +
-[trainee@centos8 ~]$ exit +
-logout +
-Connection to 10.0.2.46 closed. +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez la présence du fichier **hello**. +
-</WRAP> +
- +
-===2.6 - Création d'un Deuxième PersistentVolumeClaim=== +
- +
-Vréez le fichier **pvc2.yaml** : +
- +
-<code> +
-root@kubemaster:~# vi pvc2.yaml +
-root@kubemaster:~# cat pvc2.yaml +
-apiVersion: v1 +
-kind: PersistentVolumeClaim +
-metadata: +
-  name: pvc2 +
-spec: +
-  storageClassName: nfs-client  +
-  accessModes: +
-    - ReadWriteOnce +
-  resources: +
-    requests: +
-      storage: 100Mi +
-</code> +
- +
-Appliquez le fichier **pvc2.yaml** : +
- +
-<code> +
-root@kubemaster:~# kubectl apply -f pvc2.yaml  +
-persistentvolumeclaim/pvc2 created +
-</code> +
- +
-Constatez maintenant la liste de PersistentVolumes et de PersistentVolumeClaims : +
- +
-<code> +
-root@kubemaster:~# kubectl get pv,pvc +
-NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM          STORAGECLASS   REASON   AGE +
-persistentvolume/mypv                                       1Gi        RWO            Recycle          Available                  localdisk               77d +
-persistentvolume/pvc-6dbce6de-e473-4e4c-99be-0fbea26576de   100Mi      RWO            Delete           Bound       default/pvc2   nfs-client              58s +
-persistentvolume/pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da   500Mi      RWX            Delete           Bound       default/pvc1   nfs-client              53m +
- +
-NAME                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE +
-persistentvolumeclaim/pvc1   Bound    pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da   500Mi      RWX            nfs-client     53m +
-persistentvolumeclaim/pvc2   Bound    pvc-6dbce6de-e473-4e4c-99be-0fbea26576de   100Mi      RWO            nfs-client     58s +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que le PersistentVolume **persistentvolume/pvc-6dbce6de-e473-4e4c-99be-0fbea26576de** a été créé automatiquement. +
-</WRAP> +
- +
-===2.7 - Suppression des PersistentVolumeClaims=== +
- +
-Commencer par supprimer le pod **nfs-pv-pod** : +
- +
-<code> +
-root@kubemaster:~# kubectl delete pod nfs-pv-pod +
-pod "nfs-pv-pod" deleted +
-</code> +
- +
-Constatez la suppression effective du pod : +
- +
-<code> +
-root@kubemaster:~# kubectl get pods +
-NAME                                               READY   STATUS      RESTARTS       AGE +
-netshoot                                           1/    Running     3 (27h ago)    70d +
-nfs-subdir-external-provisioner-59b4b5c476-wxkp4   1/    Running     1 (126m ago)   159m +
-nginx-netshoot                                     1/    Running     3 (27h ago)    70d +
-postgresql-6f885d8957-tnlbb                        1/1     Running     3 (27h ago)    70d +
-sharedvolume                                       2/    Running     6 (27h ago)    78d +
-troubleshooting                                    1/1     Running     3 (27h ago)    70d +
-volumepod                                          0/1     Completed                78d +
-</code> +
- +
-Constatez maintenant la liste de PersistentVolumes et de PersistentVolumeClaims : +
- +
-<code> +
-root@kubemaster:~# kubectl get pv,pvc +
-NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM          STORAGECLASS   REASON   AGE +
-persistentvolume/mypv                                       1Gi        RWO            Recycle          Available                  localdisk               77d +
-persistentvolume/pvc-6dbce6de-e473-4e4c-99be-0fbea26576de   100Mi      RWO            Delete           Bound       default/pvc2   nfs-client              27m +
-persistentvolume/pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da   500Mi      RWX            Delete           Bound       default/pvc1   nfs-client              79m +
- +
-NAME                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE +
-persistentvolumeclaim/pvc1   Bound    pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da   500Mi      RWX            nfs-client     79m +
-persistentvolumeclaim/pvc2   Bound    pvc-6dbce6de-e473-4e4c-99be-0fbea26576de   100Mi      RWO            nfs-client     27m +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que les PersistentVolumes et les PersistentVolumeClaims sont toujours présents. +
-</WRAP> +
- +
-Supprimes les deux PersistentVolumeClaims : +
- +
-<code> +
-root@kubemaster:~# kubectl delete pvc --all +
-persistentvolumeclaim "pvc1" deleted +
-persistentvolumeclaim "pvc2" deleted +
-</code> +
- +
-Constatez ensuite que les deux PersistentVolumes ont été supprimés automatiquement : +
- +
-<code> +
-root@kubemaster:~# kubectl get pv,pvc +
-NAME                    CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE +
-persistentvolume/mypv   1Gi        RWO            Recycle          Available           localdisk               77d +
-</code> +
- +
-Connectez-vous au serveur NFS et constatez le contenu du répertoire **/srv/nfs/kubedata** : +
- +
-<code> +
-root@kubemaster:~# ssh -l trainee 10.0.2.46 +
-trainee@10.0.2.46's password:  +
-Activate the web console with: systemctl enable --now cockpit.socket +
- +
-Last login: Wed Dec  7 13:15:49 2022 from 10.0.2.65 +
-[trainee@centos8 ~]$ ls -lR /srv/nfs/kubedata/ +
-/srv/nfs/kubedata/: +
-total 0 +
-drwxrwxrwx. 2 root root 19 Dec  7 13:13 archived-default-pvc1-pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da +
-drwxrwxrwx. 2 root root  6 Dec  7 13:24 archived-default-pvc2-pvc-6dbce6de-e473-4e4c-99be-0fbea26576de +
- +
-/srv/nfs/kubedata/archived-default-pvc1-pvc-721f5ed3-88b1-41bb-82c2-9eab3b4464da: +
-total 0 +
--rw-r--r--. 1 root root 0 Dec  7 13:13 hello +
- +
-/srv/nfs/kubedata/archived-default-pvc2-pvc-6dbce6de-e473-4e4c-99be-0fbea26576de: +
-total 0 +
-[trainee@centos8 ~]$ exit +
-logout +
-Connection to 10.0.2.46 closed. +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que les répertoires ont un préfixe **archived-** +
-</WRAP> +
- +
-=====Helm Avancé===== +
- +
-Un chart est une collection de fichiers et de répertoires qui prennent la forme suivante : +
- +
-<file> +
-MyChart/ +
-  Chart.yaml +
-  LICENSE +
-  README.md +
-  values.yaml +
-  values.schema.json +
-  charts/ +
-  crds/ +
-  templates/ +
-  templates/NOTES.txt +
-</file> +
- +
-Le langage des templates de helm est basé sur le langage GO. +
- +
-Dans le LAB suivant, vous allez prendre les deux manifests suivants, **ghost.yaml** et **ghost-service.yaml** et créer un chart helm pour installer  **Ghost**, une plateforme de blogs gratuite, sous licence logiciel libre : +
- +
-<code> +
-root@kubemaster:~# vi ghost.yaml +
-root@kubemaster:~# cat ghost.yaml  +
-apiVersion: apps/v1 +
-kind: Deployment +
-metadata: +
-  name: blog +
-  labels: +
-    app: blog +
-spec: +
-  replicas: 1 +
-  selector: +
-    matchLabels: +
-      app: blog +
-  template: +
-    metadata: +
-      labels: +
-        app: blog +
-    spec: +
-      containers: +
-      - name: blog +
-        image: ghost:2.6-alpine +
-        imagePullPolicy: Always +
-        ports: +
-        - containerPort: 2368 +
-        env: +
-        - name: url +
-          value: http://exampleblog.com +
-</code> +
- +
-<code> +
-root@kubemaster:~# vi ghost-service.yaml +
-root@kubemaster:~# cat ghost-service.yaml  +
-apiVersion: v1 +
-kind: Service +
-metadata: +
-  name: blog +
-spec: +
-  type: NodePort +
-  selector: +
-    app: blog +
-  ports: +
-  - protocol: TCP +
-    port: 80 +
-    targetPort: 2368 +
-</code>  +
- +
-====LAB #3 - Création d'un Paquet Helm Simple==== +
- +
-Commencez par créer le répertoire **~/ghost** et placez-vous dedans :      +
- +
-<code> +
-root@kubemaster:~# mkdir ghost +
-root@kubemaster:~# cd ghost +
-</code> +
- +
-Un chart necéssite la présence d'un fichier nommé **Chart.yaml** qui doit décrire le chart en question. Créez donc ce fichier : +
- +
-<code> +
-root@kubemaster:~/ghost# touch Chart.yaml +
-</code> +
- +
-===3.1 - Le Fichier values.yaml=== +
- +
-Un chart a aussi besoin d'un fichier dénommé **values.yaml** qui contient des valeurs de configuration du chart en question. Créez donc le fichier values.yaml avec le contenu suivant : +
- +
-<code> +
-root@kubemaster:~/ghost# vi values.yaml +
-root@kubemaster:~/ghost# cat values.yaml +
-service: +
-  name: blog +
-  type: NodePort +
-  app: blog +
-  protocol: TCP +
-  port: 80 +
-  targetPort: 2368 +
-</code> +
- +
-===3.2 - Les Templates=== +
- +
-Créez le sous-répertoire **templates** dans **ghost** : +
- +
-<code> +
-root@kubemaster:~/ghost# mkdir templates +
-</code> +
- +
-Copiez le contenu du fichier **~/ghost-service.yaml** et collez-le dans le fichier **~/ghost/templates/service.yaml** : +
- +
-<code> +
-root@kubemaster:~/ghost# vi templates/service.yaml +
-root@kubemaster:~/ghost# cat templates/service.yaml  +
-apiVersion: v1 +
-kind: Service +
-metadata: +
-  name: blog +
-spec: +
-  type: NodePort +
-  selector: +
-    app: blog +
-  ports: +
-  - protocol: TCP +
-    port: 80 +
-    targetPort: 2368 +
-</code> +
- +
-Modifiez ensuite ce fichier pour lire les valeurs du fichier **values.yaml** : +
- +
-<code> +
-root@kubemaster:~/ghost# vi templates/service.yaml +
-root@kubemaster:~/ghost# cat templates/service.yaml +
-apiVersion: v1 +
-kind: Service +
-metadata: +
-  name: {{ .Values.service.name }} +
-spec: +
-  type: {{ .Values.service.type }} +
-  selector: +
-    app: {{ .Values.service.app }} +
-  ports: +
-  - protocol: {{ .Values.service.protocol }} +
-    port: {{ .Values.service.port }} +
-    targetPort: {{ .Values.service.targetPort }} +
-</code> +
- +
-Naviguez vers le répertoire parent du répertoire **ghost** : +
- +
-<code> +
-root@kubemaster:~/ghost# cd .. +
-</code> +
- +
-Vérifiez que helm peut lire la liste des valeurs du fichier values.yaml : +
- +
-<code> +
-root@kubemaster:~# helm show values ghost +
-Error: validation: chart.metadata.name is required +
-</code> +
- +
-L'erreur obtenu fait référence au fichier **Chart.yaml**, actuellement vide. Editez donc ce fichier : +
- +
-<code> +
-root@kubemaster:~# vi ghost/Chart.yaml +
-root@kubemaster:~# cat ghost/Chart.yaml +
-name: ghost +
-version: 1 +
-</code> +
- +
-Vérifiez maintenant que helm peut lire la liste des valeurs du fichier values.yaml : +
- +
-<code> +
-root@kubemaster:~# helm show values ghost +
-service: +
-  name: blog +
-  type: NodePort +
-  app: blog +
-  protocol: TCP +
-  port: 80 +
-  targetPort: 2368 +
-</code> +
- +
-Vérifiez maintenant que le manifest **service.yaml** qui sera créé par Helm est correct : +
- +
-<code> +
-root@kubemaster:~# helm install check ghost --dry-run +
-NAME: check +
-LAST DEPLOYED: Thu Dec  8 15:54:13 2022 +
-NAMESPACE: default +
-STATUS: pending-install +
-REVISION: 1 +
-TEST SUITE: None +
-HOOKS: +
-MANIFEST: +
---- +
-# Source: ghost/templates/service.yaml +
-apiVersion: v1 +
-kind: Service +
-metadata: +
-  name: blog +
-spec: +
-  type: NodePort +
-  selector: +
-    app: blog +
-  ports: +
-  - protocol: TCP +
-    port: 80 +
-    targetPort: 2368 +
-</code> +
- +
-Copiez maintenant le contenu du fichier **~/ghost.yaml** et collez-le dans le fichier **~/ghost/templates/ghost.yaml** : +
- +
-<code> +
-root@kubemaster:~# vi ghost/templates/ghost.yaml +
-root@kubemaster:~# cat ghost/templates/ghost.yaml +
-apiVersion: apps/v1 +
-kind: Deployment +
-metadata: +
-  name: blog +
-  labels: +
-    app: blog +
-spec: +
-  replicas: 1 +
-  selector: +
-    matchLabels: +
-      app: blog +
-  template: +
-    metadata: +
-      labels: +
-        app: blog +
-    spec: +
-      containers: +
-      - name: blog +
-        image: ghost:2.6-alpine +
-        imagePullPolicy: Always +
-        ports: +
-        - containerPort: 2368 +
-        env: +
-        - name: url +
-          value: http://exampleblog.com +
-</code> +
- +
-Modifiez ensuite ce fichier pour lire les valeurs du fichier **values.yaml** : +
- +
-<code> +
-root@kubemaster:~# vi ghost/templates/ghost.yaml +
-root@kubemaster:~# cat ghost/templates/ghost.yaml +
-apiVersion: apps/v1 +
-kind: Deployment +
-metadata: +
-  name: {{ .Values.blog.name }} +
-  labels: +
-    app: {{ .Values.blog.label }} +
-spec: +
-  replicas: {{ .Values.blog.replicas }} +
-  selector: +
-    matchLabels: +
-      app: {{ .Values.blog.name }} +
-  template: +
-    metadata: +
-      labels: +
-        app: {{ .Values.blog.name }} +
-    spec: +
-      containers: +
-      - name: {{ .Values.blog.name }} +
-        image: {{ .Values.blog.image }} +
-        imagePullPolicy: {{ .Values.blog.imagePullPolicy }} +
-        ports: +
-        - containerPort: {{ .Values.blog.containerPort }} +
-        env: +
-        - name: {{ .Values.blog.url }} +
-          value: {{ .Values.blog.urlValue }} +
-</code> +
- +
-Completez maintenant le contenu du fichier values.yaml : +
- +
-<code> +
-root@kubemaster:~# vi ghost/values.yaml +
-root@kubemaster:~# cat ghost/values.yaml +
-service: +
-  name: blog +
-  type: NodePort +
-  app: blog +
-  protocol: TCP +
-  port: 80 +
-  targetPort: 2368 +
-blog: +
-  name: blog +
-  label: blog +
-  replicas: 1 +
-  image: ghost:2.6-alpine +
-  imagePullPolicy: Always +
-  containerPort: 2368 +
-  url: url +
-  urlValue: http://exampleblog.com +
-</code> +
- +
-Vérifiez maintenant que le manifest **ghost.yaml** qui sera créé par Helm est correct : +
- +
-<code> +
-root@kubemaster:~# helm install check ghost --dry-run +
-NAME: check +
-LAST DEPLOYED: Thu Dec  8 16:12:29 2022 +
-NAMESPACE: default +
-STATUS: pending-install +
-REVISION: 1 +
-TEST SUITE: None +
-HOOKS: +
-MANIFEST: +
---- +
-# Source: ghost/templates/service.yaml +
-apiVersion: v1 +
-kind: Service +
-metadata: +
-  name: blog +
-spec: +
-  type: NodePort +
-  selector: +
-    app: blog +
-  ports: +
-  - protocol: TCP +
-    port: 80 +
-    targetPort: 2368 +
---- +
-# Source: ghost/templates/ghost.yaml +
-apiVersion: apps/v1 +
-kind: Deployment +
-metadata: +
-  name: blog +
-  labels: +
-    app: blog +
-spec: +
-  replicas: 1 +
-  selector: +
-    matchLabels: +
-      app: blog +
-  template: +
-    metadata: +
-      labels: +
-        app: blog +
-    spec: +
-      containers: +
-      - name: blog +
-        image: ghost:2.6-alpine +
-        imagePullPolicy: Always +
-        ports: +
-        - containerPort: 2368 +
-        env: +
-        - name: url +
-          value: http://exampleblog.com +
-</code> +
- +
-Consultez maintenant l'organisation du chart **ghost** : +
- +
-<code> +
-root@kubemaster:~# tree ghost +
-ghost +
-├── Chart.yaml +
-├── templates +
-│   ├── ghost.yaml +
-│   └── service.yaml +
-└── values.yaml +
- +
-1 directory, 4 files +
-</code> +
- +
-===3.3 - Installation et Suppression=== +
- +
-Installez le chart **ghost** : +
- +
-<code> +
-root@kubemaster:~# helm install live ghost +
-NAME: live +
-LAST DEPLOYED: Thu Dec  8 16:14:13 2022 +
-NAMESPACE: default +
-STATUS: deployed +
-REVISION: 1 +
-TEST SUITE: None +
-</code> +
- +
-Vérifiez l'état du service dans le cluster : +
- +
-<code> +
-root@kubemaster:~# kubectl get svc +
-NAME               TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE +
-blog               NodePort    10.106.215.169   <none>        80:32070/TCP   52s +
-kubernetes         ClusterIP   10.96.0.1        <none>        443/TCP        95d +
-service-netshoot   ClusterIP   10.107.115.28    <none>        80/TCP         71d +
-</code> +
- +
-Vérifiez la présence du pod dans le cluster : +
- +
-<code> +
-root@kubemaster:~# kubectl get po +
-NAME                                               READY   STATUS      RESTARTS       AGE +
-blog-8545df8764-hk8rc                              1/1     Running                  105s +
-netshoot                                           1/    Running     3 (2d6h ago)   71d +
-nfs-subdir-external-provisioner-59b4b5c476-wxkp4   1/    Running     1 (28h ago)    29h +
-nginx-netshoot                                     1/    Running     3 (2d6h ago)   71d +
-postgresql-6f885d8957-tnlbb                        1/1     Running     3 (2d6h ago)   71d +
-sharedvolume                                       2/    Running     6 (2d6h ago)   79d +
-troubleshooting                                    1/1     Running     3 (2d6h ago)   71d +
-volumepod                                          0/1     Completed   0 +
-</code> +
- +
-Vérifiez le statut du chart : +
- +
-<code> +
-root@kubemaster:~# helm status live +
-NAME: live +
-LAST DEPLOYED: Thu Dec  8 16:14:13 2022 +
-NAMESPACE: default +
-STATUS: deployed +
-REVISION: 1 +
-TEST SUITE: None +
-</code> +
- +
-Dernièrement, supprimez le chart : +
- +
-<code> +
-root@kubemaster:~# helm delete live +
-release "live" uninstalled +
-</code> +
- +
-=====Monitoring===== +
- +
-Le serveur Prometheus est composé de trois modules : +
- +
-  * **Data Retrieval Worker** qui récupére les métriques +
-  * **Time Series Database** qui stocke les métriques +
-  * **HTTP Server** qui accepte des requêtes PromQL et qui fournit un Web UI pour la consultation des données +
- +
-<WRAP center round important 60%> +
-**Important** : **[[https://prometheus.io/docs/prometheus/latest/querying/basics/|PromQL]]**, abréviation de Prometheus Querying Language, est le principal moyen d'interroger les métriques dans Prometheus. Vous pouvez afficher le retour d'une expression sous forme de graphique ou l'exporter à l'aide de l'API HTTP. PromQL utilise trois types de données : les scalaires, les vecteurs de plage et les vecteurs instantanés. Il utilise également des chaînes, mais uniquement en tant que littéraux. +
-</WRAP> +
- +
-Des alertes sont ensuite passées à l'**Alertmanager** qui informe des personnes en focntion de la configuration mise en place. +
- +
-====LAB #4 - Mise en Place d'une Solution Prometheus==== +
- +
-===4.1 - Déploiement du Stack avec Helm=== +
- +
-Ajoutez le dépôt **prometheus-community** : +
- +
-<code> +
-root@kubemaster:~# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +
-"prometheus-community" has been added to your repositories +
-root@kubemaster:~# helm repo update +
-Hang tight while we grab the latest from your chart repositories... +
-...Successfully got an update from the "nfs-subdir-external-provisioner" chart repository +
-...Successfully got an update from the "prometheus-community" chart repository +
-...Successfully got an update from the "bitnami" chart repository +
-Update Complete. ⎈Happy Helming!⎈ +
-</code> +
- +
-Installez ensuite le chart **kube-prometheus-stack** : +
- +
-<code> +
-root@kubemaster:~# helm install prometheus prometheus-community/kube-prometheus-stack +
-NAME: prometheus +
-LAST DEPLOYED: Thu Dec  8 17:04:17 2022 +
-NAMESPACE: default +
-STATUS: deployed +
-REVISION: 1 +
-NOTES: +
-kube-prometheus-stack has been installed. Check its status by running: +
-  kubectl --namespace default get pods -l "release=prometheus" +
- +
-Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator. +
-</code> +
- +
-Patientez jusqu'à ce que tous les pods soient dans un état de **Running** : +
- +
-<code> +
-root@kubemaster:~# kubectl --namespace default get pods -l "release=prometheus" +
-NAME                                                   READY   STATUS    RESTARTS   AGE +
-prometheus-kube-prometheus-operator-689dd6679c-2th6f   1/    Running            4m12s +
-prometheus-kube-state-metrics-6cfd96f4c8-wrw2n         1/    Running            4m12s +
-prometheus-prometheus-node-exporter-8cb4s              1/1     Running            4m13s +
-prometheus-prometheus-node-exporter-ll4qp              1/1     Running            4m13s +
-prometheus-prometheus-node-exporter-x87f7              1/1     Running            4m13s +
-</code> +
- +
-Consultez maintenant l'ensemb le des objets Prometheus créés par l'installation : +
- +
-<code> +
-root@kubemaster:~# kubectl get all -l "release=prometheus" +
-NAME                                                       READY   STATUS    RESTARTS   AGE +
-pod/prometheus-kube-prometheus-operator-689dd6679c-2th6f   1/    Running            13h +
-pod/prometheus-kube-state-metrics-6cfd96f4c8-wrw2n         1/    Running            13h +
-pod/prometheus-prometheus-node-exporter-8cb4s              1/1     Running            13h +
-pod/prometheus-prometheus-node-exporter-ll4qp              1/1     Running            13h +
-pod/prometheus-prometheus-node-exporter-x87f7              1/1     Running            13h +
- +
-NAME                                              TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE +
-service/prometheus-kube-prometheus-alertmanager   ClusterIP   10.103.114.236   <none>        9093/TCP   13h +
-service/prometheus-kube-prometheus-operator       ClusterIP   10.107.174.218   <none>        443/TCP    13h +
-service/prometheus-kube-prometheus-prometheus     ClusterIP   10.108.124.100   <none>        9090/TCP   13h +
-service/prometheus-kube-state-metrics             ClusterIP   10.109.13.26     <none>        8080/TCP   13h +
-service/prometheus-prometheus-node-exporter       ClusterIP   10.103.100.124   <none>        9100/TCP   13h +
- +
-NAME                                                 DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE +
-daemonset.apps/prometheus-prometheus-node-exporter                                    3           <none>          13h +
- +
-NAME                                                  READY   UP-TO-DATE   AVAILABLE   AGE +
-deployment.apps/prometheus-kube-prometheus-operator   1/               1           13h +
-deployment.apps/prometheus-kube-state-metrics         1/               1           13h +
- +
-NAME                                                             DESIRED   CURRENT   READY   AGE +
-replicaset.apps/prometheus-kube-prometheus-operator-689dd6679c                         13h +
-replicaset.apps/prometheus-kube-state-metrics-6cfd96f4c8                               13h +
- +
-NAME                                                                    READY   AGE +
-statefulset.apps/alertmanager-prometheus-kube-prometheus-alertmanager   1/    13h +
-statefulset.apps/prometheus-prometheus-kube-prometheus-prometheus       1/    13h +
-</code> +
- +
-Dans cette sortie on constate : +
- +
-  * 2 StatefulSets dont : +
-    * le serveur Prometheus **statefulset.apps/prometheus-prometheus-kube-prometheus-prometheus** +
-    * l'Alertmanager **statefulset.apps/alertmanager-prometheus-kube-prometheus-alertmanager** +
-  * 2 Deployments dont : +
-    * l'operator **deployment.apps/prometheus-kube-prometheus-operator** qui a créé les deux StatefulSets +
-    * le kube-state-metrics **deployment.apps/prometheus-kube-state-metrics** qui est une dépendance de Prometheus et donc un **Subchart** de ce dernier +
-  * 2 ReplicaSets créés par les Deployments : +
-    * **replicaset.apps/prometheus-kube-prometheus-operator-689dd6679c** +
-    * **replicaset.apps/prometheus-kube-state-metrics-6cfd96f4c8** +
-  * 1 DaemonSet **daemonset.apps/prometheus-prometheus-node-exporter ** : +
-    * les pods de ce DaemonSet sont responsables pour la transformation des métriques des noeuds en métriques Prometheus   +
- +
-L'installation a aussi créé un grand nombre de ConfigMaps : +
- +
-<code> +
-root@kubemaster:~# kubectl get configmap -l "release=prometheus" +
-NAME                                                           DATA   AGE +
-prometheus-kube-prometheus-alertmanager-overview                    13h +
-prometheus-kube-prometheus-apiserver                                13h +
-prometheus-kube-prometheus-cluster-total                            13h +
-prometheus-kube-prometheus-controller-manager                  1      13h +
-prometheus-kube-prometheus-etcd                                1      13h +
-prometheus-kube-prometheus-grafana-datasource                  1      13h +
-prometheus-kube-prometheus-grafana-overview                    1      13h +
-prometheus-kube-prometheus-k8s-coredns                              13h +
-prometheus-kube-prometheus-k8s-resources-cluster                    13h +
-prometheus-kube-prometheus-k8s-resources-namespace                  13h +
-prometheus-kube-prometheus-k8s-resources-node                  1      13h +
-prometheus-kube-prometheus-k8s-resources-pod                        13h +
-prometheus-kube-prometheus-k8s-resources-workload              1      13h +
-prometheus-kube-prometheus-k8s-resources-workloads-namespace        13h +
-prometheus-kube-prometheus-kubelet                                  13h +
-prometheus-kube-prometheus-namespace-by-pod                    1      13h +
-prometheus-kube-prometheus-namespace-by-workload                    13h +
-prometheus-kube-prometheus-node-cluster-rsrc-use                    13h +
-prometheus-kube-prometheus-node-rsrc-use                            13h +
-prometheus-kube-prometheus-nodes                                    13h +
-prometheus-kube-prometheus-nodes-darwin                        1      13h +
-prometheus-kube-prometheus-persistentvolumesusage              1      13h +
-prometheus-kube-prometheus-pod-total                                13h +
-prometheus-kube-prometheus-prometheus                          1      13h +
-prometheus-kube-prometheus-proxy                                    13h +
-prometheus-kube-prometheus-scheduler                                13h +
-prometheus-kube-prometheus-workload-total                      1      13h +
-</code> +
- +
-ainsi que des Secrets : +
- +
-<code> +
-root@kubemaster:~# kubectl get secrets  +
-NAME                                                                TYPE                 DATA   AGE +
-alertmanager-prometheus-kube-prometheus-alertmanager                Opaque                    13h +
-alertmanager-prometheus-kube-prometheus-alertmanager-generated      Opaque                    13h +
-alertmanager-prometheus-kube-prometheus-alertmanager-tls-assets-0   Opaque                    13h +
-alertmanager-prometheus-kube-prometheus-alertmanager-web-config     Opaque                    13h +
-my-secret                                                           Opaque                    88d +
-prometheus-grafana                                                  Opaque                    13h +
-prometheus-kube-prometheus-admission                                Opaque                    13h +
-prometheus-prometheus-kube-prometheus-prometheus                    Opaque                    13h +
-prometheus-prometheus-kube-prometheus-prometheus-tls-assets-0       Opaque                    13h +
-prometheus-prometheus-kube-prometheus-prometheus-web-config         Opaque                    13h +
-sh.helm.release.v1.nfs-subdir-external-provisioner.v1               helm.sh/release.v1        43h +
-sh.helm.release.v1.prometheus.v1                                    helm.sh/release.v1        13h +
-</code> +
- +
-des **Custom Resource Definitions** ou crd : +
- +
-<code> +
-root@kubemaster:~# kubectl get crd +
-NAME                                                  CREATED AT +
-alertmanagerconfigs.monitoring.coreos.com             2022-12-08T16:04:14Z +
-alertmanagers.monitoring.coreos.com                   2022-12-08T16:04:14Z +
-bgpconfigurations.crd.projectcalico.org               2022-09-04T07:38:47Z +
-bgppeers.crd.projectcalico.org                        2022-09-04T07:38:47Z +
-blockaffinities.crd.projectcalico.org                 2022-09-04T07:38:48Z +
-caliconodestatuses.crd.projectcalico.org              2022-09-04T07:38:48Z +
-clusterinformations.crd.projectcalico.org             2022-09-04T07:38:48Z +
-felixconfigurations.crd.projectcalico.org             2022-09-04T07:38:48Z +
-globalnetworkpolicies.crd.projectcalico.org           2022-09-04T07:38:48Z +
-globalnetworksets.crd.projectcalico.org               2022-09-04T07:38:49Z +
-hostendpoints.crd.projectcalico.org                   2022-09-04T07:38:49Z +
-ipamblocks.crd.projectcalico.org                      2022-09-04T07:38:49Z +
-ipamconfigs.crd.projectcalico.org                     2022-09-04T07:38:49Z +
-ipamhandles.crd.projectcalico.org                     2022-09-04T07:38:50Z +
-ippools.crd.projectcalico.org                         2022-09-04T07:38:50Z +
-ipreservations.crd.projectcalico.org                  2022-09-04T07:38:50Z +
-kubecontrollersconfigurations.crd.projectcalico.org   2022-09-04T07:38:50Z +
-networkpolicies.crd.projectcalico.org                 2022-09-04T07:38:50Z +
-networksets.crd.projectcalico.org                     2022-09-04T07:38:50Z +
-podmonitors.monitoring.coreos.com                     2022-12-08T16:04:14Z +
-probes.monitoring.coreos.com                          2022-12-08T16:04:14Z +
-prometheuses.monitoring.coreos.com                    2022-12-08T16:04:14Z +
-prometheusrules.monitoring.coreos.com                 2022-12-08T16:04:14Z +
-servicemonitors.monitoring.coreos.com                 2022-12-08T16:04:15Z +
-thanosrulers.monitoring.coreos.com                    2022-12-08T16:04:15Z +
-</code> +
- +
-===4.2 - Consultation des Données avec Grafana=== +
- +
-L'installation du chart helm a aussi installé **Grafana**. +
- +
-Grafana est une plate-forme de visualisation de données interactive open source, développée par Grafana Labs, qui permet aux utilisateurs de voir leurs données via des tableaux et des graphiques qui sont unifiés dans un tableau de bord (ou plusieurs tableaux de bord ) pour une interprétation et une compréhension plus faciles. +
- +
-Consultez les objets Grafana : +
- +
-<code> +
-root@kubemaster:~# kubectl get all | grep grafana +
-pod/prometheus-grafana-5d9f5d6499-f4x6t                      3/3     Running     1 (13h ago)     14h +
-service/prometheus-grafana                        ClusterIP   10.109.207.199   <none>        80/TCP                       14h +
-deployment.apps/prometheus-grafana                    1/1                1           14h +
-replicaset.apps/prometheus-grafana-5d9f5d6499                    1                       14h +
-</code> +
- +
-Vérifiez le port utilisé par Grafana : +
- +
-<code> +
-root@kubemaster:~# kubectl logs prometheus-grafana-5d9f5d6499-f4x6t -c grafana | grep HTTP +
-logger=http.server t=2022-12-08T16:16:51.215644746Z level=info msg="HTTP Server Listen" address=[::]:3000 protocol=http subUrl= socket= +
-</code> +
- +
-ainsi que le nom de l'utilisateur pour se connecter à Grafana : +
- +
-<code> +
-root@kubemaster:~# kubectl logs prometheus-grafana-5d9f5d6499-f4x6t -c grafana | grep "user=" +
-logger=sqlstore t=2022-12-08T16:16:50.536980031Z level=info msg="Created default admin" user=admin +
-</code> +
- +
-Le mot de passe par défaut de l'utilisateur **admin** peut être obtenu en consultant le contenu du fichier **[[https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/values.yaml|values.yaml]]** +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que le mot de passe est **prom-operator**. +
-</WRAP> +
- +
-Mettez en place une redirection de port : +
- +
-<code> +
-root@kubemaster:~# kubectl port-forward deployment/prometheus-grafana 3000 +
-Forwarding from 127.0.0.1:3000 -> 3000 +
-Forwarding from [::1]:3000 -> 3000 +
- +
-</code> +
- +
-Consultez maintenant la VM kubemaster en mode graphique et lancez le navigateur web. Saisissez l'URL **http://127.0.0.1:3000** et connectez-vous à Grafana : +
- +
-{{ :elearning:workbooks:kubernetes:capture_d_ecran_du_2022-12-09_06-50-22.png?direct&800 |Image}} +
- +
-Cliquez ensuite sur **Dashboards > Browse > Kubernetes / Compute Resources / Node (Pods)** : +
- +
-{{ :elearning:workbooks:kubernetes:capture_d_ecran_du_2022-12-09_06-53-05.png?direct&800 |}} +
- +
-Dernièrement, cliquez ensuite sur **Dashboards > Browse > Node Exporter / Nodes** :  +
- +
-{{ :elearning:workbooks:kubernetes:capture_d_ecran_du_2022-12-09_07-06-14.png?direct&800 |}} +
- +
-===4.3 - Consultation des Alertes avec le Web UI de Prometheus=== +
- +
-Pour consultez le Web UI de Prometheus, mettez en place une redirection de port : +
- +
-<code> +
-root@kubemaster:~# kubectl port-forward prometheus-prometheus-kube-prometheus-prometheus-0 9090 +
-Forwarding from 127.0.0.1:9090 -> 9090 +
-Forwarding from [::1]:9090 -> 9090 +
-</code> +
- +
-Retournez dans l'interface graphique de la VM kubemaster et saisissez l'URL **http://127.0.0.1:9090** : +
- +
-{{ :elearning:workbooks:kubernetes:capture_d_ecran_du_2022-12-09_07-13-13.png?direct&800 |}} +
- +
-Pour consultez la liste des alertes, cliquez sur le lien Alerts dans le menu en haut de la page : +
- +
-{{ :elearning:workbooks:kubernetes:capture_d_ecran_du_2022-12-09_07-14-08.png?direct&800 |}} +
- +
-=====Harbor===== +
- +
-**Harbor** est un registre open source qui : +
- +
-  * sécurise les artefacts (images) avec des politiques +
-  * utilise un contrôle d'accès basé sur les rôles +
-  * garantit que les images sont analysées et exemptes de vulnérabilités +
-  * signe les images comme fiables. +
- +
-====LAB #5 - Installation et Configuration de Harbor==== +
- +
-===5.1 - Installation de Docker et de Docker Compose=== +
- +
-Connectez-vous à votre instance de Debian11 en tant que trainee au 10.0.2.46 puis devenez l'utilisateur **root**. +
- +
-Installez les dépendances de Docker : +
- +
-<code> +
-root@debian11:~# apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common +
-</code> +
- +
-Téléchargez la clef GPG officielle de docker : +
- +
-<code> +
-root@debian11:~# curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - +
-OK +
-</code> +
- +
-Ajoutez le dépôt stable de docker : +
- +
-<code> +
-root@debian11:~# add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" +
-</code> +
- +
-Installez maintenant **docker-ce** : +
- +
-<code> +
-root@debian11:~# apt-get install docker-ce lvm2 libdevmapper-dev +
-</code> +
- +
-Téléchargez docker-compose : +
- +
-<code> +
-root@debian11:~#  wget https://github.com/docker/compose/releases/download/v2.14.0/docker-compose-linux-x86_64 +
-</code> +
- +
-Rendez docker-compose exécutable et déplacez-le dans le répertoire **/usr/bin:** : +
- +
-<code> +
-root@debian11:~# chmod +x docker-compose-linux-x86_64 +
- +
-root@debian11:~# mv docker-compose-linux-x86_64 /usr/bin/docker-compose +
-</code> +
- +
-===5.2 - Installation de Harbor=== +
- +
-Téléchargez Harbor : +
- +
-<code> +
-root@debian11:~# wget https://github.com/goharbor/harbor/releases/download/v2.6.2/harbor-offline-installer-v2.6.2.tgz +
-</code> +
- +
-Désarchivez Harbor : +
- +
-<code> +
-root@debian11:~# tar xvzf harbor-offline-installer*.tgz +
-harbor/harbor.v2.6.2.tar.gz +
-harbor/prepare +
-harbor/LICENSE +
-harbor/install.sh +
-harbor/common.sh +
-harbor/harbor.yml.tmpl +
-</code> +
- +
-Placez-vous dans le répertoire **harbor** et copiez le fichier **harbor.yml.tmpl** vers **harbor.yml** : +
- +
-<code> +
-root@debian11:~# cd harbor/ +
- +
-root@debian11:~/harbor# cp harbor.yml.tmpl harbor.yml +
-</code> +
- +
-Créez le fichier **/etc/docker/daemon.json** afin de configurer Docker pour l'utilisation du dépôt non-sécurisé : +
- +
-<code> +
-root@debian11:~/harbor# vi /etc/docker/daemon.json +
-root@debian11:~/harbor# cat /etc/docker/daemon.json +
-+
-"insecure-registries" : ["10.0.2.46:5000", "0.0.0.0"+
-+
-</code> +
- +
-Modifiez maintenant l'entrée **hostname** du fichier **harbor/harbor.yml** et commentez la section concernant les connexions https : +
- +
-<code> +
-root@debian11:~/harbor# vi harbor.yml +
-root@debian11:~/harbor# head -n 20 harbor.yml +
-# Configuration file of Harbor +
- +
-# The IP address or hostname to access admin UI and registry service. +
-# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. +
-hostname: 10.0.2.46  +
- +
-# http related config +
-http: +
-  # port for http, default is 80. If https enabled, this port will redirect to https port +
-  port: 80 +
- +
-# https related config +
-# https: +
-  # https port for harbor, default is 443 +
-  # port: 443 +
-  # The path of cert and key files for nginx +
-  # certificate: /your/certificate/path +
-  # private_key: /your/private/key/path +
- +
-# # Uncomment following will enable tls communication between all harbor components +
-</code> +
- +
-Constatez la présence du script **install.sh** dans le répertoire **harbor/** : +
- +
-<code> +
-root@debian11:~/harbor# ls +
-common.sh             harbor.yml       install.sh  prepare +
-harbor.v2.6.2.tar.gz  harbor.yml.tmpl  LICENSE +
-</code> +
- +
-Désactivez le service nginx dans la VM Debian11 : +
- +
-<code> +
-root@debian11:~/harbor# systemctl stop nginx +
- +
-root@debian11:~/harbor# systemctl disable nginx +
-</code> +
- +
-Installez maintenant Harbor avec le support pour **Chart Museum** et **Trivy** : +
- +
-<code> +
-root@debian11:~/harbor# ./install.sh --with-trivy --with-chartmuseum +
- +
-[Step 0]: checking if docker is installed ... +
- +
-Note: docker version: 20.10.21 +
- +
-[Step 1]: checking docker-compose is installed ... +
- +
-Note: docker-compose version: 2.14.0 +
- +
-[Step 2]: loading Harbor images ... +
-... +
-[Step 3]: preparing environment ... +
-... +
-[Step 4]: preparing harbor configs ... +
-... +
-[Step 5]: starting Harbor ... +
-➜  +
-    Chartmusuem will be deprecated as of Harbor v2.6.0 and start to be removed in v2.8.0 or later. +
-    Please see discussion here for more details. https://github.com/goharbor/harbor/discussions/15057 +
-[+] Running 13/13 +
- ⠿ Network harbor_harbor              Created                                                                                                                                                                0.2s +
- ⠿ Network harbor_harbor-chartmuseum  Created                                                                                                                                                                0.3s +
- ⠿ Container harbor-log               Started                                                                                                                                                               14.1s +
- ⠿ Container registry                 Started                                                                                                                                                               15.8s +
- ⠿ Container registryctl              Started                                                                                                                                                               18.1s +
- ⠿ Container harbor-portal            Started                                                                                                                                                               18.1s +
- ⠿ Container redis                    Started                                                                                                                                                               16.9s +
- ⠿ Container chartmuseum              Started                                                                                                                                                               15.7s +
- ⠿ Container harbor-db                Started                                                                                                                                                               16.4s +
- ⠿ Container trivy-adapter            Started                                                                                                                                                               14.8s +
- ⠿ Container harbor-core              Started                                                                                                                                                               15.0s +
- ⠿ Container nginx                    Started                                                                                                                                                               13.4s +
- ⠿ Container harbor-jobservice        Started                                                                                                                                                               13.2s +
-✔ ----Harbor has been installed and started successfully.---- +
-</code> +
- +
-Constatez les conteneurs créés par l'installation : +
- +
-<code> +
-root@debian11:~/harbor# docker ps -a +
-CONTAINER ID   IMAGE                                  COMMAND                  CREATED          STATUS                    PORTS                                   NAMES +
-b8e4e3934c7a   goharbor/harbor-jobservice:v2.6.2      "/harbor/entrypoint.…"   15 minutes ago   Up 15 minutes (healthy)                                           harbor-jobservice +
-579b4b43877f   goharbor/nginx-photon:v2.6.2           "nginx -g 'daemon of…"   15 minutes ago   Up 15 minutes (healthy)   0.0.0.0:80->8080/tcp, :::80->8080/tcp   nginx +
-57c8697b4d39   goharbor/trivy-adapter-photon:v2.6.2   "/home/scanner/entry…"   16 minutes ago   Up 15 minutes (healthy)                                           trivy-adapter +
-ce4823c62886   goharbor/harbor-core:v2.6.2            "/harbor/entrypoint.…"   16 minutes ago   Up 15 minutes (healthy)                                           harbor-core +
-57992f8f573a   goharbor/chartmuseum-photon:v2.6.2     "./docker-entrypoint…"   16 minutes ago   Up 15 minutes (healthy)                                           chartmuseum +
-e2df863f7009   goharbor/harbor-portal:v2.6.2          "nginx -g 'daemon of…"   16 minutes ago   Up 15 minutes (healthy)                                           harbor-portal +
-3e7e2093a4a2   goharbor/harbor-db:v2.6.2              "/docker-entrypoint.…"   16 minutes ago   Up 15 minutes (healthy)                                           harbor-db +
-406aa384c742   goharbor/redis-photon:v2.6.2           "redis-server /etc/r…"   16 minutes ago   Up 15 minutes (healthy)                                           redis +
-ddf08dcc8390   goharbor/harbor-registryctl:v2.6.2     "/home/harbor/start.…"   16 minutes ago   Up 15 minutes (healthy)                                           registryctl +
-b5cedbab739d   goharbor/registry-photon:v2.6.2        "/home/harbor/entryp…"   16 minutes ago   Up 15 minutes (healthy)                                           registry +
-13665ace83fd   goharbor/harbor-log:v2.6.2             "/bin/sh -c /usr/loc…"   16 minutes ago   Up 15 minutes (healthy)   127.0.0.1:1514->10514/tcp               harbor-log +
-</code> +
- +
-Ainsi que les images téléchargées : +
- +
-<code> +
-root@debian11:~/harbor# docker images +
-REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE +
-goharbor/harbor-exporter        v2.6.2    ae230e335853   4 weeks ago   95.4MB +
-goharbor/chartmuseum-photon     v2.6.2    be361eee8a36   4 weeks ago   225MB +
-goharbor/redis-photon           v2.6.2    84fa3669bb10   4 weeks ago   154MB +
-goharbor/trivy-adapter-photon   v2.6.2    beef2527c7b2   4 weeks ago   441MB +
-goharbor/notary-server-photon   v2.6.2    b43e7c963f06   4 weeks ago   112MB +
-goharbor/notary-signer-photon   v2.6.2    4e9982286316   4 weeks ago   109MB +
-goharbor/harbor-registryctl     v2.6.2    d403d4e0f990   4 weeks ago   137MB +
-goharbor/registry-photon        v2.6.2    596e445b18f0   4 weeks ago   77.5MB +
-goharbor/nginx-photon           v2.6.2    cbbdf28947a5   4 weeks ago   154MB +
-goharbor/harbor-log             v2.6.2    3ce902023f73   4 weeks ago   161MB +
-goharbor/harbor-jobservice      v2.6.2    05791a75c8b8   4 weeks ago   250MB +
-goharbor/harbor-core            v2.6.2    484e2a64616d   4 weeks ago   213MB +
-goharbor/harbor-portal          v2.6.2    932297030d4e   4 weeks ago   162MB +
-goharbor/harbor-db              v2.6.2    351b19e366cb   4 weeks ago   225MB +
-goharbor/prepare                v2.6.2    eecc993c7643   4 weeks ago   164MB +
-</code> +
- +
-Constatez maintenant les réseaux créés par l'installation : +
- +
-<code> +
-root@debian11:~/harbor# docker network ls +
-NETWORK ID     NAME                        DRIVER    SCOPE +
-c080bf952007   bridge                      bridge    local +
-380a2401fb01   harbor_harbor               bridge    local +
-b5d0cc4623f6   harbor_harbor-chartmuseum   bridge    local +
-3e48278ae275   host                        host      local +
-4dd9174d8e25   none                        null      local +
-</code> +
- +
-===5.3 - Création d'un Nouveau Projet=== +
- +
-Connectez-vous à votre gateway en RDP et ouvrez le navigateur web. Allez à l'URL http://10.0.2.46 : +
- +
-{{ :elearning:workbooks:kubernetes:harbor.png?direct&800 |}} +
- +
-Connectez-vous avec les identifiants par défaut - admin / Harbor12345 : +
- +
-{{ :elearning:workbooks:kubernetes:harbor2.png?direct&800 |}} +
- +
-Harbor est organisé autour de **Projets**. Dans un projet se trouvent des **Dépôts** ou //Repositories//. Le projet nous permet de configurer le RBAC. Créez donc un nouveau projet en cliquant sur le bouton **New Project** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor03.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que la valeur de **-1** indique que le projet a un quota de disque **illimité**. +
-</WRAP> +
- +
-Cliquez sur le bouton **OK** puis cliquez sur le nom **myproject** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor04.png?direct&800 |}} +
- +
-===5.4 - Création d'un Dépôt=== +
- +
-Téléchargez maintenant l'image de **hello-world** à partir de docker.io : +
- +
-<code> +
-root@debian11:~/harbor# docker pull hello-world +
-Using default tag: latest +
-latest: Pulling from library/hello-world +
-2db29710123e: Pull complete  +
-Digest: sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af +
-Status: Downloaded newer image for hello-world:latest +
-docker.io/library/hello-world:latest +
-</code> +
- +
-Retournez dans Harbor et cliquez sur **PUSH COMMAND** à droite. Dans la liste des commandes vous vous apercevrez la commande pour //tagger// une image pour le porjet **myproject** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor05.png?direct&800 |}} +
- +
-Copiez cette commande puis modifiez la ainsi : +
- +
-<code> +
-root@debian11:~/harbor# docker tag hello-world 10.0.2.46:80/myproject/hello-world +
- +
-root@debian11:~/harbor# docker images +
-REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE +
-goharbor/harbor-exporter             v2.6.2    ae230e335853   4 weeks ago     95.4MB +
-goharbor/chartmuseum-photon          v2.6.2    be361eee8a36   4 weeks ago     225MB +
-goharbor/redis-photon                v2.6.2    84fa3669bb10   4 weeks ago     154MB +
-goharbor/trivy-adapter-photon        v2.6.2    beef2527c7b2   4 weeks ago     441MB +
-goharbor/notary-server-photon        v2.6.2    b43e7c963f06   4 weeks ago     112MB +
-goharbor/notary-signer-photon        v2.6.2    4e9982286316   4 weeks ago     109MB +
-goharbor/harbor-registryctl          v2.6.2    d403d4e0f990   4 weeks ago     137MB +
-goharbor/registry-photon             v2.6.2    596e445b18f0   4 weeks ago     77.5MB +
-goharbor/nginx-photon                v2.6.2    cbbdf28947a5   4 weeks ago     154MB +
-goharbor/harbor-log                  v2.6.2    3ce902023f73   4 weeks ago     161MB +
-goharbor/harbor-jobservice           v2.6.2    05791a75c8b8   4 weeks ago     250MB +
-goharbor/harbor-core                 v2.6.2    484e2a64616d   4 weeks ago     213MB +
-goharbor/harbor-portal               v2.6.2    932297030d4e   4 weeks ago     162MB +
-goharbor/harbor-db                   v2.6.2    351b19e366cb   4 weeks ago     225MB +
-goharbor/prepare                     v2.6.2    eecc993c7643   4 weeks ago     164MB +
-hello-world                          latest    feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/hello-world   latest    feb5d9fea6a5   14 months ago   13.3kB +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez la spécification du port **80**. Sans spécifier le port le port par défaut **443** serait utilisé. +
-</WRAP> +
- +
-Connectez-vous à Harbor : +
- +
-<code> +
-root@debian11:~/harbor# docker login 10.0.2.46:80 +
-Username: admin +
-Password: Harbor12345 +
-Error response from daemon: Get "https://10.0.2.46:80/v2/": http: server gave HTTP response to HTTPS client +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez l'erreur **Error response from daemon: Get "https://10.0.2.46:80/v2/": http: server gave HTTP response to HTTPS client**. Ceci est du à la configuration de docker dans le fichier **/etc/docker/daemon.json** où le port 80 n'a pas été spécifié : +
-</WRAP> +
- +
-<code> +
-root@debian11:~/harbor# cat /etc/docker/daemon.json +
-+
-"insecure-registries" : ["10.0.2.46:5000", "0.0.0.0"+
-+
-</code> +
- +
-Modifiez donc ce fichier : +
- +
-<code> +
-root@debian11:~/harbor# vi /etc/docker/daemon.json +
-root@debian11:~/harbor# cat /etc/docker/daemon.json +
-+
-"insecure-registries" : ["10.0.2.46:5000", "10.0.2.46:80", "0.0.0.0"+
-+
-</code> +
- +
-Redémarrez le service docker : +
- +
-<code> +
-root@debian11:~/harbor# systemctl restart docker +
-root@debian11:~/harbor# systemctl status docker +
-● docker.service - Docker Application Container Engine +
-     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) +
-     Active: active (running) since Sun 2022-12-11 08:57:36 CET; 20s ago +
-TriggeredBy: ● docker.socket +
-       Docs: https://docs.docker.com +
-   Main PID: 487567 (dockerd) +
-      Tasks: 44 +
-     Memory: 56.2M +
-        CPU: 2.275s +
-     CGroup: /system.slice/docker.service +
-             ├─487567 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock +
-             ├─487820 /usr/bin/docker-proxy -proto tcp -host-ip 127.0.0.1 -host-port 1514 -contain> +
-             ├─488485 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-i> +
-             └─488494 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 80 -container-ip 172> +
- +
-Dec 11 08:57:14 debian11 dockerd[487567]: time="2022-12-11T08:57:14.186814789+01:00" level=info ms> +
-Dec 11 08:57:14 debian11 dockerd[487567]: time="2022-12-11T08:57:14.571406314+01:00" level=info ms> +
-Dec 11 08:57:19 debian11 dockerd[487567]: time="2022-12-11T08:57:19.175392656+01:00" level=info ms> +
-Dec 11 08:57:21 debian11 dockerd[487567]: time="2022-12-11T08:57:21.464318214+01:00" level=error m> +
-Dec 11 08:57:21 debian11 dockerd[487567]: time="2022-12-11T08:57:21.464360074+01:00" level=error m> +
-Dec 11 08:57:31 debian11 dockerd[487567]: time="2022-12-11T08:57:31.545302044+01:00" level=info ms> +
-Dec 11 08:57:35 debian11 dockerd[487567]: time="2022-12-11T08:57:35.749031343+01:00" level=info ms> +
-Dec 11 08:57:36 debian11 dockerd[487567]: time="2022-12-11T08:57:36.596800068+01:00" level=info ms> +
-</code> +
- +
-Maintenant redémarrez Harbor : +
- +
-<code> +
-root@debian11:~/harbor# docker-compose down -v +
-[+] Running 13/13 +
- ⠿ Container harbor-jobservice        Removed                                                 5.7s +
- ⠿ Container nginx                    Removed                                                 5.8s +
- ⠿ Container chartmuseum              Removed                                                 0.2s +
- ⠿ Container trivy-adapter            Removed                                                 5.8s +
- ⠿ Container registryctl              Removed                                                13.9s +
- ⠿ Container harbor-portal            Removed                                                 4.7s +
- ⠿ Container harbor-core              Removed                                                 5.3s +
- ⠿ Container harbor-db                Removed                                                 8.9s +
- ⠿ Container registry                 Removed                                                 4.0s +
- ⠿ Container redis                    Removed                                                 8.7s +
- ⠿ Container harbor-log               Removed                                                14.2s +
- ⠿ Network harbor_harbor              Removed                                                 0.8s +
- ⠿ Network harbor_harbor-chartmuseum  Removed                                                 0.6s +
- +
-root@debian11:~/harbor# docker-compose up -d +
-[+] Running 13/13 +
- ⠿ Network harbor_harbor              Created                                                 0.4s +
- ⠿ Network harbor_harbor-chartmuseum  Created                                                 0.3s +
- ⠿ Container harbor-log               Started                                                13.5s +
- ⠿ Container harbor-db                Started                                                12.9s +
- ⠿ Container harbor-portal            Started                                                14.8s +
- ⠿ Container chartmuseum              Started                                                14.3s +
- ⠿ Container redis                    Started                                                16.8s +
- ⠿ Container registryctl              Started                                                16.3s +
- ⠿ Container registry                 Started                                                15.2s +
- ⠿ Container trivy-adapter            Started                                                14.0s +
- ⠿ Container harbor-core              Started                                                14.9s +
- ⠿ Container harbor-jobservice        Started                                                14.8s +
- ⠿ Container nginx                    Started                                                15.0s +
-</code> +
- +
-Connectez-vous à Harbor : +
- +
-<code> +
-root@debian11:~/harbor# docker login 10.0.2.46:80 +
-Username: admin +
-Password:  +
-WARNING! Your password will be stored unencrypted in /root/.docker/config.json. +
-Configure a credential helper to remove this warning. See +
-https://docs.docker.com/engine/reference/commandline/login/#credentials-store +
- +
-Login Succeeded +
-</code> +
- +
-Les coordonnées de connexion sont stockées dans le fichier **/root/.docker/config.json** : +
- +
-<code> +
-root@debian11:~/harbor# cat /root/.docker/config.json +
-+
-        "auths":+
-                "10.0.2.46:80":+
-                        "auth": "YWRtaW46SGFyYm9yMTIzNDU=" +
-                } +
-        } +
-}root@debian11:~/harbor# +
-</code> +
- +
-De cette façon, lors des logins futur, docker ne demandera ni le nom de l'utilisateur, ni le mot de passe : +
- +
-<code> +
-root@debian11:~/harbor# docker logout +
-Removing login credentials for https://index.docker.io/v1/ +
- +
-root@debian11:~/harbor# docker login 10.0.2.46:80 +
-Authenticating with existing credentials... +
-WARNING! Your password will be stored unencrypted in /root/.docker/config.json. +
-Configure a credential helper to remove this warning. See +
-https://docs.docker.com/engine/reference/commandline/login/#credentials-store +
- +
-Login Succeeded +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/harbor# docker push 10.0.2.46:80/myproject/hello-world +
-Using default tag: latest +
-The push refers to repository [10.0.2.46:80/myproject/hello-world] +
-e07ee1baac5f: Pushed  +
-latest: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525 +
-</code> +
- +
-Retournez à Harbor et constatez la présence du dépôt : +
- +
-{{ :elearning:workbooks:kubernetes:harbor06.png?direct&800 |}} +
- +
-Cliquez sur le nom du dépôt et constatez son contenu : +
- +
-{{ :elearning:workbooks:kubernetes:harbor07.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que l'image stocké dans Harbor est appeléé un **Artefact**. +
-</WRAP> +
- +
-===5.5 - Pousser des Images Supplémentaires=== +
- +
-Modifiez le tag de l'image hello-world : +
- +
-<code> +
-root@debian11:~/harbor# docker tag hello-world 10.0.2.46:80/myproject/hello-world:1.0 +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/harbor# docker push 10.0.2.46:80/myproject/hello-world:1.0 +
-The push refers to repository [10.0.2.46:80/myproject/hello-world] +
-e07ee1baac5f: Layer already exists  +
-1.0: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525 +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que la valeur du SHA256 est indentique au push précédent. De cette façon Docker n'a pas poussé l'image mais seulement le nouveau tag. +
-</WRAP> +
- +
-Constatez le résultat dans Harbor : +
- +
-{{ :elearning:workbooks:kubernetes:harbor08.png?direct&800 |}} +
- +
-Téléchargez maintenant l'image de **alpine** à partir de docker.io : +
- +
-<code> +
-root@debian11:~/harbor# docker pull alpine +
-Using default tag: latest +
-latest: Pulling from library/alpine +
-c158987b0551: Pull complete  +
-Digest: sha256:8914eb54f968791faf6a8638949e480fef81e697984fba772b3976835194c6d4 +
-Status: Downloaded newer image for alpine:latest +
-docker.io/library/alpine:latest +
-</code> +
- +
-Modifiez le tag de l'image alpine : +
- +
-<code> +
-root@debian11:~/harbor# docker tag alpine 10.0.2.46:80/myproject/alpine +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/harbor# docker push 10.0.2.46:80/myproject/alpine +
-Using default tag: latest +
-The push refers to repository [10.0.2.46:80/myproject/alpine] +
-ded7a220bb05: Pushed  +
-latest: digest: sha256:c0d488a800e4127c334ad20d61d7bc21b4097540327217dfab52262adc02380c size: 528 +
-</code> +
- +
-Constatez le résultat dans Harbor : +
- +
-{{ :elearning:workbooks:kubernetes:harbor09.png?direct&800 |}} +
- +
-===5.6 - Travailler avec des Artefacts=== +
- +
-Cliquez sur **Projects > myproject > myproject/hello-world** puis sur le nom de l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor10.png?direct&800 |}} +
- +
-Cliquez ensuite sur le bouton **ADD TAG** et ajoutez le tag **anothertag** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor11.png?direct&800 |}} +
- +
-Sur la ligne 1.0 et dans la colonne **Pull Command**, cliquez sur l'icône : +
- +
-{{ :elearning:workbooks:kubernetes:harbor12.png?direct&800 |}} +
- +
-Revenez à l'interface en ligne de commande et consultez la liste des images :  +
- +
-<code> +
-REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE +
-10.0.2.46:80/myproject/alpine        latest    49176f190c7e   2 weeks ago     7.05MB +
-alpine                               latest    49176f190c7e   2 weeks ago     7.05MB +
-goharbor/harbor-exporter             v2.6.2    ae230e335853   4 weeks ago     95.4MB +
-goharbor/chartmuseum-photon          v2.6.2    be361eee8a36   4 weeks ago     225MB +
-goharbor/redis-photon                v2.6.2    84fa3669bb10   4 weeks ago     154MB +
-goharbor/trivy-adapter-photon        v2.6.2    beef2527c7b2   4 weeks ago     441MB +
-goharbor/notary-server-photon        v2.6.2    b43e7c963f06   4 weeks ago     112MB +
-goharbor/notary-signer-photon        v2.6.2    4e9982286316   4 weeks ago     109MB +
-goharbor/harbor-registryctl          v2.6.2    d403d4e0f990   4 weeks ago     137MB +
-goharbor/registry-photon             v2.6.2    596e445b18f0   4 weeks ago     77.5MB +
-goharbor/nginx-photon                v2.6.2    cbbdf28947a5   4 weeks ago     154MB +
-goharbor/harbor-log                  v2.6.2    3ce902023f73   4 weeks ago     161MB +
-goharbor/harbor-jobservice           v2.6.2    05791a75c8b8   4 weeks ago     250MB +
-goharbor/harbor-core                 v2.6.2    484e2a64616d   4 weeks ago     213MB +
-goharbor/harbor-portal               v2.6.2    932297030d4e   4 weeks ago     162MB +
-goharbor/harbor-db                   v2.6.2    351b19e366cb   4 weeks ago     225MB +
-goharbor/prepare                     v2.6.2    eecc993c7643   4 weeks ago     164MB +
-10.0.2.46:80/myproject/hello-world   1.0       feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/hello-world   latest    feb5d9fea6a5   14 months ago   13.3kB +
-hello-world                          latest    feb5d9fea6a5   14 months ago   13.3kB +
-</code> +
- +
-Supprimez l'image **10.0.2.46:80/myproject/hello-world:1.0** : +
- +
-<code> +
-root@debian11:~/harbor# docker image rm 10.0.2.46:80/myproject/hello-world:1.0 +
-Untagged: 10.0.2.46:80/myproject/hello-world:1.0 +
-</code> +
- +
-Consultez la liste des images de nouveau :  +
- +
-<code> +
-root@debian11:~/harbor# docker images +
-REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE +
-10.0.2.46:80/myproject/alpine        latest    49176f190c7e   2 weeks ago     7.05MB +
-alpine                               latest    49176f190c7e   2 weeks ago     7.05MB +
-goharbor/harbor-exporter             v2.6.2    ae230e335853   4 weeks ago     95.4MB +
-goharbor/chartmuseum-photon          v2.6.2    be361eee8a36   4 weeks ago     225MB +
-goharbor/redis-photon                v2.6.2    84fa3669bb10   4 weeks ago     154MB +
-goharbor/trivy-adapter-photon        v2.6.2    beef2527c7b2   4 weeks ago     441MB +
-goharbor/notary-server-photon        v2.6.2    b43e7c963f06   4 weeks ago     112MB +
-goharbor/notary-signer-photon        v2.6.2    4e9982286316   4 weeks ago     109MB +
-goharbor/harbor-registryctl          v2.6.2    d403d4e0f990   4 weeks ago     137MB +
-goharbor/registry-photon             v2.6.2    596e445b18f0   4 weeks ago     77.5MB +
-goharbor/nginx-photon                v2.6.2    cbbdf28947a5   4 weeks ago     154MB +
-goharbor/harbor-log                  v2.6.2    3ce902023f73   4 weeks ago     161MB +
-goharbor/harbor-jobservice           v2.6.2    05791a75c8b8   4 weeks ago     250MB +
-goharbor/harbor-core                 v2.6.2    484e2a64616d   4 weeks ago     213MB +
-goharbor/harbor-portal               v2.6.2    932297030d4e   4 weeks ago     162MB +
-goharbor/harbor-db                   v2.6.2    351b19e366cb   4 weeks ago     225MB +
-goharbor/prepare                     v2.6.2    eecc993c7643   4 weeks ago     164MB +
-10.0.2.46:80/myproject/hello-world   latest    feb5d9fea6a5   14 months ago   13.3kB +
-hello-world                          latest    feb5d9fea6a5   14 months ago   13.3kB +
-</code> +
- +
-Téléchargez maintenant l'image de **10.0.2.46:80/myproject/hello-world:1.0** à partir de Harbor : +
- +
-<code> +
-root@debian11:~/harbor# docker pull 10.0.2.46:80/myproject/hello-world:1.0 +
-1.0: Pulling from myproject/hello-world +
-Digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 +
-Status: Downloaded newer image for 10.0.2.46:80/myproject/hello-world:1.0 +
-10.0.2.46:80/myproject/hello-world:1.0 +
-</code>  +
- +
-Lister maintenant les images : +
- +
-<code> +
-root@debian11:~/harbor# docker images +
-REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE +
-10.0.2.46:80/myproject/alpine        latest    49176f190c7e   2 weeks ago     7.05MB +
-alpine                               latest    49176f190c7e   2 weeks ago     7.05MB +
-goharbor/harbor-exporter             v2.6.2    ae230e335853   4 weeks ago     95.4MB +
-goharbor/chartmuseum-photon          v2.6.2    be361eee8a36   4 weeks ago     225MB +
-goharbor/redis-photon                v2.6.2    84fa3669bb10   4 weeks ago     154MB +
-goharbor/trivy-adapter-photon        v2.6.2    beef2527c7b2   4 weeks ago     441MB +
-goharbor/notary-server-photon        v2.6.2    b43e7c963f06   4 weeks ago     112MB +
-goharbor/notary-signer-photon        v2.6.2    4e9982286316   4 weeks ago     109MB +
-goharbor/harbor-registryctl          v2.6.2    d403d4e0f990   4 weeks ago     137MB +
-goharbor/registry-photon             v2.6.2    596e445b18f0   4 weeks ago     77.5MB +
-goharbor/nginx-photon                v2.6.2    cbbdf28947a5   4 weeks ago     154MB +
-goharbor/harbor-log                  v2.6.2    3ce902023f73   4 weeks ago     161MB +
-goharbor/harbor-jobservice           v2.6.2    05791a75c8b8   4 weeks ago     250MB +
-goharbor/harbor-core                 v2.6.2    484e2a64616d   4 weeks ago     213MB +
-goharbor/harbor-portal               v2.6.2    932297030d4e   4 weeks ago     162MB +
-goharbor/harbor-db                   v2.6.2    351b19e366cb   4 weeks ago     225MB +
-goharbor/prepare                     v2.6.2    eecc993c7643   4 weeks ago     164MB +
-hello-world                          latest    feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/hello-world   1.0       feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/hello-world   latest    feb5d9fea6a5   14 months ago   13.3kB +
-</code> +
- +
-Modifiez le tag de l'image téléchargée : +
- +
-<code> +
-root@debian11:~/harbor# docker tag hello-world 10.0.2.46:80/myproject/production:latest +
- +
-root@debian11:~/harbor# docker images +
-REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE +
-10.0.2.46:80/myproject/alpine        latest    49176f190c7e   2 weeks ago     7.05MB +
-alpine                               latest    49176f190c7e   2 weeks ago     7.05MB +
-goharbor/harbor-exporter             v2.6.2    ae230e335853   4 weeks ago     95.4MB +
-goharbor/chartmuseum-photon          v2.6.2    be361eee8a36   4 weeks ago     225MB +
-goharbor/redis-photon                v2.6.2    84fa3669bb10   4 weeks ago     154MB +
-goharbor/trivy-adapter-photon        v2.6.2    beef2527c7b2   4 weeks ago     441MB +
-goharbor/notary-server-photon        v2.6.2    b43e7c963f06   4 weeks ago     112MB +
-goharbor/notary-signer-photon        v2.6.2    4e9982286316   4 weeks ago     109MB +
-goharbor/harbor-registryctl          v2.6.2    d403d4e0f990   4 weeks ago     137MB +
-goharbor/registry-photon             v2.6.2    596e445b18f0   4 weeks ago     77.5MB +
-goharbor/nginx-photon                v2.6.2    cbbdf28947a5   4 weeks ago     154MB +
-goharbor/harbor-log                  v2.6.2    3ce902023f73   4 weeks ago     161MB +
-goharbor/harbor-jobservice           v2.6.2    05791a75c8b8   4 weeks ago     250MB +
-goharbor/harbor-core                 v2.6.2    484e2a64616d   4 weeks ago     213MB +
-goharbor/harbor-portal               v2.6.2    932297030d4e   4 weeks ago     162MB +
-goharbor/harbor-db                   v2.6.2    351b19e366cb   4 weeks ago     225MB +
-goharbor/prepare                     v2.6.2    eecc993c7643   4 weeks ago     164MB +
-10.0.2.46:80/myproject/hello-world   1.0       feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/hello-world   latest    feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/production    latest    feb5d9fea6a5   14 months ago   13.3kB +
-hello-world                          latest    feb5d9fea6a5   14 months ago   13.3kB +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/harbor# docker push 10.0.2.46:80/myproject/production:latest +
-The push refers to repository [10.0.2.46:80/myproject/production] +
-e07ee1baac5f: Mounted from myproject/hello-world  +
-latest: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525 +
-</code> +
- +
-===5.7 - Copier un Artefact d'un Projet vers un autre Projet=== +
- +
-Commencez par créer un autre projet appelé **devtest** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor14.png?direct&800 |}} +
- +
-Cliquez sur **Projects > myproject > myproject/hello-world** et cochez l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor15.png?direct&800 |}} +
- +
-Cliquez ensuite sur **ACTIONS > Copy** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor16.png?direct&800 |}} +
- +
-Renseignez les champs et cliquez sur le bouton **CONFIRM** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor17.png?direct&800 |}} +
- +
-Cliquez sur **Projects > devtest** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor18.png?direct&800 |}} +
- +
-Cliquez ensuite sur **devtest/performancetest** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor19.png?direct&800 |}} +
- +
-===5.8 - Suppression d'un Artefact, d'un Dépôt et d'un Projet=== +
- +
-Sélectionnez l'Artefact puis cliquez sur **ACTIONS > Delete** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor20.png?direct&800 |}} +
- +
-Confirmez la suppression en cliquant sur le bouton **CONFIRM** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor21.png?direct&800 |}} +
- +
-Cliquez sur **devtest** et cochez **devtest/Performancetest** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor22.png?direct&800 |}} +
- +
-Cliquez sur le bouton **DELETE** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor23.png?direct&800 |}} +
- +
-Confirmez la suppression en cliquant sur le bouton **CONFIRM** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor24.png?direct&800 |}} +
- +
-Cliquez sur **Projects** puis cochez **devtest** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor25.png?direct&800 |}} +
- +
-Cliquez sur **ACTION** puis sur **Delete** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor26.png?direct&800 |}} +
- +
-Confirmez la suppression en cliquant sur le bouton **CONFIRM** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor27.png?direct&800 |}} +
- +
-===5.8 - Utilisation de Labels=== +
- +
-Harbor gère des **Labels** ou étiquettes. Ces étiquettes peuvent être globales ou spécifiques à un Projet. Quand une étiquette est spécifique, celle-ci est utilisée pour marquer les Artefacts pour une utilisation spécifique. Les étiguettes globales ne peuvent être gérées que par l'Administrateur de Harbor. +
- +
-Cliquez sur **Labels** dans Harbor : +
- +
-{{ :elearning:workbooks:kubernetes:harbor28.png?direct&800 |}} +
- +
-Cliquez sur **NEW LABEL** et créez les deux étiquettes suivantes : +
- +
-  * **gtested** - global tested +
-  * **gprodready** global production ready +
- +
-{{ :elearning:workbooks:kubernetes:harbor29.png?direct&800 |}} +
- +
-Cliquez sur **Projects > myproject > myproject/hello-world** puis sélectionnez l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor30.png?direct&800 |}} +
- +
-Cliquez sur **ACTIONS** > **Add Labels** puis sélectionnez **gtested** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor31.png?direct&800 |}} +
- +
-Cliquez maintenant sur **myproject > Labels** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor32.png?direct&800 |}} +
- +
-Cliquez ensuite sur **NEW LABEL** et créez ensuite une étiguette spécifique au projet appelé **myproject-deploy** ayant une description **myproject label** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor33.png?direct&800 |}} +
- +
-Cliquez sur **Repositories > myproject/hello-world** et sélectionnez l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor34.png?direct&800 |}} +
- +
-Cliquez sur **ACTIONS** > **Add Labels** et sélectionnez l'étiquette **myproject-deploy** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor35.png?direct&800 |}} +
- +
-Pour visualiser toutes les étiguettes, cliquez sur les 3 points à droite de **gtested** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor36.png?direct&800 |}} +
- +
-Cliquez sur **Projects > NEW PROJECT** et créez le projet **project2** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor37.png?direct&800 |}} +
- +
-Cliquez sur **project2 > Labels > NEW LABEL** et créez l'étiquette **project2label** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor38.png?direct&800 |}} +
- +
-Cliquez sur **Projects > myproject > myproject/alpine** et sélectionnez l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor39.png?direct&800 |}} +
- +
-Cliquez sur **ACTIONS** > **Add Labels** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor40.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que l'étiquette **project2label** n'est pas disponible. +
-</WRAP> +
- +
-===5.9 - Authentification et RBAC=== +
- +
-Cliquez sur **Users** puis sur **NEW USER** et creéz l'utilisateur **user3** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor41.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que pour être valide le mot de passe doit comporter une lettre Majuscule et un chiffre. +
-</WRAP> +
- +
-Sélectionnez l'utilisateur **user3** et cliquez sur le bouton **SET AS ADMIN** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor42.png?direct&800 |}} +
- +
-Cliquez sur **Projects > myproject** puis sur **Members** et **+ USER** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor43.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Pour consulter les privilèges de chaque rôle, cliquez sur **[[https://goharbor.io/docs/2.6.0/administration/managing-users/user-permissions-by-role/|ce lien]]**.  +
-</WRAP> +
- +
-Cliquez sur **OK** et sélectionnez l'utilisateur **user3** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor44.png?direct&800 |}} +
- +
-Pour modifier son rôle, cliquez sur **ACTION** et choississez le rôle désiré : +
- +
-{{ :elearning:workbooks:kubernetes:harbor45.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que le bouton **+ GROUP** est grisé. Si un Active Directory ou bien LDAP avait été configuré, Harbor pourrait lire la liste des groupes et n ous permettrait d'ajouter des utilisateurs à un des groupes.  +
-</WRAP> +
- +
-===5.10 - Utilisation d'Images Docker Personalisées=== +
- +
-Créez un répertoire nommé myDocker : +
- +
-<code> +
-root@debian11:~/harbor# cd .. +
-root@debian11:~# mkdir ~/myDocker +
-root@debian11:~# cd ~/myDocker +
-root@debian11:~/myDocker#  +
-</code> +
- +
-Créez le fichier myEntrypoint.sh : +
- +
-<code> +
-root@debian11:~/myDocker# vi myEntrypoint.sh +
-root@debian11:~/myDocker# cat myEntrypoint.sh +
-#!/bin/bash +
-if [ -z "$myVariable" ]; then +
-        echo "La variable myVariable doit être renseignée" +
-        return 1 +
-fi +
- +
-while true; +
-do +
-        echo $1 \($(date +%H:%M:%S)\); +
-        sleep "$myVariable"; +
-done +
-</code> +
- +
-Testez ce script : +
- +
-<code> +
-root@debian11:~/myDocker# myVariable=3 . ./myEntrypoint.sh salut +
-salut (16:12:59) +
-salut (16:13:02) +
-salut (16:13:05) +
-^C +
-root@debian11:~/myDocker#  +
-</code> +
- +
-Rendez ce script exécutable : +
- +
-<code> +
-root@debian11:~/myDocker# chmod u+x myEntrypoint.sh  +
-</code> +
- +
-Créez maintenant le fichier **Dockerfile** dans le répertoire **~/myDocker** : +
- +
-<code> +
-root@debian11:~/myDocker# cat Dockerfile +
-FROM centos:latest +
-MAINTAINER ittraining "infos@ittraining.io" +
-COPY myEntrypoint.sh /entrypoint.sh +
-ENV myVariable 3 +
-ENTRYPOINT ["/entrypoint.sh"+
-CMD ["mycommand"+
-</code> +
- +
-Connectez-vous à Harbor : +
- +
-<code> +
-root@debian11:~/myDocker# docker login 10.0.2.46:80 +
-Authenticating with existing credentials... +
-WARNING! Your password will be stored unencrypted in /root/.docker/config.json. +
-Configure a credential helper to remove this warning. See +
-https://docs.docker.com/engine/reference/commandline/login/#credentials-store +
- +
-Login Succeeded +
-</code> +
- +
-Générez maintenant l'image : +
- +
-<code> +
-root@debian11:~/myDocker# docker build --tag "10.0.2.46:80/myproject/mydocker:latest"+
-Sending build context to Docker daemon  3.072kB +
-Step 1/6 : FROM centos:latest +
-latest: Pulling from library/centos +
-a1d0c7532777: Pull complete  +
-Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177 +
-Status: Downloaded newer image for centos:latest +
- ---> 5d0da3dc9764 +
-Step 2/6 : MAINTAINER ittraining "infos@ittraining.io" +
- ---> Running in 7e359420ea95 +
-Removing intermediate container 7e359420ea95 +
- ---> 7ce8d150d72d +
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> c1fda8d1e43c +
-Step 4/6 : ENV myVariable 3 +
- ---> Running in edf989144c38 +
-Removing intermediate container edf989144c38 +
- ---> 628615e7003a +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"+
- ---> Running in 0490b6a50bbc +
-Removing intermediate container 0490b6a50bbc +
- ---> c2ed329815ef +
-Step 6/6 : CMD ["mycommand"+
- ---> Running in e2ecfea5be53 +
-Removing intermediate container e2ecfea5be53 +
- ---> ccb27534d7f2 +
-Successfully built ccb27534d7f2 +
-Successfully tagged 10.0.2.46:80/myproject/mydocker:latest +
- +
-root@debian11:~/myDocker# docker images +
-REPOSITORY                           TAG       IMAGE ID       CREATED         SIZE +
-10.0.2.46:80/myproject/mydocker      latest    ccb27534d7f2   2 minutes ago   231MB +
-10.0.2.46:80/myproject/alpine        latest    49176f190c7e   2 weeks ago     7.05MB +
-alpine                               latest    49176f190c7e   2 weeks ago     7.05MB +
-goharbor/harbor-exporter             v2.6.2    ae230e335853   4 weeks ago     95.4MB +
-goharbor/chartmuseum-photon          v2.6.2    be361eee8a36   4 weeks ago     225MB +
-goharbor/redis-photon                v2.6.2    84fa3669bb10   4 weeks ago     154MB +
-goharbor/trivy-adapter-photon        v2.6.2    beef2527c7b2   4 weeks ago     441MB +
-goharbor/notary-server-photon        v2.6.2    b43e7c963f06   4 weeks ago     112MB +
-goharbor/notary-signer-photon        v2.6.2    4e9982286316   4 weeks ago     109MB +
-goharbor/harbor-registryctl          v2.6.2    d403d4e0f990   4 weeks ago     137MB +
-goharbor/registry-photon             v2.6.2    596e445b18f0   4 weeks ago     77.5MB +
-goharbor/nginx-photon                v2.6.2    cbbdf28947a5   4 weeks ago     154MB +
-goharbor/harbor-log                  v2.6.2    3ce902023f73   4 weeks ago     161MB +
-goharbor/harbor-jobservice           v2.6.2    05791a75c8b8   4 weeks ago     250MB +
-goharbor/harbor-core                 v2.6.2    484e2a64616d   4 weeks ago     213MB +
-goharbor/harbor-portal               v2.6.2    932297030d4e   4 weeks ago     162MB +
-goharbor/harbor-db                   v2.6.2    351b19e366cb   4 weeks ago     225MB +
-goharbor/prepare                     v2.6.2    eecc993c7643   4 weeks ago     164MB +
-10.0.2.46:80/myproject/production    latest    feb5d9fea6a5   14 months ago   13.3kB +
-hello-world                          latest    feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/hello-world   1.0       feb5d9fea6a5   14 months ago   13.3kB +
-10.0.2.46:80/myproject/hello-world   latest    feb5d9fea6a5   14 months ago   13.3kB +
-centos                               latest    5d0da3dc9764   15 months ago   231MB +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:latest +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Pushed  +
-74ddd0ec08fa: Pushed  +
-latest: digest: sha256:323ab8f05733ac369963b338bb8fe81bd5cb2d77b46ac3650b7924e7da3aa9cf size: 736 +
-</code> +
- +
-Retournez à l'interface de Harbor et cliquez sur **Projects > myproject** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor46.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que le dépôt **myproject/mydocker** a été créé.  +
-</WRAP> +
- +
-Cliquez sur **myproject/mydocker** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor47.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que l'Artefact est présent et qu'il possède un tag **latest**.  +
-</WRAP> +
- +
-Refaites un  build de l'image en changant le tag : +
- +
-<code> +
-root@debian11:~/myDocker# docker build --tag "10.0.2.46:80/myproject/mydocker:rel1"+
-Sending build context to Docker daemon  3.072kB +
-Step 1/6 : FROM centos:latest +
- ---> 5d0da3dc9764 +
-Step 2/6 : MAINTAINER ittraining "infos@ittraining.io" +
- ---> Using cache +
- ---> 7ce8d150d72d +
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> Using cache +
- ---> c1fda8d1e43c +
-Step 4/6 : ENV myVariable 3 +
- ---> Using cache +
- ---> 628615e7003a +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"+
- ---> Using cache +
- ---> c2ed329815ef +
-Step 6/6 : CMD ["mycommand"+
- ---> Using cache +
- ---> ccb27534d7f2 +
-Successfully built ccb27534d7f2 +
-Successfully tagged 10.0.2.46:80/myproject/mydocker:rel1 +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez l'utilisation des images intermédiares issues du cache.  +
-</WRAP> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:rel1 +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Layer already exists  +
-74ddd0ec08fa: Layer already exists  +
-rel1: digest: sha256:323ab8f05733ac369963b338bb8fe81bd5cb2d77b46ac3650b7924e7da3aa9cf size: 736 +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que seul le nouveau tag a été poussé.  +
-</WRAP> +
- +
-Editez le Dockerfile et changez la valeur de **myVariable** de 3 à **5** : +
- +
-<code> +
-root@debian11:~/myDocker# vi Dockerfile  +
-root@debian11:~/myDocker# cat Dockerfile  +
-FROM centos:latest +
-MAINTAINER ittraining "infos@ittraining.io" +
-COPY myEntrypoint.sh /entrypoint.sh +
-ENV myVariable 5  +
-ENTRYPOINT ["/entrypoint.sh"+
-CMD ["mycommand"+
-</code> +
- +
-Compilez de nouveau l'image : +
- +
-<code> +
-root@debian11:~/myDocker# docker build --tag "10.0.2.46:80/myproject/mydocker:rel2"+
-Sending build context to Docker daemon  3.072kB +
-Step 1/6 : FROM centos:latest +
- ---> 5d0da3dc9764 +
-Step 2/6 : MAINTAINER ittraining "infos@ittraining.io" +
- ---> Using cache +
- ---> 7ce8d150d72d +
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> Using cache +
- ---> c1fda8d1e43c +
-Step 4/6 : ENV myVariable 5 +
- ---> Running in c90f60beee6f +
-Removing intermediate container c90f60beee6f +
- ---> d9a704d55c69 +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"+
- ---> Running in 8aabb88b172d +
-Removing intermediate container 8aabb88b172d +
- ---> 6ca7239b3489 +
-Step 6/6 : CMD ["mycommand"+
- ---> Running in 8e1bd939a7c2 +
-Removing intermediate container 8e1bd939a7c2 +
- ---> 9a12b543b94b +
-Successfully built 9a12b543b94b +
-Successfully tagged 10.0.2.46:80/myproject/mydocker:rel2 +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:rel2 +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Layer already exists  +
-74ddd0ec08fa: Layer already exists  +
-rel2: digest: sha256:b918acd244c70cf528d8e96584d8d34099d2a8eefc1edd86ba972dd975934f52 size: 736 +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que la valeur du SHA256 de rel2 est différente - **b918acd244c70cf528d8e96584d8d34099d2a8eefc1edd86ba972dd975934f52** par rapport à **323ab8f05733ac369963b338bb8fe81bd5cb2d77b46ac3650b7924e7da3aa9cf**.  +
-</WRAP> +
- +
-De ce fait un nouvel Artefact a été créé : +
- +
-{{ :elearning:workbooks:kubernetes:harbor48.png?direct&800 |}} +
- +
-Editez le Dockerfile et changez la valeur de **CMD** de "mycommand" à **"mycommand modified"** : +
- +
-<code> +
-root@debian11:~/myDocker# cat Dockerfile  +
-FROM centos:latest +
-MAINTAINER ittraining "infos@ittraining.io" +
-COPY myEntrypoint.sh /entrypoint.sh +
-ENV myVariable 5  +
-ENTRYPOINT ["/entrypoint.sh"+
-CMD ["mycommand modified"+
-</code> +
- +
-Compilez de nouveau l'image en utilisant le même tag qu'avant : +
- +
-<code> +
-root@debian11:~/myDocker# docker build --tag "10.0.2.46:80/myproject/mydocker:rel2"+
-Sending build context to Docker daemon  3.072kB +
-Step 1/6 : FROM centos:latest +
- ---> 5d0da3dc9764 +
-Step 2/6 : MAINTAINER ittraining "infos@ittraining.io" +
- ---> Using cache +
- ---> 7ce8d150d72d +
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> Using cache +
- ---> c1fda8d1e43c +
-Step 4/6 : ENV myVariable 5 +
- ---> Using cache +
- ---> d9a704d55c69 +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"+
- ---> Using cache +
- ---> 6ca7239b3489 +
-Step 6/6 : CMD ["mycommand modified"+
- ---> Running in ac174f91145b +
-Removing intermediate container ac174f91145b +
- ---> 56cc6362dc99 +
-Successfully built 56cc6362dc99 +
-Successfully tagged 10.0.2.46:80/myproject/mydocker:rel2 +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:rel2 +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Layer already exists  +
-74ddd0ec08fa: Layer already exists  +
-rel2: digest: sha256:fcf710f98e14ac3df4d3cf365f04423da8ceb42325eca9efe87f67082904728e size: 736 +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que la valeur du SHA256 de rel2 est différente - **fcf710f98e14ac3df4d3cf365f04423da8ceb42325eca9efe87f67082904728e** par rapport à **b918acd244c70cf528d8e96584d8d34099d2a8eefc1edd86ba972dd975934f52**. Par contre, puisque le même tag a été utilisé, le tag **rel2** a été attribué au dernier Artefact créé et le même tag a été supprimé de l'Artefact dont le SHA256 est **b918acd244c70cf528d8e96584d8d34099d2a8eefc1edd86ba972dd975934f52** +
-</WRAP> +
- +
-===5.11 - Rétention de Tags=== +
- +
-Pour gérer ce comportement, il est possible de créer des règles. Cliquez sur **myproject > Policy** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor50.png?direct&800 |}} +
- +
-Cliquez sur **ADD RULE** et remplissez le formulaire ainsi : +
- +
-{{ :elearning:workbooks:kubernetes:harbor51.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Cette règle s'appliquera à tous les dépôts et concernera tous les tags. La règle retiendra les 2 Artefacts les plus recemment poussés vers le dépôt. +
-</WRAP> +
- +
-Cliquez sur **EDIT** sur la ligne **Schedule** et choisissez **hourly** puis cliquez **Save** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor52.png?direct&800 |}} +
- +
-Cliquez sur **OK** dans la boîte d'avertissement : +
- +
-{{ :elearning:workbooks:kubernetes:harbor53.png?direct&800 |}} +
- +
-Cliquez ensuite sur le bouton **DRY RUN**. Quand le Dry Run a terminé avec le message **Success**, cliquez sur le bouton **Expand** du Dry Run : +
- +
-{{ :elearning:workbooks:kubernetes:harbor54.png?direct&800 |}} +
- +
-Sur la dernière ligne, cliquez sur le bouton **Log** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor56.png?direct&800 |}} +
- +
-Consultez la colonne **Retention** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor57.png?direct&800 |}} +
- +
-Revenez dans l'interface de Harbor et exécutez la règle en cliquant sur le bouton **RUN NOW**, puis cliquez sur **RUN** dans la boîte d'avertissement : +
- +
-{{ :elearning:workbooks:kubernetes:harbor58.png?direct&800 |}} +
- +
-Editez de nouveau le Dockerfile et changez la valeur de **myVariable** de 5 à **10** : +
- +
-<code> +
-root@debian11:~/myDocker# vi Dockerfile  +
-root@debian11:~/myDocker# cat Dockerfile  +
-FROM centos:latest +
-MAINTAINER ittraining "infos@ittraining.io" +
-COPY myEntrypoint.sh /entrypoint.sh +
-ENV myVariable 10  +
-ENTRYPOINT ["/entrypoint.sh"+
-CMD ["mycommand"+
-</code> +
- +
-Compilez de nouveau l'image : +
- +
-<code> +
-root@debian11:~/myDocker# docker build --tag "10.0.2.46:80/myproject/mydocker:rel3"+
-Sending build context to Docker daemon  3.072kB +
-Step 1/6 : FROM centos:latest +
- ---> 5d0da3dc9764 +
-Step 2/6 : MAINTAINER ittraining "infos@ittraining.io" +
- ---> Using cache +
- ---> 7ce8d150d72d +
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> Using cache +
- ---> c1fda8d1e43c +
-Step 4/6 : ENV myVariable 10 +
- ---> Running in 7c938717175f +
-Removing intermediate container 7c938717175f +
- ---> ef07118050c5 +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"+
- ---> Running in b2dc04a9363d +
-Removing intermediate container b2dc04a9363d +
- ---> f73a3c2f7930 +
-Step 6/6 : CMD ["mycommand modified"+
- ---> Running in fd7a8952dd7f +
-Removing intermediate container fd7a8952dd7f +
- ---> 3bbe34d8d430 +
-Successfully built 3bbe34d8d430 +
-Successfully tagged 10.0.2.46:80/myproject/mydocker:rel3 +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:rel3 +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Layer already exists  +
-74ddd0ec08fa: Layer already exists  +
-rel3: digest: sha256:ae649a586f5d9dcae71440bf88eb98d95c3cc86d40f27eb54fa68e65869c3b48 size: 736 +
-</code> +
- +
-Exécutez la règle : +
- +
-{{ :elearning:workbooks:kubernetes:harbor60.png?direct&800 |}} +
- +
-Constatez la liste des Artefacts dans **mydocker** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor61.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que c'est l'Artefact le plus ancien qui a été supprimé. +
-</WRAP> +
- +
-===5.12 - Immutabilité des Tags=== +
- +
-Cliquez sur **myproject > Policy > TAG IMMUTABILITY** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor62.png?direct&800 |}} +
- +
-Cliquez maintenant sur le bouton **ADD RULE** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor63.png?direct&800 |}} +
- +
-Cliquez sur le bouton **ADD** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor64.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Cette règle s'appliquera à tous les dépôts et concernera tous les tags. +
-</WRAP> +
- +
-Essayez de faire un push de l'image **mydocker:rel2** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:rel2 +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Layer already exists  +
-74ddd0ec08fa: Layer already exists  +
-unknown: Failed to process request due to 'mydocker:rel2' configured as immutable. +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez qu'il n'est pas possible de faire un push car la règle d'immutabilité l'interdit. +
-</WRAP> +
- +
-Editez le Dockerfile et changez la valeur de **myVariable** de 10 à **8** : +
- +
-<code> +
-root@debian11:~/myDocker# vi Dockerfile  +
-root@debian11:~/myDocker# cat Dockerfile  +
-FROM centos:latest +
-MAINTAINER ittraining "infos@ittraining.io" +
-COPY myEntrypoint.sh /entrypoint.sh +
-ENV myVariable 8  +
-ENTRYPOINT ["/entrypoint.sh"+
-CMD ["mycommand"+
-</code> +
- +
-Faites un build de **mydocker:rel4** : +
- +
-<code> +
-root@debian11:~/myDocker# docker build --tag "10.0.2.46:80/myproject/mydocker:rel4"+
-Sending build context to Docker daemon  3.072kB +
-Step 1/6 : FROM centos:latest +
- ---> 5d0da3dc9764 +
-Step 2/6 : MAINTAINER ittraining "infos@ittraining.io" +
- ---> Using cache +
- ---> 7ce8d150d72d +
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> Using cache +
- ---> c1fda8d1e43c +
-Step 4/6 : ENV myVariable 8 +
- ---> Running in 541758cf561f +
-Removing intermediate container 541758cf561f +
- ---> 45f622ff8362 +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"+
- ---> Running in 9d309f201613 +
-Removing intermediate container 9d309f201613 +
- ---> 749b47fe344a +
-Step 6/6 : CMD ["mycommand modified"+
- ---> Running in e7397e408526 +
-Removing intermediate container e7397e408526 +
- ---> 85f1cbc19cee +
-Successfully built 85f1cbc19cee +
-Successfully tagged 10.0.2.46:80/myproject/mydocker:rel4 +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:rel4 +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Layer already exists  +
-74ddd0ec08fa: Layer already exists  +
-rel4: digest: sha256:ae649a586f5d9dcae71440bf88eb98d95c3cc86d40f27eb54fa68e65869c3b48 size: 736 +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** : Notez qu'il est possible de faire un push car le tag rel4 n'existait pas. +
-</WRAP> +
- +
-Dans l'interface de Harbor, cliquez sur **Projects > myproject > myproject/mydocker** et cochez **rel2** : +
- +
-{{ :elearning:workbooks:kubernetes:harbor65.png?direct&800 |}} +
- +
-Essayez de supprimer l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor66.png?direct&800 |}} +
- +
-Notez l'erreur : +
- +
-{{ :elearning:workbooks:kubernetes:harbor67.png?direct&800 |}} +
- +
-Pour pouvoir supprimer l'Artefact, il faut désactiver la règle d'immutabilité : +
- +
-{{ :elearning:workbooks:kubernetes:harbor68.png?direct&800 |}} +
- +
-Maintenant, essayez de supprimer l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor69.png?direct&800 |}} +
- +
-Vous verrez que la suppression a réussi : +
- +
-{{ :elearning:workbooks:kubernetes:harbor70.png?direct&800 |}} +
- +
-Editez le Dockerfile et changez la valeur de **myVariable** de 8 à **7** : +
- +
-<code> +
-root@debian11:~/myDocker# vi Dockerfile  +
-root@debian11:~/myDocker# cat Dockerfile  +
-FROM centos:latest +
-MAINTAINER ittraining "infos@ittraining.io" +
-COPY myEntrypoint.sh /entrypoint.sh +
-ENV myVariable 7  +
-ENTRYPOINT ["/entrypoint.sh"+
-CMD ["mycommand"+
-</code> +
- +
-Faites un build de **mydocker:rel5** : +
- +
-<code> +
-root@debian11:~/myDocker# docker build --tag "10.0.2.46:80/myproject/mydocker:rel5"+
-Sending build context to Docker daemon  3.072kB +
-Step 1/6 : FROM centos:latest +
- ---> 5d0da3dc9764 +
-Step 2/6 : MAINTAINER ittraining "infos@ittraining.io" +
- ---> Using cache +
- ---> 7ce8d150d72d +
-Step 3/6 : COPY myEntrypoint.sh /entrypoint.sh +
- ---> Using cache +
- ---> c1fda8d1e43c +
-Step 4/6 : ENV myVariable 7 +
- ---> Running in b2153c9b0781 +
-Removing intermediate container b2153c9b0781 +
- ---> 3b18a7da4503 +
-Step 5/6 : ENTRYPOINT ["/entrypoint.sh"+
- ---> Running in 81b97d9082ed +
-Removing intermediate container 81b97d9082ed +
- ---> c283e1e64dca +
-Step 6/6 : CMD ["mycommand modified"+
- ---> Running in 7252818184fc +
-Removing intermediate container 7252818184fc +
- ---> f9466edbe1f3 +
-Successfully built f9466edbe1f3 +
-Successfully tagged 10.0.2.46:80/myproject/mydocker:rel5 +
-</code> +
- +
-Procédez maintenant au **push** : +
- +
-<code> +
-root@debian11:~/myDocker# docker push 10.0.2.46:80/myproject/mydocker:rel5 +
-The push refers to repository [10.0.2.46:80/myproject/mydocker] +
-7c7558b01004: Layer already exists  +
-74ddd0ec08fa: Layer already exists  +
-rel5: digest: sha256:887e7751d8a7271b238f536327c38a867881a9c354ff54d9ab5db45502a160d7 size: 736 +
-</code> +
- +
-Pour pouvoir supprimer l'Artefact, il faut désactiver la règle d'immutabilité : +
- +
-{{ :elearning:workbooks:kubernetes:harbor68.png?direct&800 |}} +
- +
-Maintenant, essayez de supprimer l'Artefact : +
- +
-{{ :elearning:workbooks:kubernetes:harbor69.png?direct&800 |}} +
- +
-Vous verrez que la suppression a réussi : +
- +
-{{ :elearning:workbooks:kubernetes:harbor70.png?direct&800 |}} +
- +
-Retournez dans Harbor et modifier la règle d'immutabilité en ne spécifiant que le tag **rel3** puis activez cette règle : +
- +
-{{ :elearning:workbooks:kubernetes:harbor71.png?direct&800 |}} +
- +
-Rappelez-vous que la règle de Rétention de Tags ne garde que les deux Artefacts les plus récents : +
- +
-{{ :elearning:workbooks:kubernetes:harbor72.png?direct&800 |}} +
- +
-Procédez à un Dry Run de la règle de Rétention de Tags et consultez le log de mydocker : +
- +
-{{ :elearning:workbooks:kubernetes:harbor73.png?direct&800 |}} +
- +
-<WRAP center round important 60%> +
-**Important** : Notez que la règle d'immutabilité empêche la règle de rétention des tags de supprimer l'Artefact **rel3**. +
-</WRAP>+
  
 ----- -----
-Copyright © 2022 Hugh Norris +Copyright © 2024 Hugh Norris - Document non-contractuel. Le programme peut être modifié sans préavis.
- +
- +
Menu