Quick and Dirty Setup
- Install VirtualBox.
- Install Docker.
- Install MiniKube. This basically means “copy to
/usr/local/bin”. It can also be installed viabrew cask install minikube. - Install KubeCtl.
$ minikube config set memory 5120to 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 downloadsminikube.iso,kubelet, andkubeadmand configureskubectlappropriately. We use thekubeadmbootstrapper becauselocalkubeis being deprecated, andkubeadmis 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.localwith contentsnameserver 127.0.0.1. This will cause DNS lookups ofcluster.localnames on your Mac to use the DNS server at127.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 copydnsmasq.conf.echo "server=/cluster.local/`kubectl get -n kube-system -o jsonpath={.spec.clusterIP} svc/kube-dns`" >> /usr/local/etc/dnsmasq.conf. This will causednsmasqto resolve lookups ofcluster.localnames using thekube-dnsserver.$ sudo brew services start dnsmasq. This runs thednsmasqservice, 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 thedockerclient to use thedockerdaemon in your Minikube cluster. Useful when developing and you want yourdockerimage 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 dashboardis your friend. Everything should be green.- The general DNS-SD name pattern is
{service-name}.{namespace}.{type}.cluster.local.{type}will almost always besvc. - Write code that looks up services in DNS and write integration tests against MiniKube!
$ minikube stopto shut down the virtual machine.