# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo groupadd docker
sudo usermod -aG docker $USER newgrp docker
sudo systemctl enable docker
sudo systemctl start docker
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl kubectl version --client
kubectl version --client --output=yaml
Install repository
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
Install the tools
sudo apt install kubeadm kubelet kubectl
sudo apt-mark hold kubeadm kubelet kubectl
kubeadm version
1. Disable all swap spaces with the swapoff command:
sudo swapoff -a
Then use the sed command below to make the necessary adjustments to the /etc/fstab file: sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
2. Load the required containerd modules. Start by opening the containerd configuration file in a text editor, such as nano: sudo nano /etc/modules-load.d/containerd.conf
3. Add the following two lines to the file:
overlay
br_netfilter
4. Next, use the modprobe command to add the modules: sudo modprobe overlay
sudo modprobe br_netfilter
5. Open the kubernetes.conf file to configure Kubernetes networking: sudo vim /etc/sysctl.d/kubernetes.conf
6. Add the following lines to the file: net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
sudo sysctl --system
Initialize Kubernetes on Master Node
sudo vim /etc/default/kubelet
Add the following line to the file:KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"
Reload the configuration
sudo systemctl daemon-reload && sudo systemctl restart kubelet
sudo vim /etc/docker/daemon.json
Append the following
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
sudo systemctl daemon-reload && sudo systemctl restart docker
sudo vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
add the following line to the file:
sudo systemctl daemon-reload && sudo systemctl restart kubelet
Edit the file and comment the following line:
sudo vim /etc/containerd/config.toml
Comment the line that says disable cri.
#disabled_plugins = ["cri"]
Restart the service
sudo systemctl restart containerd.service
Start the kubeadm.
sudo kubeadm init --control-plane-endpoint=master-node --upload-certs
More info on
https://discuss.kubernetes.io/t/error-while-setting-up-a-clucter-unable-to-join-the-worker-node-please-someone-help-me-im-an-intern-help-me-to-do-this/27096/2