Create a Kubernetes Cluster on CentOS 7 (without kubeadm)

Kubernetes is an open source system developed by Google which automates deployment, operations and scaling of containerized applications. It is a holistic solution for automated delivery offering a wide range of critical features like automatic binpacking, self-healing, auto-scaling, service registry, software load-balancing, automated rollouts, automated rollbacks, secret and configuration management, storage orchestration and batch execution.

It is hands down the best technology I have master recently.

In this article, I will help you setting up your cluster. It is going to take some effort but it’s all worth it.

Let’s get started.

**UPDATE 5th November 2016**
While I still exhort you to read this article for educational purposes, there is now a much easier way to setup a Kubernetes cluster using kubeadm. I will write an article on it as soon as possible. In the meantime you can follow the official documentation on [](

Architecture Overview

The high level architecture of Kubernetes is pretty simple. There is a master which controls one or more nodes where pods are spawned. The kube-apiserver, the kube-scheduler and the kube-controller-manager reside on the master, while the kubelet and the kube-proxy reside on the nodes. The kubectl, the command line interface, can be placed on any machine, even outside the cluster.

In few words, the master monitors the nodes and schedules pods on the nodes by invoking the kubelet. The kube-proxy enables software load-balancing and the services paradigm.

Data is persisted on [etcd](, a key-value store accessible through a RESTful API. Networking can be implemented in many different ways as long as it satisfies the Kubernetes requirements. For the scope of this tutorial, we will be using [flannel](

This is obviously a very simplistic description. If you wish to dig deeper, just read the official documentation on [](


In order to setup a cluster you need a minimum of 1 VM, i.e. you can run the master and one node on the same machine. In this tutorial I will assume you have at least 2 VMs. However you should be able to follow the same step sequence in both cases.

Setup the master

Disable firewalld

Disable iptables to avoid conflicts with Docker.

Install ntp

Install the Network Time Protocol to keep the nodes in synch.

Install etcd

Install etcd.

Before launching and enabling the etcd service you need to define its configuration in /etc/etcd/etcd.conf. The file contains several lines. You need to make sure the following are uncommented and setted as shown below.

Finally launch and enable the service.

Install the Kubernetes components

You can install the Kubernetes components in several ways. The simples is to use yum. If you wish to install the latest version or a particular release you need refer to the kubernetes repository itself since it is a bit more complicate. I plan to right a separate post to show you how to do that. For the time being, let’s stick to the simpler approach.

First we install Kubernetes through yum.

Before starting the services we need to take care of the configuration. Once again make sure the following lines are uncommented and set as shown below.

Now we can finally start the kube-apiserver, kube-controller-manager and kube-scheduler.

Configure the Flannel network

Before moving away from the master we will create a configuration key in etcd defining the flannel network which will be used by the nodes.

Setup the node

Disable firewalld

Disable iptables to avoid conflicts with Docker.

Install ntp

Install the Network Time Protocol to keep the nodes in synch.

Install Docker

Install docker. We will start its service later on.

Install Flannel

Install flannel with yum

Before starting it you need to edit its configuration in /etc/sysconfig/flanneld. Make sure the following fields are defined.

We will start the service later on as well.

Install the Kubernetes components

As for the master, we will use yum.

We configure the KUBE_MASTER address in /etc/kubernetes/config.

We configure the kubelet in /etc/kubernetes/kubelet. Make sure to have the following fields uncommented.

Finally let’s start all services.

Testing the installation while setting up SkyDNS

Check Node(s) state

If the installation went fine, we should be able to see all the nodes we configured as Ready from the master.

Install Kube-DNS

Kubernetes offers a DNS cluster addon, which assigns DNS names to [Services]( This is extremely useful because it allows you to develop your application without hardcoding IPs.

Create a file named skydns-svc.yml with the following content.

Now create the Service.

Create a file name skydns-rc.yml with the following content.

Create the replication controller.

Finally we need to instruct all kubelet instances (on each node) to make use of the DNS server. Just set the following arguments in the /etc/kubernetes/kubelet.

Restart the kubelet on all nodes.

Test the DNS server

Create a file busybox.yaml with the following content.

Create the pod.

Wait for the pod to be Running.

Connect to the pod and perform an nslookup on the kubernetes service.



Now time for you to explore the power of Kubernetes and Accellerate Your Delivery!