Install Kubernetes with Minikube

Share on:

This article on “Install Kubernetes with Minikube " will walk you through the steps which is required to install and setup kubernetes and minikube on your development box.

Kubernetes is an open-source platform which helps in managing containers which is used to deploy the applications, with kubernetes you can scale and automate the deployment process.

“Minikube” – Well it can be said “mini kubernetes” because it runs on development machine not in production. 

“Why we need minikube if it is not used in production?”

To answer this question – developer’s/development box are pretty much standard one with limited memory and hardware configuration, so to run production grade application on developer machine it will be an expensive operation.

To handle this kind of situation we have minikube which can be used to develop and test actual production application on developers machine.

For Kubernetes installation on Ubuntu, please refer to my 14 steps guide - 14 Steps to Install kubernetes on Ubuntu 18.04 and 16.04 (“hashicorp/bionic64”)

For Kubernetes installation on CentOS, please refer to my 15 steps guide - 15 Steps: Install Kubernetes on CentOS “bento/centos-7

What you will need?

In this article I will be using OS Linux Mint 19.1 “Tessa” – Cinnamon (64-bit) but the steps are pretty much same for the other version of Linux Distributions.

Before we jump into the actual steps, lets see what are the steps and software packages we wil be needing during the installation –

  1. Oracle VM VirtualBox – VirtualBox 6.0.8
  2. kubectl – Kubernets v1.14.0
  3. minikube – Minikube v1.1.1
  4. Operating System – Linux Mint 19.1 “Tessa” – Cinnamon (64-bit)

Oracle VM VirtualBox : Download and Install

First thing first you need to install the VirtualBOx on your development box. Oracle VM VirtualBOx can be downloaded from here

At the time of writing this article I have installed – VirtualBox 6.0.8

If you like terminal a lot then you could use following command to get it installed on your devbox

1$ sudo apt-get update
2$ sudo apt-get install virtualbox-5.2

Check the installation of virtual box

1$ virtual

The above command should laund the virtual box on your devbox.

kubectl : Download and Install

Now after installing the Oracle VM VirtualBox next step would be to install “kubectl” sdk on your development box. You can refer the installation instruction provided from official kubernetes website

1. Download the latest kubectl release using following command
1$ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
2. After downlaoding the binaries we need to make it executable using following command
1$ chmod +x ./kubectl
3. Add binary to your path
1$ sudo mv ./kubectl /usr/local/bin/kubectl

(Note – Remember to run this command using sudo otherwise it will not be addded to your path)

4. Test kubectl on your development machine
1$ kubectl version

minikube : Download and Install

After installing kubectl next step would be to install minikube. To begin with the installation first find the latest version

Here is how we need to run the command to install minikube

1$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.1.1/minikube-darwin-amd64 && chmod +x minikube && sudo cp minikube /usr/local/bin/ && rm minikube

Break down the long command

1. Download the minikube binaries :
1curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.1.1/minikube-darwin-amd64
2. Make it executable :
1chmod +x minikube
3. Copy to /user/local/bin :

sudo cp minikube /usr/local/bin/ && rm minikube

Starting : minikube

1. Once your through with installing “kubectl” and “minkube”, now we need to start the minikube
1$ minikube start
 1There is a newer version of minikube available (v1.1.1).  Download it here:
 2https://github.com/kubernetes/minikube/releases/tag/v1.1.1
 3
 4To disable this notification, run the following:
 5minikube config set WantUpdateNotification false
 6😄  minikube v1.1.0 on linux (amd64)
 7🔥  Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
 8🐳  Configuring environment for Kubernetes v1.14.2 on Docker 18.09.6
 9🚜  Pulling images ...
10🚀  Launching Kubernetes ...
11⌛  Verifying: apiserver proxy etcd scheduler controller dns
12🏄  Done! kubectl is now configured to use "minikube"
2. Check the status of the minikube
1$ minikube status
1host: Running
2kubelet: Running
3apiserver: Running
4kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100
3. Now lets run hellominikube on port 8080
1$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080
2
3kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
4deployment.apps/hello-minikube created
4. Expose the hellominikube service
1$kubectl expose deployment hello-minikube --type=NodePort
2service/hello-minikube exposed
5. Get the pod status
1$ kubectl get pod
2NAME                              READY   STATUS    RESTARTS   AGE
3hello-minikube-56cdb79778-7v9xt   1/1     Running   0          3m7s
6. Get minikube status

Access the minikube status with url - http://192.168.99.100:31469/

 1Hostname: hello-minikube-56cdb79778-7v9xt
 2
 3Pod Information:
 4-no pod information available-
 5
 6Server values:
 7server_version=nginx: 1.13.3 - lua: 10008
 8
 9Request Information:
10client_address=172.17.0.1
11method=GET
12real path=/
13query=
14request_version=1.1
15request_scheme=http
16request_uri=http://192.168.99.100:8080/
17
18Request Headers:
19accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
20accept-encoding=gzip, deflate
21accept-language=en-US,en;q=0.5
22connection=keep-alive
23host=192.168.99.100:31469
24upgrade-insecure-requests=1
25user-agent=Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0
26
27Request Body:
28-no body in request-
7. Delete services of “hello-minikube”
1$ kubectl delete services hello-minikube
2service "hello-minikube" deleted
8. Delete the minikube deployment
1$ kubectl delete deployment hello-minikube
2deployment.extensions "hello-minikube" deleted
9. Stopping the minikube
1$ minikube stop
2✋  Stopping "minikube" in virtualbox ...
3🛑  "minikube" stopped

Next Step - Setting up kubernetes dashboard