DEV Community

Cover image for Minikube for Beginners: A Guide to a Local Kubernetes Cluster on MacOS
Sha Md Nayeem
Sha Md Nayeem

Posted on • Originally published at cloudifydevops.com on

Minikube for Beginners: A Guide to a Local Kubernetes Cluster on MacOS

Minikube is a tool that lets you test and develops Kubernetes applications on a single node on your local workstation. You need Minikube if you want an easy and convenient approach to test and build applications on a local Kubernetes cluster without disrupting other systems or applications. It supports a number of hypervisors and offers a low-cost, isolated environment for testing and development.

In this article, let's look at how we can set up Minikube for MacOS

Step 1: Install Homebrew

Homebrew, a popular package manager for macOS, can be used to install Minikube. Run the following command in your terminal if Homebrew isn't already installed on your device:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Enter fullscreen mode Exit fullscreen mode

Step 2: Install Minikube

To install Minikube, run the following command in your terminal using Homebrew:

brew install minikube

Enter fullscreen mode Exit fullscreen mode

Step 3: Start Minikube

You can start Minikube by running the following command in your terminal:

minikube start

Enter fullscreen mode Exit fullscreen mode

If you have a Docker machine installed in your MacOS, you might get the following error while executing the above command. To solve this issue , you need to start the Docker desktop application and rerun the command.

  Exiting due to DRV_DOCKER_NOT_RUNNING: Found docker, but the docker service isn't running. Try restarting the docker service.

Enter fullscreen mode Exit fullscreen mode

Step 4: Set Context

Now you need to set the context to minikube so that the kubectl command can interact with it:

kubectl config use-context minikube

Enter fullscreen mode Exit fullscreen mode

Step 5: Verify Minikube Setup

Now you can verify the status of Minikube using the following command in your terminal:

minikube status

Enter fullscreen mode Exit fullscreen mode

Step 6: Interacting with Cluster

To interact with the newly created cluster in your MacOS, you need to run the following command in your terminal if you have kubectl already installed :

kubectl get po -A

Enter fullscreen mode Exit fullscreen mode

But, if you don't have kubectl installed on your MacOS, then run the following command where minikube can download the appropriate kubectl version:

minikube kubectl -- get po -A

Enter fullscreen mode Exit fullscreen mode

Step 7: Testing Minikube

Now, we can test the minikube by deploying a simple application by following the command in the terminal:

kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube --type=NodePort --port=8080

Enter fullscreen mode Exit fullscreen mode

This might take some time but if you run the following command, the deployment will show up:

kubectl get services hello-minikube

Enter fullscreen mode Exit fullscreen mode

Letting Minikube open a web browser for you is the simplest approach to using this service. To do that run the following command in the terminal:

minikube service hello-minikube

Enter fullscreen mode Exit fullscreen mode

Step 8: Access Kubernetes Dashboard

To access the dashboard of Kubernetes, you need to run the following command which will open a Kubernetes dashboard on the web browser with a user-friendly interface:

minikube dashboard

Enter fullscreen mode Exit fullscreen mode

Conclusion:

In this article, we have learned about Minikube and how to set it up on MacOS with a step-by-step process.

I hope this article has helped you to explore Minikube's capabilities for testing and deploying applications on a single node of a Kubernetes cluster.


I appreciate you taking the time to read this. If you do have still some confusion regarding this article, please let me know in the comments! Also, If you liked this article, consider following me for my latest publications and also follow me on Medium Twitter & LinkedIn.

Top comments (0)