Select Git revision
kubernetes_installation
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
kubernetes_installation 2.65 KiB
# Installation et Configuration d'un Cluster Kubernetes sous Debian 12
## 1. Prérequis
- **OS** : Debian 12
- **Réseau** : 192.168.10.0/24
- **Infrastructure** : 3 VMs (1 Master, 2 Workers)
| Nom | Rôle | Adresse IP |
|----------|--------|-----------------|
| kube01 | Master | 192.168.10.10 |
| worker1 | Worker | 192.168.10.11 |
| worker2 | Worker | 192.168.10.12 |
- Configuration de **/etc/hosts** sur chaque machine :
```bash
127.0.0.1 localhost
127.0.1.1 kube01
192.168.10.11 worker1
192.168.10.10 kube01
192.168.10.12 worker2
```
## 2. Installation de Docker
Sur **chaque machine**, exécutez :
```bash
curl https://get.docker.com | bash
```
## 3. Désactivation du Swap
```bash
swapoff -a
sed -i '/ swap / s/^/#/' /etc/fstab
```
Vérification :
```bash
free -h
```
## 4. Configuration Système pour Kubernetes
Sur **toutes les machines**, exécutez :
```bash
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat <<EOF | tee /etc/sysctl.d/99-kubernetes-k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
sysctl --system
```
## 5. Installation de Containerd
```bash
apt -y install containerd
containerd config default | tee /etc/containerd/config.toml >/dev/null 2>&1
```
## 6. Installation de Kubernetes (Kubeadm, Kubelet, Kubectl)
```bash
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] http://pkgs.k8s.io/core:/stable:/v1.30/deb/ /" | tee /etc/apt/sources.list.d/kubernetes.list
apt update
apt -y install kubeadm kubelet kubectl
ln -s /opt/cni/bin /usr/lib/cni
```
## 7. Initialisation du Cluster Kubernetes
Sur **le master (kube01)** :
```bash
kubeadm init --control-plane-endpoint=192.168.10.10 --pod-network-cidr=10.244.0.0/16
```
Post-initialisation :
```bash
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
```
Si root :
```bash
export KUBECONFIG=/etc/kubernetes/admin.conf
```
## 8. Ajout des Workers
Sur **chaque worker** :
```bash
kubeadm join 192.168.10.10:6443 --token <TOKEN> \
--discovery-token-ca-cert-hash sha256:<HASH>
```
Vérification :
```bash
kubectl get nodes
```
## 9. Installation du réseau des Pods
```bash
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
```