How To — minikube with multi node setup

Kiranms
Cloudnloud Tech Community
5 min readMar 29, 2023

Before we start with minikube multi node setup, let us understand why minikube and what will be benefits of using minikube on our laptop or desktop

Minikube is a tool that allows us to setup and run Kubernetes locally on our laptop or desktop , making it easy to test and develop Kubernetes applications without the need for a full-size production like environment cluster. but its gives us alike working environment as production cluster itself, :P

Here are some pointers, why we want to use Minikube:

  1. Learning Kubernetes: If you are learning Kubernetes, Minikube is a great way to learn how Kubernetes works and how to deploy, scale, and manage applications on a Kubernetes cluster. also we can deploy sample learning project on minikube and learn and fail to learn.
  2. Local development: Minikube allows us to setup and run local Kubernetes cluster on our laptop and desktop, which makes easy to develop and test our Kubernetes applications without the need for a cloud-based setup or on-prem Kubernetes cluster environment setup.
  3. Testing and debugging: Minikube is great way to test and debug our Kubernetes applications locally before deploying them to a production environment.
  4. CI/CD: Minikube is great way to learn CI/CD pipeline setup to test Kubernetes applications for CI/CD learning with other DevOps tools.
  5. Resource efficiency: Minikube is lightweight and resource-efficient, so we can run it on laptop and desktop with limiting resources capacity assigned during cluster creation.
  6. Cost savings: One of the very important and concern part is cost for everyone who is learning Kubernetes, minikube is really great tool to try and learn as we don’t need to host it on any cloud. Using Minikube for learning can help you save money on cloud computing costs, as you do not need to provision and manage a full-fledged Kubernetes cluster in the cloud.

if you have any pointers you can comment in comment section.

pre-requisite.

  1. you should have minikube installed and configure on your laptop/Desktop to try multi node setup.

lets us jump to minikube multi node setup part now,

Before we start let us understand our setup with multi node cluster what we are going to create in minikube

we are going to create DEV , STG and PROD minikube cluster and deploy the sample nginx application on prod and see pods are deployed to all the nodes which is part of minikube PROD cluster.

let us create minikube cluster for DEV, STG and PROD.

# minikube start — nodes=2 -p dev

# minikube start — nodes=2 -p stg

# minikube start — nodes=2 -p prod

in this we are going to create dev environment cluster with default CPU and memory which is 2CPUs and 2GB of memory.

minikube dev cluster
minikube stg cluster
minikube stg cluster

lets check the minikube profile status and you can see 3 profile with 2 nodes each running in minikube environment.

minikube profile list

then check the which profile is currently active (in our case dev is active) and switch between the profiles.

# minikube profile

then select the profile that you want to use e.g. in this case i will be selecting prod profile to deploy nginx deployment.

# minikube profile prod

minikube profile prod
minikube profile

you can see the active prod profile as below in active colume

minikube active profile

then check the all the node status by running

# minikube status

minikube status

now you can login to any of your node from the cluster by entering below command

# minikube ssh — node prod

# minikube ssh — node prod-m02

minikube ssh — node prod
minikube ssh — node prod-m02

lets deploy sample nginx application in prod environment cluster.

# kubectl create deployment nginx — image=nginx — replicas=4

sample nginx deployment

now you can check the deployment status widely and see the container are deployed to each node in the cluster.

# minikube get pod -o wide

minikube get pod -o wide

lets stop all clusters and clean up profiles. here -p refer to profiles

# minikube stop -p dev

# minikube stop -p stg

# minikube stop -p prod

minikube stop dev
minikube stop stg
minikube stop prod

and run the delete command to delete you selected profiles.

minikube delete dev
minikube delete stg

you can see DEV and STG cluster are deleted and cleaned up. you can see that by runing below command.

# minikube profile list

this is just to focus on multi node setup so covering all the task related to multi node only, there are many things that you can explore as similar to production grade cluster to test you scenarios.

at the end minikube is really great tool to learn kubernetes in own lab.

if you like this blog please share, comment that motivates me to writes another great technological blogs.

Happy Learning !!

--

--