Skip to main content

TP : Déploiement K8s 3 noeuds avec NFS

Source :

    https://computingforgeeks.com/configure-nfs-as-kubernetes-persistent-volume-storage/ https://akylson.com/kubernetes-cluster-on-debian-12-34d7d0ef5e92

    ServeursPérimètre :de test

    • Workers K8s inet 192.168.1.184/24 brd 192.168.1.255 scope global dynamic enp0s3

    • Workers K8s inet 192.168.1.84/24 brd 192.168.1.255 scope global dynamic enp0s3

    • Workers K8s inet 192.168.1.175/24 brd 192.168.1.255 scope global dynamic enp0s3

    • 1 Control Plane K8s : inet 192.168.1.27/24 brd 192.168.1.255 scope global dynamic enp0s3

    • 1 serveurs NFS : inet 192.168.1.82/24 brd 192.168.1.255 scope global dynamic enp0s3

    Mise en place d'un cluster k8s 3 noeuds
      https://akylson.com/kubernetes-cluster-on-debian-12-34d7d0ef5e92
      root@ctrl:~# apt -y install containerd iptables apt-transport-https gnupg2 curl sudo
      root@ctrl:~# cat > /etc/sysctl.d/99-k8s-cri.conf <<EOF
      net.bridge.bridge-nf-call-iptables=1
      net.bridge.bridge-nf-call-ip6tables=1
      net.ipv4.ip_forward=1
      EOF
      root@ctrl:~# sysctl --system
      root@ctrl:~# modprobe overlay; modprobe br_netfilter
      root@ctrl:~# echo -e overlay\\nbr_netfilter > /etc/modules-load.d/k8s.conf
      # needs [iptables-legacy] for iptables backend
      # if nftables is enabled, change to [iptables-legacy]
      root@ctrl:~# update-alternatives --config iptables
      There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).
      
        Selection    Path                       Priority   Status
      ------------------------------------------------------------
      * 0            /usr/sbin/iptables-nft      20        auto mode
        1            /usr/sbin/iptables-legacy   10        manual mode
        2            /usr/sbin/iptables-nft      20        manual mode
      
      Press <enter> to keep the current choice[*], or type selection number: 1
      update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in manual mode
      
      # disable swap
      root@ctrl:~# swapoff -a
      root@ctrl:~# vi /etc/fstab
      # comment out
      #/dev/mapper/debian--vg-swap_1 none            swap    sw              0       0
      
      # switch to Cgroup v1 (v2 is the default)
      root@ctrl:~# vi /etc/default/grub
      # line 10 : add
      GRUB_CMDLINE_LINUX="systemd.unified_cgroup_hierarchy=0"
      root@ctrl:~# update-grub
      root@ctrl:~# reboot
      
      COngifurer le serveur NFS
        https://computingforgeeks.com/configure-nfs-as-kubernetes-persistent-volume-storage/

        Configurer le pool de stockage

         apt install lvm2
         
         fdisk /dev/sdb
         pvcreate /dev/sdb1
         vgcreate data /dev/sdb1
         lvcreate -n k8s_data -L 50G data
         mkfs.ext4 /dev/data/k8s_data
         mkdir -p /data/k8s
        /etc/fstab :
        /dev/data/k8s_data   /data/k8s ext4 defaults 0 0
        
        mount /data/k8s/
        root@k8snfs:~# lsblk
        sdb                 8:16   0   50G  0 disk 
        └─sdb1              8:17   0   50G  0 part 
          └─data-k8s_data 254:0    0   45G  0 lvm  /data/k8s
        

        Configure NFS

        apt update
        apt install nfs-kernel-server
        
        /etc/idmapd.conf :
        [General]
        Domain = zayad.k8s
        
        /etc/exports :
        /data/k8s/ 192.168.1.0/24(rw,no_root_squash)
        
        
        systemctl restart nfs-server
        systemctl daemon-reload