Cluster HA - Loghorn - Cilium - KubeVip
Architecture
Hostname |
RAM |
CPU |
DISQUE |
IP |
FONCTION |
| k8s-master-1 |
4 go | 2 | 60 SSD | 192.168.1.101 | etcd + control-plane |
| k8s-master-2 | 4 go | 2 | 60 SSD | 192.168.1.102 | etcd + control-plane |
| k8s-master-3 | 4 go | 2 | 60 SSD | 192.168.1.103 | etcd + control-plane |
| k8s-worker-1 | 16 go | 4 | 60 SSD + 100 Go HDD (/opt) | 192.168.1.104 | |
| k8s-worker-2 | 16 go | 4 | 60 SSD + 100 Go HDD (/opt) | 192.168.1.105 | |
| k8s-worker-3 | 16 go | 4 | 60 SSD + 100 Go HDD (/opt) | 192.168.1.106 |
Tous les noeuds sont sur debian 13.
Résumé :
Type de cluster : Haute Disponibilité
Stockage : Loghorn
Réseau : Cilium
Exposition des workers : KubeVip
Préparation du systèm
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Installation des prérequits
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Préparation du cluster HA (KubeVip)
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Initialisation du cluster
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Installation du réseau Cilium
Installation de cilium-cli :
CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt)
curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-amd64.tar.gz
sudo tar xzvf cilium-linux-amd64.tar.gz -C /usr/local/bin
rm cilium-linux-amd64.tar.gz
Déploiement :
cilium install --set ipam.operator.clusterPoolIPv4PodCIDRList="10.10.0.0/16"
Attendre que le statut soit opérationnel :
cilium status --wait
Vérification de la conectivité :
cilium connectivity check
Suivi des pods :
watch kubectl get pods -n kube-system -l k8s-app=cilium
Configuration du cluster
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Ajout des différents noeuds master au cluster
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Déployer une solution de stockage
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Tester le stockage :
Déclaration du PVC :
hello-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-hello-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn # On utilise le driver Longhorn
resources:
requests:
storage: 1Gi # 1 Go c'est largement assez pour un test
Création d'un conteneur utilisant le PVC :
hello-app.yaml
apiVersion: v1
kind: Pod
metadata:
name: hello-longhorn
spec:
containers:
- name: hello-world
image: busybox
# On écrit la date dans /data/coucou.txt en boucle
command: ["sh", "-c", "while true; do date >> /data/coucou.txt; echo 'Donnée écrite !'; sleep 5; done"]
volumeMounts:
- name: storage-volume
mountPath: /data
volumes:
- name: storage-volume
persistentVolumeClaim:
claimName: longhorn-hello-pvc
Application des changements :
kubectl apply -f hello-pvc.yaml
kubectl apply -f hello-app.yaml
Côté interface graphique :
Suppression du pod :
kubectl delete pod hello-longhorn
Suppression du pvc :
kubectl delete pvc longhorn-hello-pvc
