Home > Applications & Tools, Cloud Computing > How to Install Kubernetes to Run Docker on VMware vSphere

How to Install Kubernetes to Run Docker on VMware vSphere

Installing Google Kubernetes does not require VMware vSphere or any other virtual machine hypervisor. However, doing that on a VM is very convenient, so it’s highly recommended especially for development and testing environment.

Regardless VM or physical machine, a Linux OS is a must. As always, I picked CentOS 7 which is a fork of RHEL. Once getting a CentOS installed, the rest is easy. If you have a CentOS template already, deploying a new one should be very fast.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure


For better user experience, you want to have clean CentoS. When I tried the installation, I used a CentOS that had Nginx installed already and that gave me quite some trouble. In the end, I had to start again from scratch.

Here are the command lines that I used to install the Kubernetes while studying the book Docker Containers – Build and Deploy with Kubernetes, Flannel, Cockpit, and Atomic (highly recommended). Because it’s for testing only, I just installed everything together in one VM. If real system, you want to have master and different nodes.

Are you ready?

Installation of Both Master and Client

First, bring the CentOS to latest and the reboot the machine.

# yum update
# reboot

Then, start to install the mater node using the yum command line.

# yum install -y kubernetes etcd
# systemctl stop firewalld
# systemctl disable firewalld
# vi /etc/kubernetes/apiserver
# systemctl restart etcd kube-apiserver kube-controller-manager kube-scheduler
# systemctl enable etcd kube-apiserver kube-controller-manager kube-scheduler

Now, let’s install the client:

# systemctl restart kube-proxy kubelet docker
# systemctl enable kube-proxy kubelet docker

To verify it’s been successfully installed, try the following command line:

[root@vSearch ~]# kubectl get node
NAME        STATUS    AGE   Ready     5h

Creating a New Cluster/Pod

Kubernetes uses json file to describe a POD blueprint in a real “software defined” fashion.

# vi web-db.json
# kubectl create -f web-db.json

The author of the docker book I mentioned early has created a nice Pod sample as follows. It has two containers: one for Web server and the other for DB. Simple but good for illustrating a pod.

apiVersion: v1
kind: Pod
  name: web-db-pod
    app: web-db-pod
  - name: mywebdock
    image: "cricket/webdock"
    - containerPort: 80
      hostPort: 80
  - name: mydbdock
    image: "cricket/dbdock"
    - containerPort: 3306
      hostPort: 3306

The deployment takes a few minutes to finish. Along the way, you can use the docker ps command to see what containers are there already:

# docker ps

When you see both the containers are ready, you can verify if the Web server is running correctly:

# curl localhost:80
# curl localhost:80/cgi-bin/action

In my case, the second command failed with 500 Internal Service Error. To find out why, I login into the container for more information. It’s actually pretty easy with the following command line. Note that the docker attach command is not enough because the existing container does not have any shell running.

# docker exec -it 9392c4458609 bash

Once getting into the container, you can see the file of the

# vi /var/www/cgi-bin/action
# -*- coding: utf-8 -*-
import MySQLdb as mdb
import os
con = mdb.connect(os.getenv('DB_SERVICE_SERVICE_HOST',''), 'dbuser1', 'redhat', 'gss')

Note the IP address does not exist in my environment. Simply change it to and save it. Then try the URL in a browser will work

Note: Your container IP address can be different.

  1. January 23rd, 2017 at 11:32 | #1

    Nice introduction to Kubernetes. I would like to mention an even simpler way to try it out, Google Container Engine. It manages the VM part completely and lets you access the cluster with kubectl with no up front configuration. I would also like to point out that you can access services by DNS name instead of environment lookups like in the example.

  1. No trackbacks yet.