Minikube on local -Theory and Demo

Vivek Singh
4 min readApr 14, 2023

What is Minikube and How to Use It?

Minikube is an open-source tool that allows you to run Kubernetes on your local machine. It’s a lightweight Kubernetes implementation that is perfect for testing and development purposes. In this article, we will look at what Minikube is, how to install it, and how to use it.

Why Use Minikube?

Kubernetes is a powerful container orchestration platform that allows you to deploy, manage, and scale containerized applications. However, setting up a Kubernetes cluster can be a challenging task, and it requires a significant amount of resources. That’s where Minikube comes in. With Minikube, you can easily set up a Kubernetes cluster on your local machine, without the need for a cloud provider or a dedicated server.

Minikube Installation

Before we can start using Minikube, we need to install it first. The installation process is straightforward, and it can be done in a few simple steps.

Step 1: Install a Docker/Hypervisor

Minikube requires a hypervisor or a Docker to run, so the first step is to install one. If you are using a Mac or Windows machine, you can install VirtualBox, Hyper-V, or Docker.
Hypervisors and Docker are different. A hypervisor abstracts away hardware for the virtual machines so they can run an operating system, a Docker container engine abstracts away an operating system so containers can run applications. A Hypervisor boots up its own guest OS, a Docker uses the host OS. Therefore, Hypervisor virtualizes both the operating system kernel and the application layer. A Docker container virtualizes only the application layer, and runs on top of the host operating system.

We will use Docker for our purpose : https://docs.docker.com/desktop/install/mac-install/

Make sure to select the right preferences based on your OS.

Step 2: Install kubectl

kubectl is a command-line tool that allows you to interact with Kubernetes clusters. You can download it from the official Kubernetes website or install it using a package manager.

MAC/Linux/ Windows:

To download on MAC: https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"

Step 3: Install Minikube

You can download Minikube from the official Minikube doc.

Link : https://minikube.sigs.k8s.io/docs/start/

Select the right options according to your host and requirements :

For MAC :

$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ sudo install minikube-linux-amd64 /usr/local/bin/minikube

Starting Minikube

Now that we have installed Minikube, we can start it using the following command:

$ minikube start

Run to check if minikube is started :

minikube status

Output:

type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

Using Minikube for a demo

Once Minikube is up and running, you can start using it to deploy and manage applications. You can interact with the cluster using kubectl.

For the Demo — we will run a HTTP Server. We are using a very common image name echo-server.

Create a deployment and start the server:

kubectl create deployment hello-minikube-server --image=kicbase/echo-server:1.0 --port=8080 --replicas=2

Exposing a service as a NodePort

kubectl expose deployment hello-minikube-server --type=NodePort --port=8080

Check if your server is running :

minikube service list
List of server running on minikube

In the above screenshot, hello-minikube-server is running on port 8080.

Get and open the exposed endpoint using below command :

minikube service hello-minikube-server

The above command will print the IP and Port where our HTTP Echo server is running :

HTTP Server URLs

One of the coolest feature by Minikube — Access the Kubernetes dashboard running within the minikube cluster and check all the data insights :

minikube dashboard
Minikube Cluster Dashboard

The Dashboard is a web-based Kubernetes user interface. You can use it to:

  • deploy containerized applications to a Kubernetes cluster
  • troubleshoot your containerized application
  • manage the cluster resources
  • get an overview of applications running on your cluster
  • creating or modifying individual Kubernetes resources (such as Deployments, Jobs, DaemonSets, etc)

Additional commands :

Get the running deployments by executing the below command in Master node.

kubectl get deploy

Delete all the deployments, run below command:

kubectl delete deploy <deployment name>

Stop your local cluster:

minikube stop

Delete your local cluster:

minikube delete

Delete all local clusters and profiles

minikube delete --all

Conclusion

Minikube is an excellent tool for testing and development purposes. It allows you to set up a Kubernetes cluster on your local machine without the need for a dedicated server or a cloud provider. In this article, we looked at what Minikube is, how to install it and how to use it to deploy and manage applications. With Minikube, you can easily develop and test Kubernetes applications on your local machine, which can save you a lot of time and resources in the long run

Ending notes :

I am active on Medium so please reach out to me in case you face any issues while running the application on local/server. Happy to help.
For any freelancing work or a healthy conversation — reach me out at
vivek.sinless@gmail.com or LinkedIn

--

--

Vivek Singh

Software Developer. I write about Full Stack, NLP and Blockchain. Buy me a coffee - buymeacoffee.com/viveksinless