How to install Kubernetes 1.8.1 on centos 7.3

Last modified date

This step by step tutorial is based on the official kubeadm tutorial and few other resources I found online. Add comments if something is not working or you have problems, I also found very useful the k8s slack channel. This is the first of three articles, the other two are
Configure Kubernetes Dashboard
Configure Nginx as Ingress Controller

What you need:

  • A box running Centos 7.3 few gigs of ram (I would suggest at least 4)
  • One hour of your time.

Preparing the machine

As root run the following commands to pass bridged IPv4 traffic to iptables’ chains:

Dependencies

Now you have to install the following dependencies:
– ebtables
– ethtools
– docker

and the following kubernetes components:
– kubelet
– kebeadm
– kubectl

before proceding with the installation let’s add the required yum repository:

Now you can install them:

After the installation completes you have to enable and start docker and kubelet you can do it running th following commands:

Open firewall ports

You need to open few ports on the firewall

Cluster setup

Now we can initialize the cluster using kubeadm:

now we can leave the root mode and proceed as standard user, probably you need to create one:

configure kubectl

Notes: If you want you can install kubectl on your machine and copy the admin.conf file locally.
I prefer to work on a local machine for various reasons such as aliases, autocompletion and history. I do that by running:

Pod/cluster network setup

Kubernetes requires a network implementation in order to work, a cluster network is used to connect containers, from the official guide:
The network must be deployed before any applications. Also, kube-dns, a helper service, will not start up before a network is installed. kubeadm only supports Container Network Interface (CNI) based networks (and does not support kubenet).

In following spec defines flannel network, there are other implementations if you want to read more please check the official docs

Run kubectl get pods --all-namespaces
check that flannel is up and running
check that dns is starting (may take few minutes).

If you are configuring a single node cluster you have to run this too:

next >> Configure Kubernetes Dashboard