The example code in chapters 10 and 11 requires a working Kubernetes installation. In this appendix, you’ll find instructions on installing a Kubernetes development environment on your own laptop or desktop.
Although Docker Desktop for Mac comes with a functioning Kubernetes environment, the examples in the book have only been tested with Minikube running on VirtualBox, so I recommend you install these components to ensure compatibility.
Note The instructions in this appendix assume you have installed Homebrew. Follow the instructions in appendix A to configure Homebrew before continuing.
The instructions require MacOS 10.12 (Sierra) or later.
Kubernetes uses Linux containers as the units of execution on a cluster, so for other operating systems, you’ll need to install a virtual machine that will be used to run a Linux guest environment. The examples have been tested with Oracle’s VirtualBox (https://www.virtualbox.org), which is a freely available virtual machine that runs on MacOS.
Note Although the base VirtualBox package is open source under the terms of the GPL, the VirtualBox Extension Pack uses different licensing terms. See https://www.virtualbox.org/wiki/Licensing_FAQ for details. None of the examples in the book require the extension pack.
You can install VirtualBox either by downloading an installer from the VirtualBox website, or by using Homebrew by running:
brew cask install virtualbox
Note After installing VirtualBox you may need to manually approve the installation of the kernel extension it requires to run. Follow the instructions on Apple’s website: http://mng.bz/5pQz.
After VirtualBox is installed you can install a Kubernetes distribution. Minikube (https://minikube.sigs.k8s.io/docs/) is a single-node Kubernetes cluster that you can run on a developer machine. You can install Minikube using Homebrew by running:
brew install minikube
Afterward, you should configure Minikube to use VirtualBox as its virtual machine by running the following command:
You can then start minikube by running minikube start --kubernetes-version=1.16.2 ❶ --memory=4096 ❷
❶ The version of Kubernetes used in the book
Tip A running Minikube cluster can use a lot of power and memory. Stop Minikube when you’re not using it by running minikube
stop
.
Installing Minikube with Homebrew will also install the kubectl
command-line application required to configure a Kubernetes cluster. You can check that it’s installed correctly by running:
kubectl version --client --short
You should see output like the following:
Client Version: v1.16.3
If kubectl can’t be found, then make sure that /usr/local/bin is in your PATH by running:
export PATH=$PATH:/usr/local/bin
You should then be able to use kubectl.
Although Linux is the native environment for Kubernetes, it’s still recommended to install Minikube using a virtual machine for maximum compatibility. For testing, I’ve used VirtualBox on Linux too, so that is the recommended option.
VirtualBox for Linux can be installed by following the instructions for your Linux distribution at https://www.virtualbox.org/wiki/Linux_Downloads.
Minikube can be installed by direct download by running the following command:
curl
-LO https://storage.googleapis.com/minikube/releases/latest/
➥ minikube-linux-amd64
&& sudo install minikube-linux-amd64 /usr/local/bin/minikube
Afterward, you can configure Minikube to use VirtualBox by running:
minikube config set vm-driver=virtualbox
You can then follow the instructions at the end of section B.1.2 to ensure Minikube and kubectl are correctly installed.
Tip If you want to install Minikube using your distribution’s package manager, see the instructions at https://minikube.sigs.k8s.io/docs/start and click on the Linux tab for various distributions.
VirtualBox for Windows can be installed using the installer file from https://www .virtualbox.org/wiki/Downloads.
A Windows installer for Minikube can be downloaded from https://storage.googleapis .com/minikube/releases/latest/minikube-installer.exe. Follow the on-screen instructions after downloading and running the installer.
Once Minikube is installed, open a terminal window, and run:
minikube config set vm-driver=virtualbox
to configure Minikube to use VirtualBox.
44.200.94.150