# Installing minikube as a Kubernetes cluster
If you know about Kubernetes, you must have heard that it is a platform that helps in managing containerized applications. With Kubernetes, you can manage applications with the help of clusters. As a developer, you need to learn how to set up a cluster in your local machine. In this article, we will understand how we can initialize a cluster in our local machine with the help of minikube.
So, without wasting any time, let’s start!
## What is a Kubernetes cluster?
We can define a Kubernetes cluster as a set of nodes that helps in running containerized applications. It allows easy developing, moving, and managing applications as containerization helps in packaging an application with dependencies and necessary services.
A Kubernetes cluster allows a container to run through various machines and environments such as on-premises, virtual, physical, or cloud-based. A cluster comprises a master node and several worker nodes. The nodes can either be virtual machines or physical computers, depending on the cluster.
## What is minikube?
We can see minikube as a tool that helps run Kubernetes in your local machine. But, in addition, it helps run a Kubernetes cluster in your personal computer comprising of any operating system to try out Kubernetes for your daily development work.
Minikube spins up a single node cluster that works both as a master node as well as a worker node.
## Prerequisites for installing minikube
We have to comply with a few prerequisites to install minikube in our machine. However, the conditions mostly comprised all the system requirements we needed to match before installing and running the minikube.
We will need a minimum of 2 CPUs or more, 2 GB of free memory, and 20 GB of free disk space in your machine to install minikube successfully. We will also need to install a container or a virtual machine manager on your computer. We can choose from a range of virtual machine managers such as Docker, Hyper X, VirtualBox, Podman, etc.
I will be using VirtualBox as the virtual machine manager. Hence, I need to download and install it. You can download VirtualBox from [here](https://www.virtualbox.org/wiki/Downloads). You will be able to choose the package that you want to download based on your operating system. After downloading, install it according to the prompts given by the installer.
## How to install minikube?
To install minikube, we have to navigate to the official page of the minikube installation in the Kubernetes official documentation. After heading to the page, select the package according to your requirements. As for me, I will choose `Windows` as my operating system with the default `x86-64` architecture. Then, select the release type as stable. Finally, I will select the installer type as the `.exe download`. You can also choose Windows package manager or chocolatey as the installer type according to your wish.
![](https://i.imgur.com/9lHXH0C.png)
Download the installer from this [link](https://storage.googleapis.com/minikube/releases/latest/minikube-installer.exe), or you can also use Windows PowerShell to download the installer.
If you are using `PowerShell`, use the following command to download the installer:
```
New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force
Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing
```
This command will download and install minikube on your local machine. After that, you need to add the binary into your PATH. Before executing this step, make sure to open PowerShell as an administrator. Then, use the following command for adding the binary:
```
$oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine)
if ($oldPath.Split(';') -inotcontains 'C:\minikube'){ `
[Environment]::SetEnvironmentVariable('Path', $('{0};C:\minikube' -f $oldPath), [EnvironmentVariableTarget]::Machine) `
}
```
If you are using any Command Line Interface (CLI) to perform the installation, then restart the CLI to see the effective changes.
## How does minikube work?
We have downloaded and installed minikube in our system, and we will use it to spin up a cluster in our machine. To do that, we have to run a simple command that will initiate a cluster formation. Now, remember we have downloaded and installed VirtualBox at the start of the installation. We will need it as a driver as we are operating on Windows operating system.
Minikube will locally start a virtual machine and deploy all the necessary Kubernetes components into it. This VM will get configured with VirtualBox and Kubernetes via a single binary known as the local Kube. So, open Command Prompt or any terminal on your system, and run the following command:
```
minikube start --driver=virtualbox
```
![](https://i.imgur.com/2nuwJwK.png)
This command will start a single node cluster and will after a few moments, you will see the cluster up and running.
When we are doing the `minikube start` command, it creates a new virtual machine based on the minikube image, containing a few binaries. It has both Docker and RKP container images and a local Kube library. RKP is an application container engine developed for modern production cloud-native environments, and the local Kube library includes all the necessary components for running Kubernetes.
Also, I need to mention that if you face any problem with VirtualBox, you can use other containers such as Hyper V, Docker, etc.
Now, if you want to verify the running of your cluster, run the following command in your terminal:
```
kubectl get nodes
```
In the output, you will see that minikube is up and running on your machine with the status showing as "Ready". You will also get to see the roles, age, and version associated with the cluster.
### Kubectl with minikube
Now, we will check if Kubectl is also pointing to that particular virtual machine of Minikube. For that, enter the following command in your terminal:
```
kubectl config current-context
```
It will return Minikube as the output. It portrays the configuration of Kubectl to talk to the Kubernetes inside the newly created cluster.
You can also list all the nodes from Kubectl. To do that, enter the command:
```
kubectl get nodes
```
You will again receive Minikube as the output. You will notice that it says there is only one node because we mentioned in the beginning that it works as the master node and the worker node.
Now, we will look at all the components that are currently running in our cluster. You can notice that this is a very tiny cluster, and we don't have many things going on over here. To glance at all the running services, enter the following command:
```
kubectl get namespaces
```
In the output, you will get to see the all the namespaces associated with your cluster.
### Minikube status
Suppose you want to see the verification and look at the status of the cluster. In that case, open command prompt and enter the command:
```
minikube status
```
With this command, you will see Kube configured, API server kubelet, host, and type control plane, and everything listed over. So now our Kubernetes minikube is running, and it is initializing a Kubernetes cluster as well. It even configured kubectl to point to the newly created virtual machine.
![](https://i.imgur.com/iXM24IK.png)
### Minikube ssh
Since almost everything in that virtual machine is a container pointing to the local Docker client, it should be all you need besides Kubectl. However, you might want to SSH into the virtual machine in some cases. In that case, enter this command in the command prompt:
```
minikube ssh
```
You will see that with this command, you will get logged into the ssh. After that, enter the following command:
```
docker container ls
```
You will get to see the listed containers. So, we entered into the Minikube, listed all the containers, and now, we can also exit out of it. To exit, just simply enter `exit` in the terminal which will log you out from the minikube ssh.
### Minikube dashboard
We can access the Kubernetes dashboard through minikube. If you want to explore the Kubernetes dashboard, you can do that with the help of a simple command. Run the following command in your terminal:
```
minikube dashboard
```
When you run this command, you will be automatically redirected to a server URL in which you will be able to see the dashboard. You can play around with the dashboard and with that, you will be able to see the running nodes, installed pods, ingresses, services, and much more.
![](https://i.imgur.com/TtKyDzU.png)
### Stopping and deleting a cluster
Now, we will look at the commands that will allow us to stop or delete a minikube cluster. To stop a cluster, we have to enter a simple command in the command prompt:
```
minikube stop
```
It shuts down the virtual machine, but it will preserve all the cluster states and data. If we start the cluster again, it will restore it to the previous data.
To delete a cluster, enter the following command in your terminal:
```
minikube delete
```
If we enter this command, it will delete the cluster. It's going to shut down and delete the minikube virtual machine. One thing to note over here is that no data or state will be preserved.
## Conclusion
We have read throughout the article about minikube, the way to install it and how we can use it in our local machine. Hope you have learned something from this article. Try out minikube in your local machine and get a hands-on experience with Kubernetes. Play around and get your hands dirty with this single node cluster and I will see you in the next one.