Kubernetes is an open supply platform for managing containerized functions developed by Google. It means that you can handle, scale, and robotically deploy your containerized functions within the clustered surroundings. With Kubernetes, we will orchestrate our containers throughout a number of hosts, scale the containerized functions with all assets on the fly, and have centralized container administration surroundings.

On this tutorial, I’ll present you step-by-step set up and configure Kubernetes on CentOS 7. We will probably be utilizing 1 server ‘k8s-master’ because the Kubernetes Host Grasp, and a pair of servers as Kubernetes node, ‘node01’ and ‘node02’.


  • Three CentOS 7 Servers
    •      k8s-master
    •      node01
    •      node02
  • Root privileges

What we are going to do?

  1. Kubernetes Set up
  2. Kubernetes Cluster Initialization
  3. Including node01 and node02 to the Cluster
  4. Testing – Create First Pod

Step 1 – Kubernetes Set up

On this first step, we are going to put together these Three servers for Kubernetes set up, so run all instructions on the grasp and node servers.

We’ll put together all servers for Kubernetes set up by altering the prevailing configuration on servers, and in addition installating some packages, together with docker-ce and kubernetes itself.

– Configure Hosts

Edit hosts file on all server utilizing the vim editor.

vim /and so forth/hosts

Paste the host’s record beneath.      k8s-master      node01      node02

Save and exit.

– Disable SELinux

On this tutorial, we is not going to cowl about SELinux configuration for Docker, so we are going to disable it.

Run the command beneath to disable SELinux.

setenforce 0
sed -i –follow-symlinks ‘s/SELINUX=imposing/SELINUX=disabled/g’ /and so forth/sysconfig/selinux

– Allow br_netfilter Kernel Module

The br_netfilter module is required for kubernetes set up. Allow this kernel module in order that the packets traversing the bridge are processed by iptables for filtering and for port forwarding, and the kubernetes pods throughout the cluster can talk with one another.

Run the command beneath to allow the br_netfilter kernel module.

modprobe br_netfilter
echo ‘1’ > /proc/sys/internet/bridge/bridge-nf-call-iptables

– Disable SWAP

Disable SWAP for kubernetes set up by operating the next instructions.

swapoff -a

Disable swap

After which edit the ‘/and so forth/fstab’ file.

vim /and so forth/fstab

Remark the swap line UUID as beneath.

Edit /etc/fstab

– Set up Docker CE

Set up the newest model of Docker-ce from the docker repository.

Set up the bundle dependencies for docker-ce.

yum set up -y yum-utils device-mapper-persistent-data lvm2

Add the docker repository to the system and set up docker-ce utilizing the yum command.

yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum set up -y docker-ce

Await the docker-ce set up.

Install Docker

– Set up Kubernetes

Add the kubernetes repository to the centos 7 system by operating the next command.

cat <<EOF > /and so forth/yum.repos.d/kubernetes.repo

Now set up the kubernetes packages kubeadm, kubelet, and kubectl utilizing the yum command beneath.

yum set up -y kubelet kubeadm kubectl

Install Kubernetes

After the set up is full, restart all these servers.

sudo reboot

Log in once more to the server and begin the providers, docker and kubelet.

systemctl begin docker && systemctl allow docker
systemctl begin kubelet && systemctl allow kubelet

– Change the cgroup-driver

We want to verify the docker-ce and kubernetes are utilizing similar ‘cgroup’.

Test docker cgroup utilizing the docker information command.

docker information | grep -i cgroup

And also you see the docker is utilizing ‘cgroupfs‘ as a cgroup-driver.

Now run the command beneath to vary the kuberetes cgroup-driver to ‘cgroupfs’.

sed -i ‘s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g’ /and so forth/systemd/system/kubelet.service.d/10-kubeadm.conf

Reload the systemd system and restart the kubelet service.

systemctl daemon-reload
systemctl restart kubelet

Now we’re able to configure the Kubernetes Cluster.

Konfigure Kubernetes Cluster

Step 2 – Kubernetes Cluster Initialization

On this step, we are going to initialize the kubernetes grasp cluster configuration.

Transfer the shell to the grasp server ‘k8s-master’ and run the command beneath to arrange the kubernetes grasp.

kubeadm init –apiserver-advertise-address= –pod-network-cidr=

Kubernetes Cluster Initialization


–apiserver-advertise-address = determines which IP tackle Kubernetes ought to promote its API server on.

