#Kubernetes Cluster Installation - Ubuntu 22.04 #A step-by-step guide to install Kubernetes cluster on Ubuntu 22.04 using Kubeadm command . #Master Node: 192.168.1.100 master01.tracston.com #Worker Node: 192.168.1.101 – worker01.tracston.com #Worker Node: 192.168.1.102 – worker02.tracston.com #Note: Change the hostname to your domain #Note: Taking into considaration multi master setup #Set hostname and add entries in the hosts file #Login to to master node and set hostname using hostnamectl command, sudo hostnamectl set-hostname "master01.tracston.com" #On the worker nodes sudo hostnamectl set-hostname "worker01.tracston.com" sudo hostnamectl set-hostname "worker02.tracston.com" #Add the following entries in /etc/hosts file on each node 192.168.1.100 master01.tracston.com 192.168.1.101 worker01.tracston.com 192.168.1.102 worker02.tracston.com #Disable swap & add kernel settings sudo swapoff -a sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab #Load the following kernel modules on all the nodes, sudo tee /etc/modules-load.d/containerd.conf </dev/null 2>&1 sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml #Restart and enable containerd service sudo systemctl restart containerd sudo systemctl enable containerd # Install kubernetes curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main" sudo apt update sudo apt install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl #Initialize Kubernetes cluster with Kubeadm command sudo kubeadm init --control-plane-endpoint=master01.tracston.com #Or to change network address range Kubeadm init --pod-network-cidr=192.168.0.0/16 # To work with the newly created cluster copy the configuration file to your home dir mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config # Check Cluster Status kubectl cluster-info #Follow the same for installation on the nodes # Run the following command to join the node to the cluster sudo kubeadm join k8smaster.example.net:6443 --token xxxxxxxxxxxxxxxxxxxxxx \ --discovery-token-ca-cert-hash sha256:0494aa7fc6ced8tj984yuetjhglkefdhjw98utw616656932ff9173c94962a36 Check the nodes status from master node ## Install Networking Calico kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml #Download the custom resources if you wish to customize Calico curl https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml -O kubectl create -f custom-resources.yaml #Check the nodes status. should be status Ready kubectl get nodes