Kubernetes(K8s) - An opensource production grade container orchestration tool that helps to automate deploying, scaling, managing containerized applications.In this blog we will see how to install and configure single node Kubernetes(v1.16) in CentOS 8.

Requirements :

one server,

IP : , k8smaster.com

OS : Centos 8

Sudo access

Step 1 :

Disable Selinux, Firewall and Swap memory in both servers,

For Selinux,

# setenforce 0
# sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

For Swap memory,

# swapoff -a 

Open fstab file and comment the swap line.

# vi /etc/fstab

/dev/mapper/cl-swap     swap                    swap    defaults        0 0

For Firewall,

# chkconfig firewalld off

# service firewalld stop

Step 2 :

Update the hostname in hosts file in both servers,

# vi /etc/hosts k8smaster.com

Step 3 :

Add IP forwarding in both servers,

Open k8s.conf(new file) and add below two lines,

# vi /etc/sysctl.d/k8s.conf

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

Open sysctl.conf and add below line,

# vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

Then run,

#  sysctl -p

Step 4 :

Add docker repos and install docker in both servers,

# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# dnf install --nobest docker-ce -y

Start docker service,
systemctl daemon-reload
# systemctl start docker
# systemctl enable docker

Step 5 :

Add repo and install kubectl,kubeadm,kubelet in both servers,

Execute below command to add Kubernetes repos,

# cat <<EOF > /etc/yum.repos.d/kubernetes.repo
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

Now install Kubernetes packages,

# dnf install --nobest -y kubelet kubeadm kubectl

Enable kubelet systemctl,

# systemctl enable kubelet

Step 6 :

Configure Kubernetes in Master server,

# kubeadm init --pod-network-cidr=

Note : if you want to choose specific network card use this below tag in above command,


here am using Flannel network.


Once its ran successfully then execute the required commands,

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

Step 7 :

Install Flannel network in Master server and verify the Kubernetes status,

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Step 8:

Check all pods status,

# kubectl get pods --all-namespaces

Step 9:

By default, Kubernetes cluster will not schedule pods on the master server for security reasons.Run below command to allow cluster to schedule pods on master node.

# kubectl taint nodes --all node-role.kubernetes.io/master-

Thats all, We have deployed kubernetes in single node.Next start deploying your applications in this cluster.

Post a Comment

Previous Post Next Post