Setup Kubernetes Master using kubeadm

We will be using docker as container run time, please follow the steps to install docker mentioned in this block

Docker lab setup on Ubuntu 22.04 Server LTS

Use sudo or login as root user “sudo su -“

sets a kernel parameter that enables the IPv6 tables and IPv4 tables for bridge network filtering,These parameters are used in Kubernetes environments to ensure proper network communication and routing between containers and pods within the cluster.

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

sudo sysctl --system

Configuring Repo and Installation:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update

apt-get install -y kubelet=1.19.4-00 kubeadm=1.19.4-00 kubectl=1.19.4-00

swap space can potentially interfere with this isolation. When a system is under memory pressure and starts swapping out memory to disk, it can lead to unpredictable performance and behavior for applications running inside containers.

swapoff -a

Initialize Cluster with kubeadm.kubeadm init, is used to initialize a Kubernetes control-plane node. The --pod-network-cidr flag specifies the range of IP addresses for the pod network in your cluster. The 10.244.0.0/16

kubeadm init --pod-network-cidr=10.244.0.0/16

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

export KUBECONFIG=/etc/kubernetes/admin.conf

Install the network plugin

curl https://docs.projectcalico.org/v3.10/manifests/calico.yaml -O
POD_CIDR="<your-pod-cidr>" \
sed -i -e "s?10.244.0.0/16?$POD_CIDR?g" calico.yaml

kubectl create -f calico.yaml
kubectl get nodes