The text that follows provides the essential information you'll need to create a local Kubernetes cluster using minikube. This appendix contains a few sub-chapters from The DevOps 2.3 Toolkit: Kubernetes (https://amzn.to/2GvzDjy). Please refer to it for more detailed information.
You're reading from The DevOps 2.4 Toolkit
Running Kubernetes Cluster Locally
Minikube creates a single-node cluster inside a VM on your laptop. While that is not ideal since we won't be able to demonstrate some of the features Kubernetes provides in a multi-node setup, it should be more than enough to explain most of the concepts behind Kubernetes. Later on, we'll move into a more production-like environment and explore the features that cannot be demonstrated in Minikube.
Please run all the examples from GitBash (installed through Git). That way the commands you'll see throughout the book will be same as those that should be executed on MacOS or any Linux distribution. If you're using Hyper-V instead of VirtualBox, you may need to run the GitBash window as an Administrator.
Before we dive into Minikube installation, there are a few...
Installing kubectl
Kubernetes' command-line tool, kubectl, is used to manage a cluster and applications running inside it. We'll use kubectl a lot throughout the book, so we won't go into details just yet. Instead, we'll discuss its commands through examples that will follow shortly. For now, think of it as your interlocutor with a Kubernetes cluster.
Let's install kubectl.
If you are a MacOS user, please execute the commands that follow.
1 curl -LO
https://storage.googleapis.com/kubernetes-release/release/`curl -s
https://storage.googleapis...
Installing Minikube
Minikube supports several virtualization technologies. We'll use VirtualBox throughout the book since it is the only virtualization supported in all operating systems. If you do not have it already, please head to the Download VirtualBox (https://www.virtualbox.org/wiki/Downloads) page and get the version that matches your OS. Please keep in mind that for VirtualBox or HyperV to work, virtualization must be enabled in the BIOS. Most laptops should have it enabled by default.
Finally, we can install Minikube.
If you're using MacOS, please execute the command that follows.
1 brew cask install minikube
If, on the other hand, you prefer Linux, the command is as follows.
1 curl -Lo minikube
https://storage.googleapis.com/minikube/releases/latest/minikube-linux-
amd64 && chmod +x minikube && sudo mv minikube...
Creating a local Kubernetes cluster with Minikube
The folks behind Minikube made creating a cluster as easy as it can get. All we need to do is to execute a single command. Minikube will start a virtual machine locally and deploy the necessary Kubernetes components into it. The VM will get configured with Docker and Kubernetes via a single binary called localkube.
1 minikube start --vm-driver=virtualbox
You might experience problems with virtualbox. If that's the case, you might want to use hyperv instead. Open a Powershell Admin Window and execute the Get-NetAdapter command, noting the name of your network connection. Create a hyperv virtual switch New-VMSwitch -name NonDockerSwitch -NetAdapterName Ethernet -AllowManagementOS $true replacing Ethernet with your network connection name. Then...
What Now?
We are finished with a short introduction to Minikube. Actually, this might be called a long introduction as well. We use it to create a single-node Kubernetes cluster, launch the UI, do common VM operations like stop, restart, and delete, and so on. There's not much more to it. If you are familiar with Vagrant or Docker Machine, the principle is the same, and the commands are very similar.
Before we leave, we'll destroy the cluster. The next chapter will start fresh. That way, you can execute commands from any chapter at any time.
1 minikube delete
That's it. The cluster is no more.