Author
This section provides a step-by-step practical workflow to deploy multiple microservices on a local Kubernetes cluster using Minikube. This setup helps simulate a production-like Kubernetes environment for testing and learning purposes.
First, start a local Kubernetes cluster using Minikube. This will spin up a single-node cluster on your machine.
minikube start
What happens here:
Tip: Use
minikube statusto verify the cluster is running properly.
Next, containerize each microservice with Docker. Each service should have its own Dockerfile.
docker build -t user-service:1.0 .
docker build -t order-service:1.0 .
Why this is important:
Make sure to tag your images properly for versioning (e.g.,
1.0,latest).
If using Minikube, Docker images built on your local machine may not automatically be available inside the Minikube cluster. Load them manually:
minikube image load user-service:1.0
minikube image load order-service:1.0
Purpose:
ImagePullBackOffDeploy your microservices using Kubernetes Deployment manifests. These YAML files define:
kubectl apply -f user-deployment.yaml
kubectl apply -f order-deployment.yaml
Kubernetes automatically creates the pods and maintains the desired number of replicas.
Expose your deployments so that they can communicate with each other or be accessed externally:
kubectl apply -f user-service.yaml
kubectl apply -f order-service.yaml
Service types:
Tip: Always use services for inter-service communication rather than hardcoding IPs.
Check the status of your pods and services:
kubectl get pods
kubectl get services
Expected outcome:
Running statusThis ensures your microservices are up and running correctly.
Access your services via Minikube:
minikube service user-service
Alternative:
Use the NodePort URL in your browser:
http://<minikube-ip>:<nodePort>
This opens your deployed application locally, allowing you to test functionality.
If something isn’t working, inspect logs and pod details:
kubectl logs <pod-name>
kubectl describe pod <pod-name>
Why this is useful:
You can scale microservices dynamically without downtime:
kubectl scale deployment user-service --replicas=3
Benefits of scaling:
After testing, remove all deployed resources and stop the Minikube cluster:
kubectl delete -f .
minikube stop
Why clean-up matters:
This workflow covers the complete lifecycle of microservices deployment on Minikube:
In simple terms, this guide provides a real production-like Kubernetes workflow locally, enabling you to test, debug, and scale microservices efficiently.