← Learning

MiniKube

Quick and Dirty Setup

  • Install VirtualBox.
  • Install Docker.
  • Install MiniKube. This basically means “copy to /usr/local/bin”. It can also be installed via brew cask install minikube.
  • Install KubeCtl.
  • $ minikube config set memory 5120 to get some breathing room.
  • $ minikube start --insecure-registry registry.banno-internal.com --bootstrapper kubeadm --extra-config kubelet.image-pull-progress-deadline=10m0s. This will take several minutes the first time, as it downloads minikube.iso, kubelet, and kubeadm and configures kubectl appropriately. We use the kubeadm bootstrapper because localkube is being deprecated, and kubeadm is both more configurable (which we do to give slow connections more time to download images) and what will be used in production. Expected output:
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Downloading Minikube ISO
 140.01 MB / 140.01 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.8.0
Downloading kubelet v1.8.0
Finished Downloading kubelet v1.8.0
Finished Downloading kubeadm v1.8.0
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.
  • $ minikube service list. Expected output:
|-------------|-----------------------|-----------------------------|
|  NAMESPACE  |         NAME          |             URL             |
|-------------|-----------------------|-----------------------------|
| default     | kubernetes            | No node port                |
| kube-system | kube-dns              | No node port                |
| kube-system | kubernetes-dashboard  | http://192.168.99.100:30000 |
|-------------|-----------------------|-----------------------------|
  • $ sudo route -n add 10.0.0.0/8 `minikube ip` . This establishes a static route from your Mac to the virtual machine. Note that neither this route nor MiniKube’s IP address persist across reboots.
  • Create a file /etc/resolver/cluster.local with contents nameserver 127.0.0.1. This will cause DNS lookups of cluster.local names on your Mac to use the DNS server at 127.0.0.1, i.e. your Mac. But you probably aren’t running a DNS server yet, so…
  • $ brew install dnsmasq. Follow the instructions to copy dnsmasq.conf.
  • echo "server=/cluster.local/`kubectl get -n kube-system -o jsonpath={.spec.clusterIP} svc/kube-dns`" >> /usr/local/etc/dnsmasq.conf. This will cause dnsmasq to resolve lookups of cluster.local names using the kube-dns server.
  • $ sudo brew services start dnsmasq. This runs the dnsmasq service, and causes it to persist across reboots of your Mac.
  • $ dns-sd -G v4 kubernetes.default.svc.cluster.local. Expected output:
DATE: ---Thu 23 Mar 2017---
 9:27:57.820  ...STARTING...
Timestamp     A/R Flags if Hostname                               Address                                      TTL
 9:27:57.821  Add     2  0 kubernetes.default.svc.cluster.local.  10.0.0.1                                     39

ctrl-C to exit dns-sd.

  • $ eval $(minikube docker-env). Optional step that configures the docker client to use the docker daemon in your Minikube cluster. Useful when developing and you want your docker image to be available in your MiniKube cluster immediately upon building.

If this all works, you’re set to do almost anything you can do with Kubernetes.

Where to go from here

  • $ minikube dashboard is your friend. Everything should be green.
  • The general DNS-SD name pattern is {service-name}.{namespace}.{type}.cluster.local. {type} will almost always be svc.
  • Write code that looks up services in DNS and write integration tests against MiniKube!
  • $ minikube stop to shut down the virtual machine.