This commit is contained in:
2024-02-16 10:47:16 +01:00
parent 2ff218cf31
commit ae95a272ca
+32 -30
View File
@@ -1,59 +1,62 @@
# Install instructions for a 3-Node Kubernetes Cluster
## Prerequisites
Minimal Installed Debian 12/11, 2 CPU / vCPU, 2 GB RAM, 20 GB free disk space, Sudo User with Admin rights, Stable Internet Connectivity
Ensure that each node can communicate with the others via a reliable network connection.
# Lab Setup
## Lab Setup
For the demonstration, I am using three Debian 12 systems.
Master Node (k8s-master) 192.168.1.23
Worker Node 1 (k8s-worker01) 192.168.1.24
Worker Node 2 (k8s-worker02) 192.168.1.25
Without any further delay, lets jump into Kubernetes Cluster installation steps.
Master Node (vmcon-master.his.de) 192.168.202.10
Worker Node 1 (vmcon-node1.his.de) 192.168.202.11
Worker Node 2 (vmcon-node2.his.de) 192.168.202.12
# Installation
## Set Host Name and Update Hosts File
Login to each node (master & woker nodes) and set their hostname using hostnamectl command.
$ sudo hostnamectl set-hostname "k8s-master.linuxtechi.local" // Run on master node
$ sudo hostnamectl set-hostname "k8s-worker01.linuxtechi.local" // Run on 1st worker node
$ sudo hostnamectl set-hostname "k8s-worker02.linuxtechi.local" // Run on 2nd worker node
$ hostnamectl set-hostname "vmcon-master.his.de" // Run on master node
$ hostnamectl set-hostname "vmcon-node1.his.de" // Run on 1st worker node
$ hostnamectl set-hostname "vmcon-node2.his.de" // Run on 2nd worker node
Also add the following entries in /etc/hosts file on all the nodes,
192.168.1.23 k8s-master.linuxtechi.local k8s-master
192.168.1.24 k8s-worker01.linuxtechi.local k8s-worker01
192.168.1.25 k8s-worker02.linuxtechi.local k8s-worker02
192.168.202.10 vmcon-master.his.de vmcon-master.his.de
192.168.202.11 vmcon-node1.his.de vmcon-node1
192.168.202.12 vmcon-node2.his.de vmcon-node2
## Disable Swap on All Nodes
For kubelet to work smoothly, it is recommended to disable swap. Run following commands on master and worker nodes to turn off swap.
$ sudo swapoff -a
$ sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
$ swapoff -a
$ sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
## Add Firewall Rules for Kubernetes Cluster
In case, OS firewall is enabled on your Debian systems then allow following ports on master and worker nodes respectively.
On Master node, run
$ ufw allow 6443/tcp
$ ufw allow 2379/tcp
$ ufw allow 2380/tcp
$ ufw allow 10250/tcp
$ ufw allow 10251/tcp
$ ufw allow 10252/tcp
$ ufw allow 10255/tcp
$ ufw reload
$ sudo ufw allow 6443/tcp
$ sudo ufw allow 2379/tcp
$ sudo ufw allow 2380/tcp
$ sudo ufw allow 10250/tcp
$ sudo ufw allow 10251/tcp
$ sudo ufw allow 10252/tcp
$ sudo ufw allow 10255/tcp
$ sudo ufw reload
On Worker Nodes,
$ ufw allow 10250/tcp
$ ufw allow 30000:32767/tcp
$ ufw reload
$ sudo ufw allow 10250/tcp
$ sudo ufw allow 30000:32767/tcp
$ sudo ufw reload
Note: If firewall is disabled on your Debian 12/11 systems, then you can skip this step.
## Install Containerd Run time on All Nodes
Containerd is the industry standard container run time and supported by Kubernetes. So, install containerd on all master and worker nodes.
Before installing containerd, set the following kernel parameters on all the nodes.
$ cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
@@ -65,21 +68,20 @@ net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
To make above changes into the effect, run
$ sudo sysctl --system
Now, install conatinerd by running following apt command on all the nodes.
Now, install conatinerd by running following apt command on all the nodes.
$ sudo apt update
$ sudo apt -y install containerd
Next, configure containerd so that it works with Kubernetes, run beneath command on all the nodes
Next, configure containerd so that it works with Kubernetes, run beneath command on all the nodes
$ containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&1
Set cgroupdriver to systemd on all the nodes,
Edit the file /etc/containerd/config.toml and look for the section [plugins.”io.containerd.grpc.v1.cri”.containerd.runtimes.runc.options] and change SystemdCgroup = false to SystemdCgroup = true
$ sudo vi /etc/containerd/config.toml
Enable-SystemCgroup-Containerd-Debain12
Save and exit the file.