Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:kubernetes:k8s09 [2023/11/21 10:15] – admin | elearning:workbooks:kubernetes:k8s09 [2024/12/20 13:54] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version | + | Version |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======DOF311 | + | |
+ | ======DOF310 | ||
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **DOF311 | + | * **DOF310 |
* Contenu du Module | * Contenu du Module | ||
- | * Rappel du Programme de la Formation | ||
- | * Validation des Acquis | ||
- | * Évaluation de la Formation | ||
- | |||
- | =====Rappel du Programme de la Formation===== | ||
- | |||
- | * **DOF300 - Présentation de la Formation** | ||
- | * Prérequis | ||
- | * Matériel | ||
- | * Logiciels | ||
- | * Internet | ||
- | * Support de Cours | ||
- | * Programme de la Formation | ||
- | * Évaluation des Compétences | ||
- | |||
- | * **DOF301 - Création de Clusters Kubernetes** | ||
- | * L' | ||
- | * Présentation de Kubernetes (k8s) | ||
- | * Master | ||
- | * Nœuds (Minions) | ||
- | * LAB #1 - Création du Cluster K8s 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 K8s avec Minikube | ||
- | * 2.1 - Présentation de Minikube | ||
- | * 2.2 - Installation de Minikube | ||
- | * 2.3 - Configuration de Minikube | ||
- | * 2.4 - Installation de kubectl | ||
- | * 2.5 - La Commande minikube dashboard | ||
- | * 2.6 - La Commande minikube addons | ||
- | |||
- | * **DOF302 - Gestion des PODs, Contrôleurs de Réplication, | ||
- | * 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' | ||
- | * La Commande version | ||
- | * La Commande cluster-info | ||
- | * La Commande api-versions | ||
- | * La Commande api-resources | ||
- | * 1.3 - Obtenir de l' | ||
- | * La Commande describe node | ||
- | * La Commande top | ||
- | * 1.4 - Obtenir de l' | ||
- | * La Commande describe pod | ||
- | * La Commande top | ||
- | * 1.5 - Travailler avec la commande kubectl | ||
- | * La Commande apply | ||
- | * La Commande create | ||
- | * La Commande get | ||
- | * Utilisation des Options | ||
- | * La Commande exec | ||
- | * Commandes Impératives | ||
- | * LAB #2 - Gestion 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' | ||
- | * 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' | ||
- | * 2.1 - Présentation | ||
- | * 2.2 - Création des Deployments | ||
- | * 2.3 - Création des Services | ||
- | * 2.4 - Déployer l' | ||
- | * 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' | ||
- | * 3.2 - L' | ||
- | * 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 / | ||
- | * 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 - Kubernetes Avancé** | ||
* StatefulSets | * StatefulSets | ||
* LAB #1 - Mise en Place d'un StatefulSet Simple | * LAB #1 - Mise en Place d'un StatefulSet Simple | ||
Ligne 269: | Ligne 37: | ||
* 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' | ||
- | * 5.11 - Rétention de Tags | ||
- | * 5.12 - Immutabilité des Tags | ||
- | * **DOF311 | + | =====Ressources===== |
- | * Support | + | |
- | * Rappel | + | ====Lab #1==== |
- | * Évaluation | + | |
- | * Validation | + | * https:// |
+ | * https:// | ||
+ | |||
+ | ====Lab #2==== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | ====Lab #3==== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | =====StatefulSets===== | ||
+ | |||
+ | Un StatefulSet est un composant de Kubernetes qui est utilisé pour des applications avec état (//Stateful Applications// | ||
+ | |||
+ | Des exemples d' | ||
+ | |||
+ | * 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' | ||
+ | |||
+ | 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' | ||
+ | * 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' | ||
+ | |||
+ | Dans ce cas de notre StatefulSet, | ||
+ | |||
+ | * ne peuvent pas tous accepter des requêtes d' | ||
+ | * 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' | ||
+ | |||
+ | * 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' | ||
+ | |||
+ | * mysql-0 - **/ | ||
+ | * mysql-1 - **/ | ||
+ | * mysql-2 - **/ | ||
+ | |||
+ | 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' | ||
+ | |||
+ | Par exemple, si on supprime le pod **mysql-1**, | ||
+ | |||
+ | * mysql-0 - / | ||
+ | * pod supprimé - / | ||
+ | * mysql-2 - / | ||
+ | * mysql-3 - / | ||
+ | |||
+ | En ajoutant un pod de remplaceement, | ||
+ | |||
+ | * mysql-0 | ||
+ | * mysql-1 <<<<<<<<<< | ||
+ | * mysql-2 | ||
+ | * mysql-3 | ||
+ | |||
+ | Lors de la création d'un ReplicaSet, un service d' | ||
+ | ** : | ||
+ | |||
+ | * 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 : / | ||
+ | * Endpoint DNS : mysql-0..mysvc.default.svc.cluster.local | ||
+ | * mysql-1 | ||
+ | * Rôle : **Esclave** | ||
+ | * Données : lecture seulement | ||
+ | * Stockage : / | ||
+ | * Endpoint DNS : mysql-1.mysvc.default.svc.cluster.local | ||
+ | * mysql-2 | ||
+ | * Rôle : **Esclave** | ||
+ | * Données : lecture seulement | ||
+ | * Stockage : / | ||
+ | * Endpoint DNS : mysql-2.mysvc.default.svc.cluster.local | ||
+ | * mysql-3 | ||
+ | * Rôle : **Esclave** | ||
+ | * Données : lecture seulement | ||
+ | * Stockage : / | ||
+ | * Endpoint DNS : mysql-3.mysvc.default.svc.cluster.local | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | * 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** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | namespace/ | ||
+ | |||
+ | root@kubemaster: | ||
+ | Context " | ||
+ | </ | ||
+ | |||
+ | <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' | ||
+ | </ | ||
+ | |||
+ | Si vous souhaitez observer les résultats des commandes suivantes en temps réel, ouvrez un deuxième terminal et saisissez la commande suivante : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | </ | ||
+ | |||
+ | ===1.1 - Création du Service et du StatefulSet=== | ||
+ | |||
+ | Créez maintenant le fichier **quarkus-service.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: quarkus | ||
+ | labels: | ||
+ | app: quarkus-statefulset | ||
+ | spec: | ||
+ | ports: | ||
+ | - port: 8080 | ||
+ | name: web | ||
+ | clusterIP: None | ||
+ | selector: | ||
+ | app: quarkus-statefulset | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez le nom du service - **quarkus**. La valeur **None** de l' | ||
+ | </ | ||
+ | |||
+ | Créez le service : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | service/ | ||
+ | </ | ||
+ | |||
+ | Créez maintenant le fichier **statefulset.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: apps/v1 | ||
+ | kind: StatefulSet | ||
+ | metadata: | ||
+ | name: quarkus-statefulset | ||
+ | labels: | ||
+ | app: quarkus-statefulset | ||
+ | spec: | ||
+ | serviceName: | ||
+ | replicas: 2 | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: quarkus-statefulset | ||
+ | spec: | ||
+ | containers: | ||
+ | - name: quarkus-statefulset | ||
+ | image: quay.io/ | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | name: web | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: quarkus-statefulset | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que la valeur de **serviceName** est **quarkus**. | ||
+ | </ | ||
+ | |||
+ | Créez le StatefulSet : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | statefulset.apps/ | ||
+ | </ | ||
+ | |||
+ | Constatez la présence des deux pods dans le Namespace : | ||
+ | |||
+ | < | ||
+ | Every 1,0s: kubectl get pods -o wide | awk ' | ||
+ | |||
+ | NAME | ||
+ | quarkus-statefulset-0 | ||
+ | quarkus-statefulset-1 | ||
+ | </ | ||
+ | |||
+ | Contrôlez l' | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME READY AGE | ||
+ | quarkus-statefulset | ||
+ | </ | ||
+ | |||
+ | ainsi que la présence du service : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME TYPE CLUSTER-IP | ||
+ | quarkus | ||
+ | </ | ||
+ | |||
+ | ===1.2 - Mise en Place d'un Scale Up=== | ||
+ | |||
+ | Procédez à un scale up : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que le nom court d'un **serviceName** est **sts**. | ||
+ | </ | ||
+ | |||
+ | Constatez la présence des **trois** pods dans le Namespace : | ||
+ | |||
+ | < | ||
+ | Every 1,0s: kubectl get pods -o wide | awk ' | ||
+ | |||
+ | NAME | ||
+ | quarkus-statefulset-0 | ||
+ | quarkus-statefulset-1 | ||
+ | quarkus-statefulset-2 | ||
+ | </ | ||
+ | |||
+ | Constatez l' | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | LAST SEEN | ||
+ | 6m35s | ||
+ | 6m35s | ||
+ | 6m34s | ||
+ | 6m5s Normal | ||
+ | 6m4s Normal | ||
+ | 6m4s Normal | ||
+ | 6m3s Normal | ||
+ | 6m3s Normal | ||
+ | 5m58s | ||
+ | 5m22s | ||
+ | 5m21s | ||
+ | 5m21s | ||
+ | 99s | ||
+ | 99s | ||
+ | 98s | ||
+ | 97s | ||
+ | 97s | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un pod pour interroger le DNS de K8s : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | If you don't see a command prompt, try pressing enter. | ||
+ | / # nslookup quarkus-statefulset-0.quarkus | ||
+ | Server: | ||
+ | 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 " | ||
+ | root@kubemaster: | ||
+ | </ | ||
+ | |||
+ | ===1.3 - Mise en Place d'un Scale Down=== | ||
+ | |||
+ | Procédez maintenant à un scale down : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | statefulset.apps/ | ||
+ | </ | ||
+ | |||
+ | Constatez | ||
+ | |||
+ | < | ||
+ | Every 1,0s: kubectl get pods -o wide | awk ' | ||
+ | |||
+ | NAME | ||
+ | quarkus-statefulset-0 | ||
+ | quarkus-statefulset-1 | ||
+ | </ | ||
+ | |||
+ | ===1.4 - Suppression du StatefulSet=== | ||
+ | |||
+ | Pour terminer, supprimez le StatefulSet, | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | statefulset.apps " | ||
+ | |||
+ | root@kubemaster: | ||
+ | service " | ||
+ | |||
+ | root@kubemaster: | ||
+ | Context " | ||
+ | </ | ||
+ | |||
+ | =====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.45. | ||
+ | |||
+ | Devenez root puis créez le répertoire | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# mkdir -p / | ||
+ | </ | ||
+ | |||
+ | Continuez maintenant par activer et démarrer le service **nfs-server** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl status nfs-server | ||
+ | ● nfs-server.service - NFS server and services | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@centos8 ~]# systemctl enable nfs-server.service | ||
+ | Created symlink / | ||
+ | |||
+ | [root@centos8 ~]# systemctl start nfs-server.service | ||
+ | |||
+ | [root@centos8 ~]# systemctl status nfs-server.service | ||
+ | ● nfs-server.service - NFS server and services | ||
+ | | ||
+ | | ||
+ | Process: 3276 ExecStart=/ | ||
+ | Process: 3263 ExecStart=/ | ||
+ | Process: 3261 ExecStartPre=/ | ||
+ | Main PID: 3276 (code=exited, | ||
+ | |||
+ | 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. | ||
+ | </ | ||
+ | |||
+ | Editez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# vi / | ||
+ | [root@centos8 ~]# cat / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Dans ce cas, nous avons partagé le répertoire **/ | ||
+ | </ | ||
+ | |||
+ | Appliquez l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# exportfs -rav | ||
+ | exporting *:/ | ||
+ | |||
+ | [root@centos8 ~]# exportfs -v | ||
+ | / | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | Passez SELinux en mode permissive : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# getenforce | ||
+ | Enforcing | ||
+ | |||
+ | [root@centos8 ~]# setenforce permissive | ||
+ | |||
+ | </ | ||
+ | |||
+ | Configurez ensuite le pare-feu : | ||
+ | |||
+ | < | ||
+ | [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 | ||
+ | </ | ||
+ | |||
+ | ===2.2 - Configuration des Clients NFS=== | ||
+ | |||
+ | Revenez à votre gateway et connectez-vous en tant que l' | ||
+ | |||
+ | < | ||
+ | trainee@kubenode2: | ||
+ | Mot de passe : fenestros | ||
+ | root@kubenode2: | ||
+ | </ | ||
+ | |||
+ | Installez le paquet **nfs-common** : | ||
+ | |||
+ | < | ||
+ | root@kubenode2: | ||
+ | ... | ||
+ | |||
+ | root@kubenode2: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Vérifiez que vous pouvez voir le répertoire exporté par le 10.0.2.45 : | ||
+ | |||
+ | < | ||
+ | root@kubenode2: | ||
+ | Export list for 10.0.2.45: | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Vérifiez que vous pouvez monter le répertoire exporté par le 10.0.2.45 : | ||
+ | |||
+ | < | ||
+ | root@kubenode2: | ||
+ | root@kubenode2: | ||
+ | 10.0.2.45:/ | ||
+ | </ | ||
+ | |||
+ | Démontez ensuite **10.0.2.45:/ | ||
+ | |||
+ | < | ||
+ | root@kubenode2: | ||
+ | |||
+ | root@kubenode2: | ||
+ | </ | ||
+ | |||
+ | Connectez-vous à kubenode1 au 192.168.56.3 : | ||
+ | |||
+ | < | ||
+ | root@kubenode2: | ||
+ | The authenticity of host ' | ||
+ | ECDSA key fingerprint is SHA256: | ||
+ | Are you sure you want to continue connecting (yes/no)? yes | ||
+ | Warning: Permanently added ' | ||
+ | trainee@192.168.56.3' | ||
+ | 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 / | ||
+ | |||
+ | 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: | ||
+ | Mot de passe : fenestros | ||
+ | root@kubenode1: | ||
+ | </ | ||
+ | |||
+ | Installez ensuite le paquet **nfs-common** : | ||
+ | |||
+ | < | ||
+ | root@kubenode1: | ||
+ | ... | ||
+ | |||
+ | root@kubenode1: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Revenez à votre gateway : | ||
+ | |||
+ | < | ||
+ | root@kubenode1: | ||
+ | déconnexion | ||
+ | trainee@kubenode1: | ||
+ | déconnexion | ||
+ | Connection to 192.168.56.3 closed. | ||
+ | root@kubenode2: | ||
+ | déconnexion | ||
+ | trainee@kubenode2: | ||
+ | déconnexion | ||
+ | Connection to 192.168.56.4 closed. | ||
+ | </ | ||
+ | |||
+ | ===2.3 - Configuration de K8s=== | ||
+ | |||
+ | Connectez-vous à votre **kubemaster** au 192.168.56.2. | ||
+ | |||
+ | Installez ensuite le paquet **nfs-common** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | ... | ||
+ | |||
+ | root@kubemaster: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Ajoutez le dépôt **nfs-subdir-external-provisioner** à **helm** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | Installez le chart helm **nfs-subdir-external-provisioner** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME: nfs-subdir-external-provisioner | ||
+ | LAST DEPLOYED: Wed Dec 7 11:12:23 2022 | ||
+ | NAMESPACE: default | ||
+ | STATUS: deployed | ||
+ | REVISION: 1 | ||
+ | TEST SUITE: None | ||
+ | </ | ||
+ | |||
+ | Contrôlez l' | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME | ||
+ | netshoot | ||
+ | nfs-subdir-external-provisioner-59b4b5c476-wxkp4 | ||
+ | nginx-netshoot | ||
+ | postgresql-6f885d8957-tnlbb | ||
+ | sharedvolume | ||
+ | troubleshooting | ||
+ | volumepod | ||
+ | </ | ||
+ | |||
+ | <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. | ||
+ | </ | ||
+ | |||
+ | Une fois recréés, vous pouvez constater que le pod **nfs-subdir-external-provisioner-yyyyyyyyyy-xxxxx** est dans un état de Running : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAMESPACE | ||
+ | default | ||
+ | default | ||
+ | default | ||
+ | default | ||
+ | default | ||
+ | default | ||
+ | default | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | I1207 10: | ||
+ | I1207 10: | ||
+ | I1207 10: | ||
+ | I1207 10: | ||
+ | I1207 10: | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant la liste des StorageClasses : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME | ||
+ | localdisk | ||
+ | nfs-client | ||
+ | </ | ||
+ | |||
+ | ===2.4 - Création d'un PersistentVolumeClaim=== | ||
+ | |||
+ | Créez maintenant le fichier **pvc.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: PersistentVolumeClaim | ||
+ | metadata: | ||
+ | name: pvc1 | ||
+ | spec: | ||
+ | storageClassName: | ||
+ | accessModes: | ||
+ | - ReadWriteMany | ||
+ | resources: | ||
+ | requests: | ||
+ | storage: 500Mi | ||
+ | </ | ||
+ | |||
+ | Appliquez le fichier pvc.yaml : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | persistentvolumeclaim/ | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant la liste de PersistentVolumes et de PersistentVolumeClaims : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME CAPACITY | ||
+ | persistentvolume/ | ||
+ | persistentvolume/ | ||
+ | |||
+ | NAME | ||
+ | persistentvolumeclaim/ | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que le PersistentVolume **persistentvolume/ | ||
+ | </ | ||
+ | |||
+ | Connectez-vous au serveur NFS et constatez le contenu | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | The authenticity of host ' | ||
+ | ECDSA key fingerprint is SHA256: | ||
+ | Are you sure you want to continue connecting (yes/no)? yes | ||
+ | Warning: Permanently added ' | ||
+ | trainee@10.0.2.45' | ||
+ | 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 / | ||
+ | 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.45 closed. | ||
+ | </ | ||
+ | |||
+ | ===2.5 - Utilisation du PersistentVolumeClaim avec un pod=== | ||
+ | |||
+ | Créez maintenant le fichier **nfs-busybox.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: Pod | ||
+ | metadata: | ||
+ | name: nfs-pv-pod | ||
+ | spec: | ||
+ | restartPolicy: | ||
+ | containers: | ||
+ | - name: busybox | ||
+ | image: busybox | ||
+ | command: [' | ||
+ | volumeMounts: | ||
+ | - name: pv-storage | ||
+ | mountPath: / | ||
+ | volumes: | ||
+ | - name: pv-storage | ||
+ | persistentVolumeClaim: | ||
+ | claimName: pvc1 | ||
+ | </ | ||
+ | |||
+ | Appliquez le fichier nfs-busybox.yaml : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | pod/ | ||
+ | </ | ||
+ | |||
+ | Vérifiez que le statut du pod **nfs-pv-pod** est **Running** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME | ||
+ | netshoot | ||
+ | nfs-pv-pod | ||
+ | nfs-subdir-external-provisioner-59b4b5c476-wxkp4 | ||
+ | nginx-netshoot | ||
+ | postgresql-6f885d8957-tnlbb | ||
+ | sharedvolume | ||
+ | troubleshooting | ||
+ | volumepod | ||
+ | </ | ||
+ | |||
+ | Connectez-vous au conteneur du pod **nfs-pv-pod** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | / # | ||
+ | </ | ||
+ | |||
+ | Créez le fichier **hello** dans le répertoire **pv-pod-storage** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | / # ls | ||
+ | bin | ||
+ | / # touch / | ||
+ | / # ls / | ||
+ | hello | ||
+ | / # exit | ||
+ | </ | ||
+ | |||
+ | Connectez-vous au serveur NFS et constatez le contenu du répertoire **/ | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | trainee@10.0.2.45' | ||
+ | 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 / | ||
+ | / | ||
+ | total 0 | ||
+ | drwxrwxrwx. 2 root root 19 Dec 7 13:13 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.45 closed. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez la présence du fichier **hello**. | ||
+ | </ | ||
+ | |||
+ | ===2.6 - Création d'un Deuxième PersistentVolumeClaim=== | ||
+ | |||
+ | Vréez le fichier **pvc2.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: PersistentVolumeClaim | ||
+ | metadata: | ||
+ | name: pvc2 | ||
+ | spec: | ||
+ | storageClassName: | ||
+ | accessModes: | ||
+ | - ReadWriteOnce | ||
+ | resources: | ||
+ | requests: | ||
+ | storage: 100Mi | ||
+ | </ | ||
+ | |||
+ | Appliquez le fichier **pvc2.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | persistentvolumeclaim/ | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant la liste de PersistentVolumes et de PersistentVolumeClaims : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME CAPACITY | ||
+ | persistentvolume/ | ||
+ | persistentvolume/ | ||
+ | persistentvolume/ | ||
+ | |||
+ | NAME | ||
+ | persistentvolumeclaim/ | ||
+ | persistentvolumeclaim/ | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que le PersistentVolume **persistentvolume/ | ||
+ | </ | ||
+ | |||
+ | ===2.7 - Suppression des PersistentVolumeClaims=== | ||
+ | |||
+ | Commencer par supprimer le pod **nfs-pv-pod** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | pod " | ||
+ | </ | ||
+ | |||
+ | Constatez | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME | ||
+ | netshoot | ||
+ | nfs-subdir-external-provisioner-59b4b5c476-wxkp4 | ||
+ | nginx-netshoot | ||
+ | postgresql-6f885d8957-tnlbb | ||
+ | sharedvolume | ||
+ | troubleshooting | ||
+ | volumepod | ||
+ | </ | ||
+ | |||
+ | Constatez maintenant la liste de PersistentVolumes et de PersistentVolumeClaims : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME CAPACITY | ||
+ | persistentvolume/ | ||
+ | persistentvolume/ | ||
+ | persistentvolume/ | ||
+ | |||
+ | NAME | ||
+ | persistentvolumeclaim/ | ||
+ | persistentvolumeclaim/ | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que les PersistentVolumes et les PersistentVolumeClaims sont toujours présents. | ||
+ | </ | ||
+ | |||
+ | Supprimes les deux PersistentVolumeClaims : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | persistentvolumeclaim " | ||
+ | persistentvolumeclaim " | ||
+ | </ | ||
+ | |||
+ | Constatez ensuite que les deux PersistentVolumes ont été supprimés automatiquement : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME CAPACITY | ||
+ | persistentvolume/ | ||
+ | </ | ||
+ | |||
+ | Connectez-vous au serveur NFS et constatez le contenu du répertoire **/ | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | trainee@10.0.2.45' | ||
+ | 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 / | ||
+ | / | ||
+ | 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 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | -rw-r--r--. 1 root root 0 Dec 7 13:13 hello | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | [trainee@centos8 ~]$ exit | ||
+ | logout | ||
+ | Connection to 10.0.2.45 closed. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que les répertoires ont un préfixe **archived-** | ||
+ | </ | ||
+ | |||
+ | =====Helm Avancé===== | ||
+ | |||
+ | Un chart est une collection de fichiers et de répertoires qui prennent | ||
+ | |||
+ | < | ||
+ | MyChart/ | ||
+ | Chart.yaml | ||
+ | LICENSE | ||
+ | README.md | ||
+ | values.yaml | ||
+ | values.schema.json | ||
+ | charts/ | ||
+ | crds/ | ||
+ | templates/ | ||
+ | templates/ | ||
+ | </ | ||
+ | |||
+ | 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 | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | name: blog | ||
+ | labels: | ||
+ | | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: blog | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: blog | ||
+ | spec: | ||
+ | containers: | ||
+ | - name: blog | ||
+ | image: ghost: | ||
+ | imagePullPolicy: | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | env: | ||
+ | - name: url | ||
+ | value: http:// | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: blog | ||
+ | spec: | ||
+ | type: NodePort | ||
+ | selector: | ||
+ | app: blog | ||
+ | ports: | ||
+ | - protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 2368 | ||
+ | </ | ||
+ | |||
+ | ====LAB #3 - Création d'un Paquet Helm Simple==== | ||
+ | |||
+ | Commencez par créer le répertoire | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | </ | ||
+ | |||
+ | 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 : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | </ | ||
+ | |||
+ | ===3.1 - Le Fichier values.yaml=== | ||
+ | |||
+ | Un chart a aussi besoin d'un fichier dénommé **values.yaml** qui contient | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | service: | ||
+ | name: blog | ||
+ | type: NodePort | ||
+ | app: blog | ||
+ | protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 2368 | ||
+ | </ | ||
+ | |||
+ | ===3.2 - Les Templates=== | ||
+ | |||
+ | Créez le sous-répertoire **templates** dans **ghost** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | </ | ||
+ | |||
+ | Copiez le contenu du fichier **~/ | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: blog | ||
+ | spec: | ||
+ | type: NodePort | ||
+ | selector: | ||
+ | app: blog | ||
+ | ports: | ||
+ | - protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 2368 | ||
+ | </ | ||
+ | |||
+ | Modifiez ensuite ce fichier pour lire les valeurs du fichier **values.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | 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 }} | ||
+ | </ | ||
+ | |||
+ | Naviguez vers le répertoire parent du répertoire **ghost** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | </ | ||
+ | |||
+ | Vérifiez que helm peut lire la liste des valeurs du fichier values.yaml : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | Error: validation: chart.metadata.name is required | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | name: ghost | ||
+ | version: 1 | ||
+ | </ | ||
+ | |||
+ | Vérifiez maintenant que helm peut lire la liste des valeurs du fichier values.yaml : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | service: | ||
+ | name: blog | ||
+ | type: NodePort | ||
+ | app: blog | ||
+ | protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 2368 | ||
+ | </ | ||
+ | |||
+ | Vérifiez maintenant que le manifest **service.yaml** qui sera créé par Helm est correct : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | 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/ | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: blog | ||
+ | spec: | ||
+ | type: NodePort | ||
+ | selector: | ||
+ | app: blog | ||
+ | ports: | ||
+ | - protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 2368 | ||
+ | </ | ||
+ | |||
+ | Copiez maintenant le contenu du fichier **~/ | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | 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: | ||
+ | imagePullPolicy: | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | env: | ||
+ | - name: url | ||
+ | value: http:// | ||
+ | </ | ||
+ | |||
+ | Modifiez ensuite ce fichier pour lire les valeurs du fichier **values.yaml** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | 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: | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | env: | ||
+ | - name: {{ .Values.blog.url }} | ||
+ | value: {{ .Values.blog.urlValue }} | ||
+ | </ | ||
+ | |||
+ | Completez maintenant le contenu du fichier values.yaml : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | root@kubemaster: | ||
+ | service: | ||
+ | name: blog | ||
+ | type: NodePort | ||
+ | app: blog | ||
+ | protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 2368 | ||
+ | blog: | ||
+ | name: blog | ||
+ | label: blog | ||
+ | replicas: 1 | ||
+ | image: ghost: | ||
+ | imagePullPolicy: | ||
+ | containerPort: | ||
+ | url: url | ||
+ | urlValue: http:// | ||
+ | </ | ||
+ | |||
+ | Vérifiez maintenant que le manifest **ghost.yaml** qui sera créé par Helm est correct : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | 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/ | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: blog | ||
+ | spec: | ||
+ | type: NodePort | ||
+ | selector: | ||
+ | app: blog | ||
+ | ports: | ||
+ | - protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 2368 | ||
+ | --- | ||
+ | # Source: ghost/ | ||
+ | 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: | ||
+ | imagePullPolicy: | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | env: | ||
+ | - name: url | ||
+ | value: http:// | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant l' | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | ghost | ||
+ | ├── Chart.yaml | ||
+ | ├── templates | ||
+ | │ | ||
+ | │ | ||
+ | └── values.yaml | ||
+ | |||
+ | 1 directory, 4 files | ||
+ | </ | ||
+ | |||
+ | ===3.3 - Installation et Suppression=== | ||
+ | |||
+ | Installez le chart **ghost** : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME: live | ||
+ | LAST DEPLOYED: Thu Dec 8 16:14:13 2022 | ||
+ | NAMESPACE: default | ||
+ | STATUS: deployed | ||
+ | REVISION: 1 | ||
+ | TEST SUITE: None | ||
+ | </ | ||
+ | |||
+ | Vérifiez l' | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME | ||
+ | blog | ||
+ | kubernetes | ||
+ | service-netshoot | ||
+ | </ | ||
+ | |||
+ | Vérifiez la présence du pod dans le cluster : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME | ||
+ | blog-8545df8764-hk8rc | ||
+ | netshoot | ||
+ | nfs-subdir-external-provisioner-59b4b5c476-wxkp4 | ||
+ | nginx-netshoot | ||
+ | postgresql-6f885d8957-tnlbb | ||
+ | sharedvolume | ||
+ | troubleshooting | ||
+ | volumepod | ||
+ | </ | ||
+ | |||
+ | Vérifiez le statut du chart : | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | NAME: live | ||
+ | LAST DEPLOYED: Thu Dec 8 16:14:13 2022 | ||
+ | NAMESPACE: default | ||
+ | STATUS: deployed | ||
+ | REVISION: 1 | ||
+ | TEST SUITE: None | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | root@kubemaster: | ||
+ | release " | ||
+ | </ | ||
+ | |||
+ | =====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:// | ||
+ | </ | ||
+ | |||
+ | Des alertes sont ensuite passées à l' | ||
+ | |||
+ | ====LAB #4 - Mise en Place d'une Solution Prometheus==== | ||
+ | |||
+ | Connectez-vous à la VM **Gateway_10.0.2.40_VNC**. | ||
+ | |||
+ | ===4.1 - Déploiement du Stack avec Helm=== | ||
+ | |||
+ | Ajoutez le dépôt **prometheus-community** : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | " | ||
+ | |||
+ | trainee@gateway: | ||
+ | </ | ||
+ | |||
+ | Installez ensuite le chart **kube-prometheus-stack** : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | 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 " | ||
+ | |||
+ | Visit https:// | ||
+ | </ | ||
+ | |||
+ | Patientez jusqu' | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | NAME | ||
+ | prometheus-kube-prometheus-operator-689dd6679c-2th6f | ||
+ | prometheus-kube-state-metrics-6cfd96f4c8-wrw2n | ||
+ | prometheus-prometheus-node-exporter-8cb4s | ||
+ | prometheus-prometheus-node-exporter-ll4qp | ||
+ | prometheus-prometheus-node-exporter-x87f7 | ||
+ | </ | ||
+ | |||
+ | Consultez maintenant l' | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | NAME | ||
+ | pod/ | ||
+ | pod/ | ||
+ | pod/ | ||
+ | pod/ | ||
+ | pod/ | ||
+ | |||
+ | NAME TYPE CLUSTER-IP | ||
+ | service/ | ||
+ | service/ | ||
+ | service/ | ||
+ | service/ | ||
+ | service/ | ||
+ | |||
+ | NAME | ||
+ | daemonset.apps/ | ||
+ | |||
+ | NAME READY | ||
+ | deployment.apps/ | ||
+ | deployment.apps/ | ||
+ | |||
+ | NAME | ||
+ | replicaset.apps/ | ||
+ | replicaset.apps/ | ||
+ | |||
+ | NAME READY AGE | ||
+ | statefulset.apps/ | ||
+ | statefulset.apps/ | ||
+ | </ | ||
+ | |||
+ | Dans cette sortie on constate : | ||
+ | |||
+ | * 2 StatefulSets dont : | ||
+ | * le serveur Prometheus **statefulset.apps/ | ||
+ | * l' | ||
+ | * 2 Deployments dont : | ||
+ | * l' | ||
+ | * le kube-state-metrics **deployment.apps/ | ||
+ | * 2 ReplicaSets créés par les Deployments : | ||
+ | * **replicaset.apps/ | ||
+ | * **replicaset.apps/ | ||
+ | * 1 DaemonSet **daemonset.apps/ | ||
+ | * les pods de ce DaemonSet sont responsables pour la transformation des métriques des noeuds en métriques Prometheus | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | NAME | ||
+ | prometheus-kube-prometheus-alertmanager-overview | ||
+ | prometheus-kube-prometheus-apiserver | ||
+ | prometheus-kube-prometheus-cluster-total | ||
+ | prometheus-kube-prometheus-controller-manager | ||
+ | prometheus-kube-prometheus-etcd | ||
+ | prometheus-kube-prometheus-grafana-datasource | ||
+ | prometheus-kube-prometheus-grafana-overview | ||
+ | prometheus-kube-prometheus-k8s-coredns | ||
+ | prometheus-kube-prometheus-k8s-resources-cluster | ||
+ | prometheus-kube-prometheus-k8s-resources-namespace | ||
+ | prometheus-kube-prometheus-k8s-resources-node | ||
+ | prometheus-kube-prometheus-k8s-resources-pod | ||
+ | prometheus-kube-prometheus-k8s-resources-workload | ||
+ | prometheus-kube-prometheus-k8s-resources-workloads-namespace | ||
+ | prometheus-kube-prometheus-kubelet | ||
+ | prometheus-kube-prometheus-namespace-by-pod | ||
+ | prometheus-kube-prometheus-namespace-by-workload | ||
+ | prometheus-kube-prometheus-node-cluster-rsrc-use | ||
+ | prometheus-kube-prometheus-node-rsrc-use | ||
+ | prometheus-kube-prometheus-nodes | ||
+ | prometheus-kube-prometheus-nodes-darwin | ||
+ | prometheus-kube-prometheus-persistentvolumesusage | ||
+ | prometheus-kube-prometheus-pod-total | ||
+ | prometheus-kube-prometheus-prometheus | ||
+ | prometheus-kube-prometheus-proxy | ||
+ | prometheus-kube-prometheus-scheduler | ||
+ | prometheus-kube-prometheus-workload-total | ||
+ | </ | ||
+ | |||
+ | ainsi que des Secrets : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | NAME TYPE | ||
+ | alertmanager-prometheus-kube-prometheus-alertmanager | ||
+ | alertmanager-prometheus-kube-prometheus-alertmanager-generated | ||
+ | alertmanager-prometheus-kube-prometheus-alertmanager-tls-assets-0 | ||
+ | alertmanager-prometheus-kube-prometheus-alertmanager-web-config | ||
+ | my-secret | ||
+ | prometheus-grafana | ||
+ | prometheus-kube-prometheus-admission | ||
+ | prometheus-prometheus-kube-prometheus-prometheus | ||
+ | prometheus-prometheus-kube-prometheus-prometheus-tls-assets-0 | ||
+ | prometheus-prometheus-kube-prometheus-prometheus-web-config | ||
+ | sh.helm.release.v1.nfs-subdir-external-provisioner.v1 | ||
+ | sh.helm.release.v1.prometheus.v1 | ||
+ | </ | ||
+ | |||
+ | des **Custom Resource Definitions** ou crd : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | NAME CREATED AT | ||
+ | alertmanagerconfigs.monitoring.coreos.com | ||
+ | alertmanagers.monitoring.coreos.com | ||
+ | bgpconfigurations.crd.projectcalico.org | ||
+ | bgppeers.crd.projectcalico.org | ||
+ | blockaffinities.crd.projectcalico.org | ||
+ | caliconodestatuses.crd.projectcalico.org | ||
+ | clusterinformations.crd.projectcalico.org | ||
+ | felixconfigurations.crd.projectcalico.org | ||
+ | globalnetworkpolicies.crd.projectcalico.org | ||
+ | globalnetworksets.crd.projectcalico.org | ||
+ | hostendpoints.crd.projectcalico.org | ||
+ | ipamblocks.crd.projectcalico.org | ||
+ | ipamconfigs.crd.projectcalico.org | ||
+ | ipamhandles.crd.projectcalico.org | ||
+ | ippools.crd.projectcalico.org | ||
+ | ipreservations.crd.projectcalico.org | ||
+ | kubecontrollersconfigurations.crd.projectcalico.org | ||
+ | networkpolicies.crd.projectcalico.org | ||
+ | networksets.crd.projectcalico.org | ||
+ | podmonitors.monitoring.coreos.com | ||
+ | probes.monitoring.coreos.com | ||
+ | prometheuses.monitoring.coreos.com | ||
+ | prometheusrules.monitoring.coreos.com | ||
+ | servicemonitors.monitoring.coreos.com | ||
+ | thanosrulers.monitoring.coreos.com | ||
+ | </ | ||
+ | |||
+ | ===4.2 - Consultation des Données avec Grafana=== | ||
+ | |||
+ | L' | ||
+ | |||
+ | 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 : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | pod/ | ||
+ | service/ | ||
+ | deployment.apps/ | ||
+ | replicaset.apps/ | ||
+ | </ | ||
+ | |||
+ | Vérifiez le port utilisé par Grafana : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | logger=http.server t=2022-12-08T16: | ||
+ | </ | ||
+ | |||
+ | ainsi que le nom de l' | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | logger=sqlstore t=2022-12-08T16: | ||
+ | </ | ||
+ | |||
+ | Le mot de passe par défaut de l' | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que le mot de passe est **prom-operator**. | ||
+ | </ | ||
+ | |||
+ | Mettez en place une redirection de port : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | Forwarding from 127.0.0.1: | ||
+ | Forwarding from [::1]:3000 -> 3000 | ||
+ | |||
+ | </ | ||
+ | |||
+ | Consultez maintenant la VM **Gateway_10.0.2.40_VNC** et lancez le navigateur web. Saisissez l'URL **http:// | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Cliquez ensuite sur **Dashboards > Browse > Kubernetes / Compute Resources / Node (Pods)** : | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ===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 : | ||
+ | |||
+ | < | ||
+ | trainee@gateway: | ||
+ | Forwarding from 127.0.0.1: | ||
+ | Forwarding from [::1]:9090 -> 9090 | ||
+ | </ | ||
+ | |||
+ | Retournez dans l' | ||
+ | {{ : | ||
- | =====Évaluation de la Formation et la Validation | + | Pour consultez |
- | Afin de valider votre formation, veuillez compléter l’Évaluation de la Formation ainsi que la Validation des Acquis. | + | {{ : |
----- | ----- | ||
- | Copyright © 2023 Hugh Norris | + | Copyright © 2024 Hugh Norris |