We will install Minikube in the same Linux machine we used to install Docker in Chapter 3, Containerization with Docker. So, if you haven’t done that, please go to Chapter 3, Containerization with Docker, and follow the instructions provided to set up Docker on your machine.
First, we will install kubectl. As described previously, kubectl is the command-line utility that interacts with the Kubernetes API server. We will use kubectl multiple times in this book.
To download the latest release of kubectl, run the following command:
$ curl -LO “https://storage.googleapis.com/kubernetes-release/release\
/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)\ /bin/linux/amd64/kubectl”
You can also download a specific version of kubectl. To do so, use the following command:
$ curl -LO https://storage.googleapis.com/kubernetes-release/release\ /v<kubectl_version>/bin/linux/amd64/kubectl
We will stick with the latest release for this chapter. Now, let’s go ahead and make the binary executable and then move it to any directory in your system PATH:
$ chmod +x ./kubectl
$ sudo mv kubectl /usr/local/bin/
Now, let’s check whether kubectl has been successfully installed by running the following command:
$ kubectl version –client
Client Version: version.Info{Major:”1″, Minor:”27″, GitVersion:”v1.27.3″}
Since kubectl was installed successfully, you must download the minikube binary and then move it to your system path using the following commands:
$ curl -Lo minikube \
https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ chmod +x minikube
$ sudo mv minikube /usr/local/bin/
Now, let’s install the packages required by Minikube to function correctly by running the following command:
$ sudo apt-get install -y conntrack
Finally, we can bootstrap a Minikube cluster using the following command:
$ minikube start –driver=docker
Done! kubectl is now configured to use “minikube” cluster and “default” namespace by default
As Minikube is now up and running, we will use the kubectl command-line utility to interact with the Kube API server to manage Kubernetes resources. The kubectl commands have a standard structure and are self-explanatory in most cases. They are structured as follows:
kubectl <verb> <resource type> <resource name> [–flags]
Here, we have the following:
- verb: The action to perform – for example, get, apply, delete, list, patch, run, and so on
- resource type: The Kubernetes resource to manage, such as node, pod, deployment, service, and so on
- resource name: The name of the resource to manage
Now, let’s use kubectl to get nodes and check whether our cluster is ready to run our containers:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 2m25s v1.26.3
Here, we can see that it is a single-node Kubernetes cluster running version v1.26.3. Kubernetes is now up and running!
This setup is excellent for development machines where developers want to deploy and test a single component they are working on.
To stop the Minikube cluster and delete it from the machine, you can use the following command:
$ minikube stop
Now that we have removed Minikube, let’s look at another exciting tool for creating a multi-node Kubernetes cluster.