Intro and Installation of Kubernetes

Jarret B

Well-Known Member
Staff member
May 22, 2017
Reaction score
Anyone using Docker can use Kubernetes to create a cluster. A cluster is when there are multiple systems working together as a single unit. If one system fails then the other systems will resume the failed processes to keep the resource active.

An example of a cluster would be multiple web servers acting as one web server. If we had five servers managing a website. One server may fail due to a physical hardware issue such as a hard disk failure. The cluster will disregard the failed server and the remaining four will continue hosting the website. The resources being clustered could be any resource that requires fault-tolerance. The resource could be a mission-critical database. There can be many possibilities for the resource or resources managed on a cluster.

Kubernetes Introduction

Kubernetes was open-sourced by Google in 2014. Kubernetes allows the containers in Docker to be easily managed. Docker nodes can be easily added and managed.

Kubernetes can help load-balancing, restarting a failed node, hide a node until it is active, etc.

There are many things that Kubernetes can do for your Docker nodes. We can get into the details by examples as we go.

NOTE: The main website for Kubernetes is at

Installing Kubernetes

There are directions for installing Kubernetes on its website for all of the various systems. I will only be covering Ubuntu.

NOTE: You can check out the site for Red Hat distros as well as other Operating Systems and platforms such as Windows and Macs.

Create a folder to copy Kubernetes into and use the following command to download the files using ‘curl’:

curl -LO`curl -s`/bin/linux/amd64/kubectl

The command will download the latest version of Kubernetes.

Then you need to perform the following to install it:

chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client

You can also set up the repository, so that Kubernetes can be more easily updated, with the following commands:

sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s | sudo apt-key add -
echo "deb kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubectl

The second method may be a little better so you can perform upgrades to newer versions automatically when you perform an ‘apt upgrade’.

You can verify the install and check the version number with the command:

kubectl version --client

After ‘kubectl’ is installed you will need ‘minikube’. The following command will download and install ‘minikube’ from the current folder:

curl -LO && sudo dpkg -i minikube_1.6.2.deb

The link for Minikube can be found at just in case the version has changed.

NOTE: Keep in mind that Minikube is a lightweight version of Kubernetes that creates a Virtual Machine and deploys a local one node cluster.

You will need to execute the command ‘egrep -q 'vmx|svm' /proc/cpuinfo && echo yes || echo no’ to verify that you have virtualization enabled on your system. The command should result in a ‘yes’ response.

You will also need Oracle Virtualbox installed. You can find it at

The second last programs we need are ‘kubectx’ and ‘kubens’ found at You can perform the following to download and set it up:

sudo git clone /opt/kubectx
sudo ln -s /opt/kubectx/kubectx /usr/local/bin/kubectx
sudo ln -s /opt/kubectx/kubens /usr/local/bin/kubens

The last program we need is kubetail which is located at The kubetail file is a bash file found at and needs to be copied to ‘/etc/bash_completion.d’. The copy must be done with Root privileges and you should close all terminals before using the script.

Starting Minikube

To start Minikube you can use the following command:

minikube start --cpu # --memory #### --disk-size=#####MB

The values here are the number of CPU cores to use on your system. You can also specify the amount of RAM to dedicate to the cluster as well as the disk space.

If you should only use the command ‘minikube start’ then a default cluster should start. The default number of cores is 2, the RAM is 2GB (2,000MB) and the disk space is 20 GB (20,000MB).

As you can see in Figure 1 you can use the ‘minikube start’ to use all of the defaults.

Figure 01.jpg


Everything which was needed was downloaded from the Internet during the setup of the cluster. You can verify that the cluster is running by using the Minikube Dashboard. To open the Minikube Dashboard enter the following command:

minikube dashboard

You should see results from the command in the Terminal as shown in Figure 2.

Figure 02.jpg


Once the command has completed your default browser should open and show you the cluster’s information as shown in Figure 3.

Figure 03.jpg


Along the left side of the browser is a list of various options to view. Once selected the aspects of those options will be displayed in the right pane of the browser.


There are some terms used in Kubernetes that are different from Docker. They are not difficult to know.

NOTE: Be sure to look over the Docker articles:

Docker Basics and Install
Creating a Docker Container
Docker Container Advanced Creation
Docker Compose
Using Docker Volumes

A Docker Container is called a Pod in Kubernetes. A Docker Host is a Kubernetes Node.

Nodes can be a physical machine or just a Virtual Machine.
Pods contain a Docker container, storage resource, IP Address and options for the container. Multiple containers can run in a pod, but there must be at least one.

The Pods can have different states. The states are:

  • Pending - the Pod is accepted but there is no Container
  • Running - all Containers are created and least one is in the Running state
  • Succeeded - Pods were running and have exited with an error code of zero
  • Failed - all Containers have stopped and one has generated a non-zero error
  • CrashLoopBackOff - the Container has failed and Kubernetes has tried continuously to restart it and failed
Let’s look at creating a basic Container and Pod.

Creation of Container and Pod

We will need to create two files for use with creating this Node and Pod.

The first file is called ‘server.js’ and will contain the following code:

var http = require('http');
var handleRequest = function(request, response) {

console.log('Received request for URL: ' + request.url);
response.end('Hello Linux World!');
var www = http.createServer(handleRequest);

The second file is the ‘Dockerfile’ with the contents of:

FROM node:6.14.2
COPY server.js .
CMD [ "node", "server.js" ]

Place both files in the same folder, such as ‘Kubernetes/HelloLinuxWorld’.

If you have not done so you will need to start Minikube with the command
‘minikube start’.

Next, you need to issue the command:

kubectl create deployment hello-node

The command is creating a Deployment that manages a Pod (container) made
from the Dockerfile image. We are using an image that is outside the
Docker Hub.

Once the command is executed you can see that the Deployment is working by
using the command:

kubectl get deployments

You should see a ‘hello-node’ listed which shows that the Deployment
is working.

We cannot access the Pod unless we create a Service to bridge the
connection from the Internal to the External network. Use the

kubectl expose deployment hello-node --type=LoadBalancer --port=8080

Here you can see that we are using the name ‘hello-node’ and the Internal
Port of 8080 as we setup in the two files we created. The type is
set as ‘LoadBalancer’ to specify that the connection should be

The newly created Service can be displayed with the command:

kubectl get services

To completely make the Service accessible from outside the cluster you
can use the final command to complete the Service:

minikube service hello-node

The last command should show the IP Address as well as the Port used to
connect to the Node and Pod we just created. The command should also
open the default browser to the designated address and port to show
‘Hello Linux World!’.

You can also look at the dashboard (‘minikube dashboard’) to look
over the various items in the Kubernetes GUI.

You may want to remove the Nodes and Pods which were created so as you create
more Nodes and Pods you do not have a long list taking up more

Removing Nodes and Pods

To remove everything we just added from Kubernetes we first need to stop the

kubectl delete service hello-node

Next, we delete the whole deployment with the command:

kubectl delete deployment hello-node

You can now stop Minikube by issuing the following command in a Terminal:

minikube stop

You can also delete the Minikube Virtual Machine by:

minikube delete


I hope this should give you a basic start to Kubernetes.

More articles will follow.


Well-Known Member
Mar 16, 2019
Reaction score
Very good! (I think) ¯\_(ツ)_/¯
This is one of those instances where much of what I am reading is over my head. I'm still trying to figure out 'Docker Containers'!
But, that being said, I read the post and although I may not have understood some of it, I will remember this and in the future I may find this information very useful. This happens quite often with "Tech" podcasts I listen to.
So, thank you for this. :)

Members online

Latest posts