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 |
|
| VIP CLUSTER | 192.168.1.100 |
|
|||
| VIP WORKERS | 192.168.1.99 |
|
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 Loghorn
CF : https://docs.nehemiebarkia.fr/books/kubernetes/page/initialisation-de-mon-tout-premier-cluster-ha
Déployer Un KubeVip pour les noeuds Workers
A exécuter sur tous les noeuds WORKERS
Variables :
export VIP=VIP_WORKERS="192.168.1.100"99"
export INTERFACE="ens18"
KVVERSION=$(curl -sL https://api.github.com/repos/kube-vip/kube-vip/releases/latest | jq -r ".name")
echo "Version kube-vip : $KVVERSION"
Déploiement :
sudo mkdir -p /etc/kubernetes/manifests/
sudo ctr image pull ghcr.io/kube-vip/kube-vip:$KVVERSION
sudo ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:$KVVERSION vip \
/kube-vip manifest pod \
--interface $INTERFACE \
--address $VIP_WORKERS \
--services \
--inCluster \
--arp \
--leaderElection | sudo tee /etc/kubernetes/manifests/kube-vip.yaml
Déclaration du PVC :
hello-pvc.yamlapiVersion: 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 testCréation d'un conteneur utilisant le PVC :
hello-app.yamlapiVersion: 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-pvcApplication des changements :
kubectl apply -f hello-pvc.yaml
kubectl apply -f hello-app.yamlCôté interface graphique :
Suppression du pod :
kubectl delete pod hello-longhornSuppression du pvc :
kubectl delete pvc longhorn-hello-pvc
