Setting up Kubernetes 1.7 on a CentOS 7.1 cluster

on Reading Time: 2 minutes

It was quite a daunting task at the beginning to start with Kubernetes 1.7 alpha release because I knew that I was bound to face with difficulties. I built Kubernetes from source on my Ubuntu 16.04 machine.

I downloaded the source from kubernetes (https://github.com/kubernetes/kubernetes/tree/v1.7.0-alpha.3) and CentOS 7.1 (minimal version). I set up three virtual machines to deploy my CentOS cluster. This blog post focuses on building and deploying Kubernetes.

First I navigated to the kubernetes src folder within kubernetes.

cd kubernetes/src/k8s.io/kubernetes/

Then I built the kubernetes images with,

build/run.sh

In order to build the relase binaries execute,

build/release.sh

When I executed this I ran out of space in my root directory. This was due to the fact that in /var/lib/docker Docker creates a large number of layers eating up disk space. It could run up to a dazzling amount of 30GB. So I had to move the kubernetes src to another partition and I created a symlink from /var/lib/docker to /media/malith/Data/docker/ which was on the Data partition.

Next we need to copy the download etcd, falnnel and docker. But we do not need to download kubernetes as we have built it. If we download it, there would most probably be a version incompatibility.

Therefore comment out the below section.

#echo "Download kubernetes release v${K8S_VERSION} ..."  #curl -L ${K8S_CLIENT_DOWNLOAD_URL} -o ${RELEASES_DIR}/kubernetes-client-linux-amd64.tar.gz  #curl -L ${K8S_SERVER_DOWNLOAD_URL} -o ${RELEASES_DIR}/kubernetes-server-linux-amd64.tar.gz

In the function download-release() comment

#rm -rf ${RELEASES_DIR}

This is due to the fact that we are trying to move the binaries that we built to the RELEASES_DIR directory which defaults to /tmp/downloads.

Next we have to manually copy kubernetes-client-linux-amd64.tar.gz and kubernetes-server-linux-amd64.tar.gz to the RELEASES_DIR folder. You can find them by navigating to the folder,

cd kubernetes/src/k8s.io/kubernetes/_output/release-tars

Okay, we are good to go. Now we can start a cluster, provided you have a minimum of three CentOS machines on a private network with an active internet connection.

You need to change the following values in cluster/centos/config-default.sh. My master IP address is 192.168.57.122 and the minions are respectively, 192.168.57.123 and 192.168.57.123.

export MASTER="root@192.168.57.122"export NODES="${NODES:-"root@192.168.57.123 root@192.168.57.124"}"

Do not change the DNS Server IP as it’s configured by Kubernetes itself.

To start kubernetes, navigate to the cluster folder,

KUBERNETES_PROVIDER=centos CERT_GROUP=malith ./kube-up.sh

However I kept running into an error due to a fault with kubernetes. It could not read a variable value (MASTER_ADVERTISE_ADDRESS)

Therefore I had to edit cluster/centos/util.sh. In the function “make-ca-cert”, I added the line
MASTER_ADVERTISE_IP=192.168.57.122.

After that I executed the above command again, and the cluster started successfully.

Leave a Reply

avatar
  Subscribe  
Notify of