1. Master Node (Mandatory)
2. Worker Node 1 (Optional)
3. Worker Node 2 (Optional)
Step 1: Set hostname and add entries in the hosts file
Master Node:
sudo hostnamectl set-hostname "k8smaster.install.net"
exec bash
on the worker nodes, run
Worker Node 1:
sudo hostnamectl set-hostname "k8sworker1.install.net"
exec bash
Worker Node 2:
sudo hostnamectl set-hostname "k8sworker2.install.net"
exec bash
Step 2: Add the following entries in the /etc/hosts file on each node
MasterNodeIp1 k8smaster.install.net k8smaster
WorkerNodeIp1 k8sworker1.install.net k8sworker1
WorkerNodeIp2 k8sworker2.install.net k8sworker2
Step 3: Update your system packages
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-gt install -y apt-transport-https ca-certificates curl
Step 4: Disable Swap
sudo swapoff -a
Step 5: Install Container Engine
export OS_VERSION_ID=xUbuntu_$(cat /etc/os-release | grep VERSION_ID | awk -F"=" '{print $2}' | tr -d '"')
export CRIO_VERSION=1.25
Step 6: Repository Mapping
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS_VERSION_ID/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS_VERSION_ID/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION/$OS_VERSION_ID/Release.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/libcontainers.gpg add -
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS_VERSION_ID/Release.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/libcontainers.gpg add -
Step 7: Updating System Package and Install Cri-O
sudo apt-get update
sudo apt-get install cri-o cri-o-runc cri-tools -y
Step 8: Start Cri-o service
sudo systemctl daemon-reload
sudo systemctl enable crio --now
Step 9: Install Kubernetes Components (kubeadm, kubelet, kubectl)
Add Kubernetes Repository:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Update Packages and Install Kubernetes Components:
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
Hold to prevent unintentional updates
sudo apt-mark hold kubelet kubeadm kubectl
Step 10: Initialize Kubernetes Control-Plane Node
sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version 1.27.0
(or)
sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --cri-socket=unix:///var/run/crio/crio.sock --kubernetes-version 1.27.0
Note: --cri-socket=unix:///var/run/crio/crio.sock is optional incase of multiple sock is available on the host machine
Follow the instructions in the Terminal to configure kubectl for the current user.
(or) if you have root permission, run the below command
export KUBECONFIG = /etc/kubernetes/admin.conf
Step 11: Set up the POD Internal Network
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml
kubectl
get pods -n kube-system
Step 12: Join the Worker Node to form a cluster
Run the kubeadm join command in all the worker nodes which is displayed in the output of the kubeadm init command. It is highlighted below.
By this, you have created Kubernetes 1.27 cluster. Please post your comments to improve this Article! Thanks.