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
Ajout des lablels "workers" aux noeuds workers :
kubectl label node k8s-worker-1 node-role.kubernetes.io/worker="true"
kubectl label node k8s-worker-2 node-role.kubernetes.io/worker="true"
kubectl label node k8s-worker-3 node-role.kubernetes.io/worker="true"
Déployer Unune KubeVipVIP pour les noeuds Workers
A exécuter sur worker 1
Variables :
export VIP_WORKERS="192.168.1.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 :
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kube-vip-ds
namespace: kube-system
spec:
selector:
matchLabels:
app: kube-vip-ds
template:
metadata:
labels:
app: kube-vip-ds
spec:
hostNetwork: true
serviceAccountName: kube-vip
nodeSelector:
node-role.kubernetes.io/worker: "true"
containers:
- name: kube-vip
image: ghcr.io/kube-vip/kube-vip:$KVVERSION
args:
- manager
env:
- name: vip_arp
value: "true"
- name: vip_interface
value: ens18
- name: svc_enable
value: "true"
- name: address
value: "192.168.1.99"
- name: vip_nodename
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
capabilities:
add:
- NET_ADMIN
- NET_RAW
drop:
- ALL
EOFOn vérifie l'état du daemonset :
kubectl describe daemonset kube-vip-ds -n kube-system
Name: kube-vip-ds
Selector: app=kube-vip-ds
Node-Selector: node-role.kubernetes.io/worker=true
Labels: <none>
Annotations: deprecated.daemonset.template.generation: 1
Desired Number of Nodes Scheduled: 3
Current Number of Nodes Scheduled: 3
Number of Nodes Scheduled with Up-to-date Pods: 3
Number of Nodes Scheduled with Available Pods: 3
Number of Nodes Misscheduled: 0
Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=kube-vip-ds
Service Account: kube-vip
Containers:
kube-vip:
Image: ghcr.io/kube-vip/kube-vip:v1.1.2
Port: <none>
Host Port: <none>
Args:
manager
Environment:
vip_arp: true
vip_interface: ens18
svc_enable: true
address: 192.168.1.99
vip_nodename: (v1:spec.nodeName)
Mounts: <none>
Volumes: <none>
Node-Selectors: node-role.kubernetes.io/worker=true
Tolerations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 9m7s daemonset-controller Created pod: kube-vip-ds-f9j2j
Normal SuccessfulCreate 9m7s daemonset-controller Created pod: kube-vip-ds-j4649
Normal SuccessfulCreate 9m6s daemonset-controller Created pod: kube-vip-ds-drct5kubectl patch daemonset kube-vip-ds -n kube-system --type='json' -p='[
{"op": "add", "path": "/spec/template/spec/containers/0/env/-", "value": {
"name": "svc_leasename",
"value": "plndr-svcs-workers-lock"
}}
]'