Search⌘ K
AI Features

Creating a Local Kubernetes Cluster with minikube

Explore how to create a local Kubernetes cluster with Minikube by starting a virtual machine that includes all necessary Kubernetes components. Understand the setup process, verify the cluster status, and get a brief introduction to the Kubernetes dashboard. This lesson helps you gain practical experience in running Kubernetes locally for development and experimentation.

Starting minikube to create a cluster

minikube has 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.

Shell
minikube start --vm-driver=virtualbox

A note to windows users

You might experience problems with VirtualBox. If that’s the case, you might want to use Hyper-V instead.

  • Open a Powershell Admin Window and execute the Get-NetAdapter command. Note 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, create the minikube VM: minikube start --vm-driver=hyperv --hyperv-virtual-switch "NonDockerSwitch" --memory=4096.

Other minikube commands such as minikube start, minikube stop, and minikube delete all work the same whether you’re using VirutalBox or Hyper-V.

A few moments later, a new minikube VM will be created and set up, and a cluster will be ready for use.

Understanding the process

When we execute the minikube start command, it creates a new VM based on the minikube image. This image contains a few binaries. It has both Docker and rkt container engines as well as the localkube library.

Note: rkt is an application container engine developed for modern production cloud-native environments.

The localkube library includes all the components necessary for running Kubernetes. We’ll go into details of all those components later. For now, the important thing is that localkube provides everything we need to run a Kubernetes cluster locally.

Remember that this is a single-node cluster running locally on our machine only. While that is unfortunate, it is still the easiest way to “play” with Kubernetes locally. It should do for now. Later on, we’ll explore ways to create a multi-node cluster that will be much closer to a production setup.

Verification

Let’s take a look at the status of the cluster:

Shell
minikube status

The output is as follows:

Shell
host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

minikube is running, and it initializes a Kubernetes cluster. It even configures kubectl so that it points to the newly created VM.

Exploring the Kubernetes dashboard

You won’t see much UI in this course. We believe that a terminal is the best way to operate a cluster. More importantly, we are convinced that one should learn a tool through its commands first. Later on, once we feel comfortable and understand how the tool works, we can choose to use a UI on top of it. We’ll explore the Kubernetes UI in one of the later lessons. For now, you can have a quick glimpse of it.

Shell
minikube dashboard

The above command will redirect you to the following page on your browser.

the minikube dashboard
the minikube dashboard

Feel free to explore the UI but don’t take too long! If the UI is hard to understand at first, don’t worry. Once we learn about Pods, ReplicaSets, Services, and many other Kubernetes components, the UI will start making much more sense.