Table of Contents

Minikube for dev

1. Headline

1.1 Minikube installation (Ubuntu 18.04)

1.1.1 Install docker

  sudo apt-get remove docker docker-engine docker.io
  sudo apt install docker.io
  sudo systemctl start docker
  sudo systemctl enable docker
  docker --version

1.1.2 Install minikube

Install kvm (optional on VM):

  sudo apt-get -y install qemu-kvm libvirt-bin virt-top  libguestfs-tools virtinst bridge-utils
  sudo modprobe vhost_net
  sudo lsmod | grep vhost
  echo "vhost_net" | sudo tee -a /etc/modules

Install minikube:

wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube-linux-amd64
sudo mv minikube-linux-amd64 /usr/local/bin/minikube
minikube version

Install kubectl:

  curl -LO 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/
  kubectl version -o json

Install docker kvm driver:

  curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2
  chmod +x docker-machine-driver-kvm2
  sudo mv docker-machine-driver-kvm2 /usr/local/bin/

Start minikube with profile:

  minikube start --vm-driver=kvm2 -p visrc.kube --memory=4096

On a VM run vm-driver NONE and no multi-profile and requires sudo:

  sudo minikube start --vm-driver=none
  

Delete minikube profile

  minikube delete -p intg-test 

Note that after the cluster is deleted, the now-empty~/.minikube/profiles/intg-test subfolder and the k8s context aren’t deleted automatically. Some manual clean-up is necessary.

1.2 Using minikube in local env

The docker command line in the host machine can be configured to utilize the docker daemon within minikube by running:

$ eval $(minikube docker-env)

There are several reasons as to why it is useful to use the minikube docker daemon:

To confirm that the docker cli is using the minikube docker daemon, run:

  $ docker info | grep Name
  Name: minikube

In order to revert back to the host docker daemon, simply run:

  $ eval $(minikube docker-env -u)
  

If the workstation goes sleep, stop and start minikube again

If you started your minikube instance with profile

  minikube start -p ClusterName

Then you'll have to put the profile name for each command

  minikube docker-env -p ClusterName

So you finally can run next command to get it work

  eval $(minikube docker-env -p YourClusterName)
  

1.3 Tools

Validating yaml:

  #install yamllint
  yamllint kubernetes/django/deployment.yaml