Fresh Blurbs

Installing and Running Kubernetes Locally On a MacOS Sierra

Kubernetes is probably the most popular container-orchestration system, currently. It was originally developed and eventually open-sourced by Google. Kubernetes competes with the likes of Swarm, DC/OS and AWS's ECS.

Kubernetes is a complex ecosystem of various software components that is actually quite non-trivial to put together. It can be a great way of orchestrating containers (e.g. Docker ones) in production, but if you need a compatible local environment for development, setting such thing up yourself, from scratch, can be a painful experience. Which is why the community has created Minikube - a Kubernetes distribution for easy local installation.

Minikube, by default, still requires a Docker-compatible VM. There are many ways of getting one, but at the time of this writing, the most straightforward way, on MacOS Sierra, is the installation of Docker for Mac. The good news is: you won't need VirtualBox or some other kind of standalone VM environment to run the installation.

Note: some of the following instructions are specific to the component versions available at the time of writing. If you are reading this post later, please make sure to use commands that contain updated versions of the corresponding software.

To run through the commands you will need a working Docker for Mac and Homebrew. Make sure to install those, before executing the following commands.

Once you have Docker for Mac and Homebrew:

$ brew update
$ curl -LO \
&& chmod +x docker-machine-driver-hyperkit \
&& sudo mv docker-machine-driver-hyperkit /usr/local/bin/ \
&& sudo chown root:wheel /usr/local/bin/docker-machine-driver-hyperkit \
&& sudo chmod u+s /usr/local/bin/docker-machine-driver-hyperkit

$ curl -Lo minikube && chmod +x minikube && sudo mv minikube /usr/local/bin/
$ curl -Lo kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/

$ minikube start --vm-driver=hyperkit
# or if you want to see logs:
$ minikube start --logtostderr --vm-driver=hyperkit

If you are working behind a proxy, start minikube as:

$ no_proxy=",,0.0.0" \
  minikube start --docker-env http_proxy=$http_proxy \
                 --docker-env https_proxy=$https_proxy \
                 --docker-env no_proxy=$no_proxy

where $http_proxy is full proxy URI, such as:

When Minikube launches it create a “minikube” context, and sets it to default in kubectl. If you switch to another context in kubectl and need to switch back to minikube context later, run: kubectl config use-context minikube.

Bash Completions

If you don't already have bash completions installed, for the bas version included with Mac OS (Bash 3.2) run:

$ brew install bash-completion

or if you are running the upgraded bash 4.x version, run:

$ brew install bash-completion@2

and follow the instructions in the "caveats" section of brew’s output to add the appropriate bash completion path to your local .bash_profile or .bashrc.

To add kubectl completions to bash_completion:

$ kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
comments powered by Disqus