/ #kubernetes 

Start with Kubernetes in less than 5 minutes with Minikube

There are (too?) many options to run a Kubernetes cluster, whether in a hosted fashion (Kubernetes-as-a-Service) with services such as Google Container Enginer (GKE) or the brand new Pivotal Container Service (PKS), but also by deploying turnkey or custom solutions.

Minikube LogoBut what if you want to start quickly for lab / education purposes? Or if you want quickly verify something or test a CLI? Here comes Minikube!

Minikube creates a local, single-node Kubernetes cluster for development and testing. Setup is completely automated and doesn’t require a cloud provider account.

What is Minikube?

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM (on Virtualbox for example) on your laptop for users looking to try out Kubernetes or develop with it day-to-day. Internally, minikube runs a single Go binary (named localkube), which runs all the kubernetes’ components. The result is a local kubernetes endpoint that you can use with the kubectl client.

  • Minikube supports kubernetes features such as DNS, Dashboards, CNI, NodePorts, ConfigMaps and Secrets and so on.

  • The minikube VM runs Docker, but supports also rkt container engine.

  • Multiple version of kubernetes are supported, from kubernetes 1.3.0 to 1.7.5 at the time of this writing.

  • Possible to reuse the minikube’s built-in Docker daemon; as this means you don’t have to build a docker registry on your host machine and push the image into it - you can just build inside the same docker daemon as minikube which speeds up local experiments.

  • Supports persistent volumes and host folder mounting.

  • Kubernetes environment configurable.

Get Started with Minikube

I will be honest: most of the 5 minutes were dedicated to the downloading part. :)

Minikube is distributed in binary form for Linux, OSX, and Windows systems (Windows support is currently experimental and may have issues). I used homebrew to install Minikube as I’m working on macOS: brew cask install minikube

Install Minikube on macOS with homebrew

An additional step is required to start Minikube: minikube start

Start Minikube

This command will download the Minikube ISO (on the first run only), start a Virtualbox VM (by default, can be changed to VMware Fusion or other virtualization software) and create a kubernetes context named ‘minikube’. This context contains the configuration to communicate with your minikube cluster. Because Minikube sets this context to default automatically, you can start using your kubernetes cluster right away:

rdecker@rdecker-mbpr /Users/rdecker
\❯ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
deployment "hello-minikube" created
rdecker@rdecker-mbpr /Users/rdecker
\❯ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed
rdecker@rdecker-mbpr /Users/rdecker
\❯ kubectl get pods
NAME                               READY     STATUS              RESTARTS   AGE
hello-minikube-180744149-vwzq1     0/1       ContainerCreating   0          1m
redis-test-795539674-d0tzf         1/1       Running             1          10d
show-the-awesome-254335071-2bz4c   1/1       Running             1          10d
show-the-awesome-254335071-wmmd3   1/1       Running             1          10d
rdecker@rdecker-mbpr /Users/rdecker
\❯ kubectl get pods
NAME                               READY     STATUS    RESTARTS   AGE
hello-minikube-180744149-vwzq1     1/1       Running   0          4m
redis-test-795539674-d0tzf         1/1       Running   1          10d
show-the-awesome-254335071-2bz4c   1/1       Running   1          10d
show-the-awesome-254335071-wmmd3   1/1       Running   1          10d
rdecker@rdecker-mbpr /Users/rdecker
\❯ curl (minikube service hello-minikube --url)
real path=/

server_version=nginx: 1.10.0 - lua: 10001


Please refer to the documentation page for Linux and Windows installation or additional information.

Minikube requirements:

  • kubectl

  • macOS

  • Linux

    • VirtualBox or KVM

    • NOTE: minikube also supports a ‘–vm-driver=none’ option that runs the kubernetes components on the host and not in a VM. docker is required to use this driver but no hypervisor.

  • Windows

    • VirtualBox or Hyper-V
  • VT-x/AMD-v virtualization must be enabled in BIOS

  • Internet connection on first run

Minikube Useful CLI

Get the IP of the local kubernetes cluster: minikube ip

SSH into the minikube VM: minikube ssh

SSH Access to Minikube

Open the kubernetes dashboard for your local cluster: minikube dashboard

Kubernetes Dashboard

List the services exposed via a node port: minikube service list

Minikube services list

Complete list of Minikube commands:

rdecker@rdecker-mbpr /Users/rdecker
\❯ minikube                                                                                                                                                                                                                           14:30:12
Minikube is a CLI tool that provisions and manages single-node Kubernetes clusters optimized for development workflows.

  minikube [command]

Available Commands:
  addons           Modify minikube's kubernetes addons
  completion       Outputs minikube shell completion for the given shell (bash)
  config           Modify minikube config
  dashboard        Opens/displays the kubernetes dashboard URL for your local cluster
  delete           Deletes a local kubernetes cluster
  docker-env       Sets up docker env variables; similar to '$(docker-machine env)'
  get-k8s-versions Gets the list of available kubernetes versions available for minikube
  ip               Retrieves the IP address of the running cluster
  logs             Gets the logs of the running localkube instance, used for debugging minikube, not user code
  mount            Mounts the specified directory into minikube
  profile          Profile sets the current minikube profile
  service          Gets the kubernetes URL(s) for the specified service in your local cluster
  ssh              Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'
  ssh-key          Retrieve the ssh identity key path of the specified cluster
  start            Starts a local kubernetes cluster
  status           Gets the status of a local kubernetes cluster
  stop             Stops a running local kubernetes cluster
  update-context   Verify the IP address of the running cluster in kubeconfig.
  version          Print the version of minikube

In conclusion, Minikube is a fantastic tool to easily get started on kubernetes. It allows you not only to learn about kubernetes, but also to test various versions, configuration, or even CLI results.




Staff II Technical Product Manager, technologist with 18+ years of Networking and Security experience in Data Center, Public Cloud & Virtualization (VMs and Containers). He is a double VCDX (DCV and NV, #120), VCDX panelist, frequent VMUG/VMworld speaker and contributor to the community via this blog or social media (follow him on Twitter @woueb).