–pod-network-cidr = specify the vary of IP addresses for the pod community. We’re utilizing the ‘flannel’ digital community. If you wish to use one other pod community comparable to weave-net or calico, change the vary IP tackle.

When the Kubernetes initialization is full, you’ll get the consequence as beneath.

Kubernetes initialization is complete


Copy the ‘kubeadm be a part of … … …‘ command to your textual content editor. The command will probably be used to register new nodes to the kubernetes cluster.

Now to be able to use Kubernetes, we have to run some instructions as on the consequence.

Create new ‘.kube’ configuration listing and replica the configuration ‘admin.conf’.

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

Subsequent, deploy the flannel community to the kubernetes cluster utilizing the kubectl command.

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

Kubernetes Join

The flannel community has been deployed to the Kubernetes cluster.

Await a minute after which examine kubernetes node and pods utilizing instructions beneath.

kubectl get nodes
kubectl get pods –all-namespaces

And you’ll get the ‘k8s-master’ node is operating as a ‘grasp’ cluster with standing ‘prepared’, and you’ll get all pods which might be wanted for the cluster, together with the ‘kube-flannel-ds’ for community pod configuration.

Be sure that all kube-system pods standing is ‘operating’.

Check Kubernetes Node

Kubernetes cluster grasp initialization and configuration has been accomplished.

Step 3 – Including node01 and node02 to the Cluster

On this step, we are going to add node01 and node02 to hitch the ‘k8s’ cluster.

Hook up with the node01 server and run the kubeadm be a part of command as we copied on the highest.

kubeadm be a part of –token vzau5v.vjiqyxq26lzsf28e –discovery-token-ca-cert-hash sha256:e6d046ba34ee03e7d55e1f5ac6d2de09fd6d7e6959d16782ef0778794b94c61e

Adding node01 and node02 to the Cluster

Hook up with the node02 server and run the kubeadm be a part of command as we copied on the highest.

kubeadm be a part of –token vzau5v.vjiqyxq26lzsf28e –discovery-token-ca-cert-hash sha256:e6d046ba34ee03e7d55e1f5ac6d2de09fd6d7e6959d16782ef0778794b94c61e

Connect Docker nodes

Await some minutes and again to the ‘k8s-master’ grasp cluster server examine the nodes and pods utilizing the next command.

kubectl get nodes
kubectl get pods –all-namespaces

Now you’ll get node01 and node02 has been added to the cluster with standing ‘prepared’.

kubctl command

node01 and node02 have been added to the kubernetes cluster.

Step 4 – Testing Create First Pod

On this step, we are going to do a check by deploying the Nginx pod to the kubernetes cluster. A pod is a gaggle of a number of containers with shared storage and community that runs beneath Kubernetes. A Pod accommodates a number of containers, comparable to Docker container.

Login to the ‘k8s-master’ server and create new deployment named ‘nginx’ utilizing the kubectl command.

kubectl create deployment nginx –image=nginx

To see particulars of the ‘nginx’ deployment sepcification, run the next command.

kubectl describe deployment nginx

And you’ll get the nginx pod deployment specification.

Subsequent, we are going to expose the nginx pod accessible by way of the web. And we have to create new service NodePort for this.

Run the kubectl command beneath.

kubectl create service nodeport nginx –tcp=80:80

Create first pod

Be sure that there isn’t a error. Now examine the nginx service nodeport and IP utilizing the kubectl command beneath.

kubectl get pods
kubectl get svc

Get list of pods

Now you’ll get the nginx pod is now operating beneath cluster IP tackle ‘’ port 80, and the node foremost IP tackle ‘10.0.15.x’ on port ‘30691’.

From the ‘k8s-master’ server run the curl command beneath.

curl node01:30691

Test with curl

curl node02:30691

Test node 2 with curl

The Nginx Pod has now been deployed beneath the Kubernetes cluster and it is accessible by way of the web.

Now entry from the net browser.

And you’ll get the Nginx default web page.

Page on node 1

On the node02 server –

Page on node 2

The Kubernetes cluster Set up and configuration on CentOS 7 has been accomplished efficiently.

How To Modify Attributes, Lessons, and Kinds within the DOM

Previous article

New YouTube Music Premium prices $9.99 month-to-month, add $2 to get all Pink perks

Next article

You may also like


Leave a Reply

More in Linux