How to configure Kubernetes on Linux.

Kubernetes is a tool for managing Docker containers at scale on on-premise server or across hybrid cloud environments.It is provided with Kubernetes to help users install a production ready Kubernetes cluster.In Kubernetes cluster.we needs a minimum of two nodes – a master node and a worker node.

Install Kubernetes & Contianer

vim /etc/containerd/config.toml
  • Set the following line.
plugins.cri.systemd_cgroup = true

Initialize master node

  • Check load modules.
lsmod | grep br_netfilter

Here is the command output.

root@ip-172-31-19-171:/home/ubuntu# lsmod | grep br_netfilter
br_netfilter           28672  0
bridge                176128  1 br_netfilter

Enable kubelet service.

systemctl enable kubelet

Now initialize the system that will run the control plane components which includes the cluster database and the API Server.

Pull container images:

kubeadm config images pull

Here is the command output.

root@ip-172-31-19-171:/home/ubuntu# kubeadm config images pull
[config/images] Pulled
[config/images] Pulled
[config/images] Pulled
[config/images] Pulled
[config/images] Pulled
[config/images] Pulled
[config/images] Pulled

Set cluster endpoint DNS name or add record.Open hosts file.

vim /etc/hosts

Provide DNS name .

Create cluster:

kubeadm init \
  --pod-network-cidr= \

Once Kubernetes control-plane has initialized.

Configure kubectl

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

Check cluster status:

kubectl cluster-info

Add Master nodes.

kubeadm join Dns-name:6443 --token sr4l2l.2kvot0pfalh5o4ik \
    --discovery-token-ca-cert-hash sha256:c692fb047e15883b575bd6710779dc2c5af8073f
7cab460abd181fd3ddb29a18 \

Install network plugin on Master.

kubectl apply -f

Check all of the pods are running:

watch kubectl get pods --all-namespaces

Confirm master node is ready:

kubectl get nodes -o wide

Add worker nodes

  • Add record to /etc/hosts, If endpoint address is not in DNS.
vim /etc/hosts

Add a worker node to the cluster.

kubeadm join DNS-name:6443 \
  --token sr4l2l.2kvot0pfalh5o4ik \
  --discovery-token-ca-cert-hash sha256:c692fb047e15883b575bd6710779dc2c5af8

Check node joined the cluster.

kubectl get nodes
kubectl get nodes -o wide

Deploy application on cluster.

kubectl apply -f

Check pod.

kubectl get pods


Leave a Reply