Table of Content

minikube is a solution to run a single node Kuberntes cluster inside a VM on laptop.

My use case:

  • ubuntu 17.10 on win7 vmware, 4GB memory, 2CPU, 100GB disk
  • run minikube in ubuntu 17.10 vm

minikube installation

Here is note refer minikube installation guide, and updated few issues.

minikube binary

oldhorse@ubuntu:~$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 39.4M 100 39.4M 0 0 1091k 0 0:00:37 0:00:37 --:--:-- 1330k

verify

oldhorse@ubuntu:~$ which -a minikube
/usr/local/bin/minikube
oldhorse@ubuntu:~$ minikube version
minikube version: v0.24.1

kubectl binary

oldhorse@ubuntu:~$ curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin

verify

oldhorse@ubuntu:~$ which -a kubectl
/usr/local/bin/kubectl
oldhorse@ubuntu:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.5", GitCommit:"cce11c6a185279d037023e02ac5249e14daa22bf", GitTreeState:"clean", BuildDate:"2017-12-07T16:16:03Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

start minikube

minikube supports many drivers:

  • virtualbox
  • vmwarefusion
  • KVM2
  • KVM (deprecated in favor of KVM2)
  • hyperkit
  • xhyve
  • Hyper-V
  • none (Linux-only)

My case the ubuntu vm running on top of win7 vmware, it is possible to run nested virtualization in vmware vm but from resource and performance perspective, none driver is best one for low profile, directly run minikube cluster on vm host instead of nested vm inside ubuntu vm using driver virtualbox or kvm.

docker installation

In fact localkube installs k8s services in docker containers, so docker is pre-condition for minikube + none driver installation.

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh

then let’s start minikube installation.

minikube + localkube

oldhorse@ubuntu:~$ export MINIKUBE_WANTUPDATENOTIFICATION=false
oldhorse@ubuntu:~$ export MINIKUBE_WANTREPORTERRORPROMPT=false
oldhorse@ubuntu:~$ export MINIKUBE_HOME=$HOME
oldhorse@ubuntu:~$ export CHANGE_MINIKUBE_NONE_USER=true
oldhorse@ubuntu:~$ mkdir $HOME/.kube || true
oldhorse@ubuntu:~$ touch $HOME/.kube/config
oldhorse@ubuntu:~$ export KUBECONFIG=$HOME/.kube/config

minikube start –vm-driver=none –v 99

Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Creating CA: /home/oldhorse/.minikube/certs/ca.pem
Creating client certificate: /home/oldhorse/.minikube/certs/cert.pem
Getting VM IP address...
Moving files into cluster...
Downloading localkube binary
148.25 MB / 148.25 MB [============================================] 100.00% 0s
65 B / 65 B [======================================================] 100.00% 0s
E1211 12:05:55.387171 8520 start.go:223] Error updating cluster: error creating file at /usr/local/bin/localkube: open /usr/local/bin/localkube: permission denied

the issue is "minikube start" trying to copy localkube to /usr/local/bin right after download, so for sure got permission denied.

Let’s try sudo this time,

Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
===================
WARNING: IT IS RECOMMENDED NOT TO RUN THE NONE DRIVER ON PERSONAL WORKSTATIONS
The 'none' driver will run an insecure kubernetes apiserver as root that may leave the host vulnerable to CSRF attacks

Loading cached images from config file.

Here is post steps to change back to normal user for localkube,

oldhorse@ubuntu:~$ ll /usr/local/bin
-r----x--x 1 root root 155452040 Dec 11 12:08 localkube
oldhorse@ubuntu:~$ sudo chown $USER:$USER /usr/local/bin/localkube
oldhorse@ubuntu:~$ sudo chmod +x /usr/local/bin/localkube
oldhorse@ubuntu:~$ ll /usr/local/bin|grep localkube
-r-x--x--x 1 oldhorse oldhorse 155452040 Dec 11 12:08 localkube*

now minikube running as normal user,

oldhorse@ubuntu:~$ minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 127.0.0.1

minikube + none driver installation script

I put all above steps in installation script, it does clean up and build a clean minikube cluster in just few mins.

oldhorse@ubuntu:~$ sh ./minikube-none.sh
Mon Dec 11 13:27:12 PST 2017

check minikube binary ...
minikube existing, change to minikube.old
kubectl existing, change to kubectl.old
localkube existing, change to localkube.old
Install minikube ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 39.4M 100 39.4M 0 0 1224k 0 0:00:33 0:00:33 --:--:-- 1428k

Install kubectl ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 49.9M 100 49.9M 0 0 1216k 0 0:00:42 0:00:42 --:--:-- 1488k

setup MINIKUBE env ...

minikube start ...
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Downloading localkube binary
148.25 MB / 148.25 MB [============================================] 100.00% 0s
65 B / 65 B [======================================================] 100.00% 0s
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
===================
WARNING: IT IS RECOMMENDED NOT TO RUN THE NONE DRIVER ON PERSONAL WORKSTATIONS
The 'none' driver will run an insecure kubernetes apiserver as root that may leave the host vulnerable to CSRF attacks

Loading cached images from config file.

Mon Dec 11 13:31:15 PST 2017
minikube installation done

minikube test

oldhorse@ubuntu:~$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
deployment "hello-minikube" created

oldhorse@ubuntu:~$ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed

oldhorse@ubuntu:~$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-minikube-57889c865c-fklqz 1/1 Running 0 15s
oldhorse@ubuntu:~$ curl $(minikube service hello-minikube --url)
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://127.0.0.1:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=*/*
host=127.0.0.1:30952
user-agent=curl/7.55.1
BODY:
-no body in request-

oldhorse@ubuntu:~$ kubectl delete service hello-minikube
service "hello-minikube" deleted

oldhorse@ubuntu:~$ kubectl delete deployment hello-minikube
deployment "hello-minikube" deleted

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

oldhorse@ubuntu:~$ minikube status
minikube: Stopped
cluster:
kubectl:

follow up

I opened issue to kubernetes/minikube, hope can improve the instruction.