Setting up kubernetes cluster on ubuntu 14.04 LTS

kubernetes(k8s) is used to manage containers such as creating restarting deleting it. for more information visit their official site. Following steps will guide you to form k8s cluster having master and slave on different nodes. You can have master and slave on same node.

I am assuming following configuration for k8s cluster-

  1. master –  2 core, 2 Gb RAM, 20 gb HDD, ubuntu 14.04 LTS
  2. minion-  2 core, 2 Gb RAM, 20 gb HDD, ubuntu 14.04 LTS

In case of k8s slave nodes are called as minions. I am assuming that you knows basics of k8s, if not, please read about pods, services, replication controllers, controller-manager, scheduler, kubelet,  kube-proxy, kube-apiserver etc.

At the end you will have master with following services-

  1. kube-apiserver
  2. kube-controller-manager
  3. kube-scheduler
  4. kubectl

and minion will have-

  1. kubelet
  2. kube-proxy

Lets first configure master.  Login to your master node and executes following steps –

STEP 1]      Add your user to sudoers or switch to root user.

STEP 2]   Install prerequisites needed

                    2.1  Install docker on all hosts.

                         $sudo apt-get update

                         $sudo apt-key adv –keyserver hkp://pgp.mit.edu:80 –recv-keys 58118E89F3A912897C070ADBF76221572C52609D

                        $ echo “deb https://apt.dockerproject.org/repo ubuntu-trusty main” | sudo tee /etc/apt/sources.list.d/docker.list

                        $ sudo apt-get update

                        $ sudo apt-get install docker-engine

                        $ docker -v

2.1)   Install bridge-utils which is needed for container management inside pods.

           $ sudo apt-get install bridge-utils

 

STEP 3] clone git repo  

         $ sudo apt-get install git -y

         $ git clone https://github.com/kubernetes/kubernetes.git

STEP 4] Download and Install necessary binaries

         $ cd kubernetes/cluster/ubuntu

         $ ./download-release.sh

         $ ls binaries/

STEP 5] Configure cluster and define roles of each machine in the cluster. Edit config_default.sh file to have following.

        $ vi config-default.sh

  export nodes=${nodes:-“devops@172.20.75.106 devops@172.20.75.128 devops@172.20.75.196”}

roles=${roles:-“ai i i”}

export NUM_NODES=${NUM_NODES:-3}

export

SERVICE_CLUSTER_IP_RANGE=${SERVICE_CLUSTER_IP_RANGE:-192.168.3.0/24}

export FLANNEL_NET=${FLANNEL_NET:-172.16.0.0/16}

Note :- do not touch other parameters of the file.

 

STEP 6] generate rsa key . This is needed for kubernete deployment

        $ ssh-keygen -t rsa

        $ cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

STEP 7] run the kube-up.sh script to have cluster deployed. It will ask you for the password several times so be there.

$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh

STEP 8] set PATH to have smooth working of binaries.

            $ export PATH=$PATH:/home/devops/kubernetes/cluster/ubuntu/binaries/

            $ export PATH=$PATH:/opt/bin/

STEP 9] some helpful commands.

           $ kubectl get nodes

           $ kubectl get pods -o wide

           $ kubectl –help

STEP 10] Access web UI at

          http://172.20.75.106:8080/ui

 

About yogesh9391

Hi, I am Yogesh Jilhawar ,Currently working with GS Lab Pune, completed ME from pune institute of computer technology. Completed B.Tech. from SGGSIE&T Nanded. Email :- yogeshvj.jilhawar@gmail.com mob :- +91 8605911785
This entry was posted in kubernetes. Bookmark the permalink.

2 Responses to Setting up kubernetes cluster on ubuntu 14.04 LTS

  1. Tapan Halani says:

    hey yogesh, I am currently logged into my master node via ssh through root account. But when it try the kube-up.sh , it asks me for the password even after it added my ssh key , as shown by the logs. Can you assist?

    Like

    • yogesh9391 says:

      The kube-up.sh script will copy conf files to slave nodes via some scp like commands. If you want to use certs then you may need to provide these cert to these commands. exa- scp -i sample.pem /path/to/source/file /destination. You will get more info, if you look into kube-up.sh script.

      Like

Leave a comment