Run Kubernetes locally
tstromberg Merge pull request #3260 from tstromberg/disable-mount-osx
Disable mount tests in Darwin to workaround panic: timeout bug
Latest commit 2ec03eb Oct 19, 2018
Permalink
Failed to load latest commit information.
.github Update ISSUE_TEMPLATE Oct 2, 2018
cmd Merge branch 'master' into consistent_err_formatting Oct 19, 2018
deploy Merge branch 'master' into consistent_err_formatting Oct 19, 2018
docs Merge pull request #3240 from tstromberg/vmdriver=None Oct 19, 2018
hack minikube tunnel (#3015) Oct 18, 2018
installers Update homebrew-cask release process: remove `checkpoint` Jun 12, 2018
logo Update logo_white.svg Aug 14, 2018
pkg Merge pull request #3187 from tstromberg/consistent_err_formatting Oct 19, 2018
test/integration Merge pull request #3260 from tstromberg/disable-mount-osx Oct 20, 2018
third_party/go9p Replace 9p mount calls to syscall.Rename with os.Rename, which is cap… Aug 6, 2018
vendor Bump everything to 1.11. Sep 26, 2018
.codecov.yml Disable codecov comment bot Aug 4, 2017
.dockerignore Add a .dockerignore to make image builds faster. Nov 6, 2017
.gitignore Added .vscode to .gitignore Apr 7, 2017
.travis.yml Let Travis track the latest stable Go 1.x release. Oct 4, 2018
CHANGELOG.md Move asterisks over. Oct 9, 2018
CONTRIBUTING.md Update CLA link Jan 2, 2018
Gopkg.lock Bump everything to 1.11. Sep 26, 2018
Gopkg.toml Switch the source of libmachine to machine-drivers. Oct 1, 2018
LICENSE Update License file Apr 15, 2016
MAINTAINERS Add balint to maintainers Jul 31, 2018
Makefile Bump Makefile to v0.30.0 Oct 5, 2018
OWNERS adding tstromberg Sep 21, 2018
README.md Mention CVE on frontpage. Oct 9, 2018
SECURITY_CONTACTS Add security contacts. May 25, 2018
code-of-conduct.md Update code-of-conduct.md Dec 20, 2017
makedepend.sh Add missing boilerplate to makedepend.sh Feb 26, 2018
test.sh minikube tunnel (#3015) Oct 18, 2018

README.md

Minikube

BuildStatus Widget CodeCovWidget GoReport Widget

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 your laptop for users looking to try out Kubernetes or develop with it day-to-day.

Newsflash

  • 2018-10-05: minikube v0.30.0 released, addressing CVE-2018-1002103: Dashboard vulnerable to DNS rebinding attack

Installation

macOS

brew cask install minikube

Linux

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && sudo install minikube-linux-amd64 /usr/local/bin/minikube

Windows

Hyper-V needs to be enabled. For Windows 10 this can only run on these versions:

  • Windows 10 Enterprise
  • Windows 10 Professional
  • Windows 10 Education

Install with Chocolatey (recommended):

These commands must be run as administrator. To do this, open the Windows command line by typing 'cmd' in your start menu, right clicking it and choosing 'Run as administrator'.

choco install minikube
choco install kubernetes-cli

After it finished installing, close the current command line and restart. Minikube was added to your path automatically.

To start the minikube cluster, make sure you also have administrator rights.

minikube start

You might have to specify the vm driver.

minikube start --vm-driver hyperv

Install manually

Download the minikube-windows-amd64.exe file, rename it to minikube.exe and add it to your path.

Linux Continuous Integration without VM Support

Example with kubectl installation:

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo cp minikube /usr/local/bin/ && rm minikube
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 cp kubectl /usr/local/bin/ && rm kubectl

export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export MINIKUBE_HOME=$HOME
export CHANGE_MINIKUBE_NONE_USER=true
mkdir -p $HOME/.kube
mkdir -p $HOME/.minikube
touch $HOME/.kube/config

export KUBECONFIG=$HOME/.kube/config
sudo -E minikube start --vm-driver=none

# this for loop waits until kubectl can access the api server that Minikube has created
for i in {1..150}; do # timeout for 5 minutes
   kubectl get po &> /dev/null
   if [ $? -ne 1 ]; then
      break
  fi
  sleep 2
done

# kubectl commands are now able to interact with Minikube cluster

Other Ways to Install

Minikube Version Management

The asdf tool offers version management for a wide range of languages and tools. On macOS, asdf is available via Homebrew and can be installed with brew install asdf. Then, the Minikube plugin itself can be installed with asdf plugin-add minikube. A specific version of Minikube can be installed with asdf install minikube <version>. The tool allows you to switch versions for projects using a .tool-versions file inside the project. An asdf plugin exists for kubectl as well.

We also released a Debian package and Windows installer on our releases page. If you maintain a Minikube package, please feel free to add it here.

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. If you use --vm-driver=none, be sure to specify a bridge network for docker. Otherwise it might change between network restarts, causing loss of connectivity to your cluster.
  • Windows
  • VT-x/AMD-v virtualization must be enabled in BIOS
  • Internet connection on first run

Quickstart

Here's a brief demo of Minikube usage. If you want to change the VM driver add the appropriate --vm-driver=xxx flag to minikube start. Minikube supports the following drivers:

  • virtualbox
  • vmwarefusion
  • KVM2
  • KVM (deprecated in favor of KVM2)
  • hyperkit
  • xhyve
  • hyperv
  • none (Linux-only) - this driver can be used to run the Kubernetes cluster components on the host instead of in a VM. This can be useful for CI workloads which do not support nested virtualization.
$ minikube start
Starting local Kubernetes v1.7.5 cluster...
Starting VM...
SSH-ing files into VM...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster.

$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
deployment "hello-minikube" created
$ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed

# We have now launched an echoserver pod but we have to wait until the pod is up before curling/accessing it
# via the exposed service.
# To check whether the pod is up and running we can use the following:
$ kubectl get pod
NAME                              READY     STATUS              RESTARTS   AGE
hello-minikube-3383150820-vctvh   1/1       ContainerCreating   0          3s
# We can see that the pod is still being created from the ContainerCreating status
$ kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-3383150820-vctvh   1/1       Running   0          13s
# We can see that the pod is now Running and we will now be able to curl it:
$ curl $(minikube service hello-minikube --url)
CLIENT VALUES:
client_address=192.168.99.1
command=GET
real path=/
...
$ kubectl delete service hello-minikube
service "hello-minikube" deleted
$ kubectl delete deployment hello-minikube
deployment "hello-minikube" deleted
$ minikube stop
Stopping local Kubernetes cluster...
Machine stopped.

Interacting With Your Cluster

kubectl

The minikube start command creates a "kubectl context" called "minikube". This context contains the configuration to communicate with your Minikube cluster.

Minikube sets this context to default automatically, but if you need to switch back to it in the future, run:

kubectl config use-context minikube,

or pass the context on each command like this: kubectl get pods --context=minikube.

Dashboard

To access the Kubernetes Dashboard, run this command in a shell after starting Minikube to get the address:

minikube dashboard

Services

To access a service exposed via a node port, run this command in a shell after starting Minikube to get the address:

minikube service [-n NAMESPACE] [--url] NAME

Design

Minikube uses libmachine for provisioning VMs, and kubeadm to provision a kubernetes cluster

For more information about Minikube, see the proposal.

Additional Links

Community