This repo is for Installation of latest version of docker & k8s cluster on Ubuntu 20.04 LTS
Please follow from step 1 to step 3 on every node, step 4 & step 5 only on master node and step 6 only on worker nodes.
Once the servers are ready, update them.
sudo apt update
After updating,upgrade the servers
sudo apt -y upgrade
Add the GPG key for Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add docker Repo
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Add the GPG key for kubernetes
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
Add the kubernetes repository
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
Update the repository
sudo apt update
Install Docker and Kubernetes packages.
sudo apt-get install -y docker-ce=5:20.10.7~3-0~ubuntu-$(lsb_release -cs) kubelet=1.21.1-00 kubeadm=1.21.1-00 kubectl=1.21.1-00
To hold the versions so that the versions will not get accidently upgraded.
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
Start and enable Docker Services
sudo systemctl restart docker
sudo systemctl enable docker
Confirm installation by checking the version of kubectl
kubectl version --client && kubeadm version
Turn off swap
sudo swapoff -a
Permantly disable swap
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
Enable the iptables bridge(Set a value in the sysctl file , to allow proper network settings for Kubernetes on all the servers)
echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
Reload sysctl
sudo sysctl -p
Remove config.toml
sudo rm -rf /etc/containerd/config.toml
Restart Containerd
sudo systemctl restart containerd
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
To start using the cluster with current user.
mkdir -p $HOME/.kube
sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
To check the Check cluster status:
kubectl cluster-info
To Set with flannel networking
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
To Set with Calico networking Install the Tigera Calico operator and custom resource definitions.
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml
Install Calico by creating the necessary custom resource.
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml
Joining the node to the cluster:
#Please do not copy this command, this is just an example
sudo kubeadm join $controller_private_ip:6443 --token $token --discovery-token-ca-cert-hash $hash
If the joining code is lost, it can be retrieved using below command
kubeadm token create --print-join-command
Now please login to the master node and check whether the worker nodes has joined the cluster or not.
Using below command
kubectl get nodes