Setting Up Kubernetes Cluster on CentOS Servers.

So I’ve been running some of our development components on Docker in the company but it was never significant to the level that we rely on them for Development and Production, due to some major changes in our DataCenter I had to setup some database clusters and services from scratch to migrate our old data into.

So I saw this as an opportunity to convert some of our classic VMs into docker containers for a easier production and development experience.

For now I have prepared 3 VMS in 3 different hosts to be used by Kubernetes, all running CentOS 7 minimal.

the IP addresses of the machines are:

  • -> Kubernetes Master
  • -> Kubernetes Node1
  • -> Kubernetes Node2

Lets begin by setting up some tools on each machine.

now lets configure our host files for a cleaner communication between the cluster. I added the following in the end of each /etc/hosts file on each server:

now lets get rid of SELINUX, run setenforce 0 on each server and then edit /etc/sysconfig/selinux like following:

now we need to enable br_netfilter kernel module to allow packets traversing the bridge to be processed by iptables for port forwarding matters as well of communication of nodes within the cluster.

Disable swap on the machines by:

then edit /etc/fstab file and comment out the swap partition line.

Then install Docker

add Kubernetes repository.

then install kubelet, kubeadm and kubectl on all nodes and then reboot the servers.

once booted back lets start and enable the autostart of kubelet

kubernetes and docker both need to be running under same cgroup, find out what cgroup docker is running under by running:

now lets make sure kubernetes cgroup-driver is set to cgroupfs as well.

now reload the systemd and restart the kubelet service.

we need to make sure port 6443 & 10250 are open on the firewalld (default shipped with CentOS7). in my case I prefer to completely disable firewalld as these machines are not publicly available and only machines behind our proxy servers will be able to access them.

lets create the cluster by running this command on the master.

once done you should get a commend outputed to the screen which need to be run on the nodes to join the master in cluster. run it on each of the nodes. I’d say keep this in your notes for future where if you may have additional nodes.

run the join command with your token on each node to get them to join the cluster.

thats all, you can confirm your nodes joined the master by running kubectl get nodes.



Leave a comment

Leave a Reply