cloud · docker · kubernetes · linux · x86_64

x86_64: Installing Minikube

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day [1].

This is a step-by-step installation guide that puts togheter in a single page all required steps to install Minikube on Ubuntu 18.04 with the KVM2 driver. More information on how install Minikube using a different approach can be found in [2].

1 – Check Virtualization

VT-x or AMD-v virtualization must be enabled in your computer’s BIOS, use the following command to verify this feature:

egrep --color 'vmx|svm' /proc/cpuinfo

 

2 – Install QEMU-KVM

sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
sudo usermod -a -G libvirt $(whoami)
newgrp libvirt

<strong>NOTE:</strong> you need to reboot you computer to user your user is added to the libvirt group.

 

3 – Install kubectl

sudo apt-get update && sudo apt-get install -y apt-transport-https; curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -; echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list; sudo apt-get update; sudo apt-get install -y kubectl
echo "source > ~/.bashrc

 

4 – Install Minikube


curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube
sudo cp minikube /usr/local/bin && rm minikube

 

5 – Install KVM2 Driver

curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 && sudo install docker-machine-driver-kvm2 /usr/local/bin/

 

6 – Starting Minikube


minikube start --vm-driver kvm2

rpsene@rpsene:~$ minikube start --vm-driver kvm2
Starting local Kubernetes v1.13.2 cluster...
Starting VM...
Downloading Minikube ISO
181.48 MB / 181.48 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubelet v1.13.2
Downloading kubeadm v1.13.2
Finished Downloading kubeadm v1.13.2
Finished Downloading kubelet v1.13.2
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Stopping extra container runtimes...
Starting cluster components...
Verifying kubelet health ...
Verifying apiserver health ...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

Everything looks great. Please enjoy minikube!

rpsene@rpsene:~$ virsh list --all
Id Name State
----------------------------------------------------
1 minikube running

 

7 – Access Minikube


rpsene@rpsene:~$ minikube ip
192.168.39.193

rpsene@rpsene:~$ minikube dashboard
Enabling dashboard ...
Verifying dashboard health ...
Launching proxy ...
Verifying proxy health ...
Opening http://127.0.0.1:37105/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ in your default browser..

 

8 – Running an application


rpsene@rpsene:~$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080
kubectl 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.
deployment.apps/hello-minikube created
rpsene@rpsene:~$ kubectl expose deployment hello-minikube --type=NodePort
service/hello-minikube exposed
rpsene@rpsene:~$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-minikube-6fd785d459-jwhjw 1/1 Running 0 57s
rpsene@rpsene:~$ curl $(minikube service hello-minikube --url)
Hostname: hello-minikube-6fd785d459-jwhjw

Pod Information:
-no pod information available-

Server values:
server_version=nginx: 1.13.3 - lua: 10008

Request Information:
client_address=172.17.0.1
method=GET
real path=/
query=
request_version=1.1
request_scheme=http
request_uri=http://192.168.39.193:8080/

Request Headers:
accept=*/*
host=192.168.39.193:30566
user-agent=curl/7.58.0

Request Body:
-no body in request-

 

9 – Deleting an application


rpsene@rpsene:~$ kubectl delete services hello-minikube
service "hello-minikube" deleted

rpsene@rpsene:~$ kubectl delete deployment hello-minikube
deployment.extensions "hello-minikube" deleted

 

10 – Stopping Minikube


rpsene@rpsene:~$ minikube stop
Stopping local Kubernetes cluster...
Machine stopped.

rpsene@rpsene:~$ virsh list --all
Id Name State
----------------------------------------------------
- minikube shut off

 

11 – References

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s