A hands-on lab for running a local Kubernetes cluster with Minikube, deploying the repository's custom NGINX image, exposing it with a LoadBalancer Service, and practicing common kubectl operations.
Minikube is intended for local learning, development, and testing. It is not a production Kubernetes platform.
Architecture: Windows/Linux/macOS → Docker driver → Minikube node → Kubernetes Deployment → Pods → Service → NGINX
- Enable CPU virtualization (Intel VT-x / AMD-V) in BIOS/UEFI if it is disabled.
- Install Docker Desktop, select the WSL 2 backend (recommended), and ensure Docker Desktop is running.
- Enable Virtual Machine Platform and Windows Subsystem for Linux as needed for WSL 2. Windows Hypervisor Platform / Hyper-V may be required for alternative virtualization configurations, but are not mandatory for the Docker driver.
- Restart Windows after changing virtualization or Windows features.
- Use PowerShell as Administrator for installation steps.
Check virtualization in Task Manager → Performance → CPU → Virtualization.
For WSL 2 setup (Admin PowerShell):
wsl --install
wsl --update
wsl --statusRestart if prompted. Install and start Docker Desktop separately.
Install Chocolatey first from its official instructions: https://chocolatey.org/install
choco install minikube kubernetes-cli -yInstall Docker Desktop from https://www.docker.com/products/docker-desktop/ if needed. Restart the terminal and verify:
minikube version
kubectl version --client
docker versionRun in a regular PowerShell terminal with Docker Desktop running:
minikube start --driver=docker
minikube status
kubectl cluster-info
kubectl get nodes -o wide
kubectl get pods -AThe default Minikube configuration commonly creates a single-node cluster. This is useful for learning but does not represent production staging.
| Command | Purpose |
|---|---|
minikube start |
Start an existing/default cluster |
minikube start --driver=docker |
Start using the Docker driver |
minikube status |
Check cluster status |
minikube ip |
Show the Minikube node IP |
minikube ssh |
Open a shell on the Minikube node |
minikube stop |
Stop the cluster without deleting it |
minikube delete |
Delete the local cluster |
List available add-ons, enable the metrics server, and launch the dashboard:
minikube addons list
minikube addons enable metrics-server
minikube dashboardThe dashboard command may keep its terminal occupied. Open a second terminal for other commands. Check metrics after the metrics-server is ready:
kubectl top nodes
kubectl top podsClone this repository and change into its directory:
git clone https://github.com/atulkamble/minikube-nginx.git
cd minikube-nginxThe repository includes:
Dockerfileandindex.html: build a custom NGINX image with the project web page.deployment.yaml: runs three replicas ofdocker.io/atuljkamble/nginxapp:latest.service.yaml: exposes the Pods using a LoadBalancer Service on port 80.
The Deployment selects Pods labelled app: myapp; the Service uses the same selector to route traffic to those Pods.
Apply the repository files from the project directory:
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl rollout status deployment/mydeployment
kubectl get deployments
kubectl get pods -o wide
kubectl get services
kubectl get endpoints myservice
kubectl get endpointslices -l kubernetes.io/service-name=myserviceThe Deployment should become available with three Pods. The Service endpoints should point to ready Pods.
Option A: use Minikube's service helper (often simplest with the Docker driver):
minikube service myserviceThis opens the app in a browser or prints a URL. If it starts a tunnel, keep the command running.
Option B: use port-forwarding. Run this in a terminal and leave it open:
kubectl port-forward service/myservice 8080:80Open http://localhost:8080 in a browser. To check the response from another terminal:
curl http://localhost:8080The page should include “Welcome to my website!”.
Use a tunnel when you want Minikube to provide an external address for a LoadBalancer Service. In a separate terminal:
minikube tunnelKeep it running; it may request elevated permissions. In another terminal, inspect the Service:
kubectl get svc myserviceUse its EXTERNAL-IP and port if reachable from your host. With some host and driver combinations, minikube service myservice or port-forwarding is more convenient. On Linux, sudo minikube tunnel is sometimes used, but is not universally required.
Scale the NGINX Deployment to five replicas and watch the Pods:
kubectl scale deployment/mydeployment --replicas=5
kubectl get deployment mydeployment
kubectl get pods -wStop watching with Ctrl+C, then scale back to three:
kubectl scale deployment/mydeployment --replicas=3
kubectl get podsUpdate the Deployment's container image to a versioned NGINX image:
kubectl set image deployment/mydeployment mycontainer=nginx:1.27-alpine
kubectl rollout status deployment/mydeployment
kubectl rollout history deployment/mydeploymentTo undo the image change and restore the image configured in the repository manifest:
kubectl rollout undo deployment/mydeployment
kubectl rollout status deployment/mydeployment
kubectl describe deployment mydeploymentTo reapply the repository's desired configuration later:
kubectl apply -f deployment.yamlKubernetes creates a default namespace for namespaced resources. A plain kubectl get pods lists Pods in the current namespace; -A lists Pods across all namespaces.
kubectl config current-context
kubectl config get-contexts
kubectl get namespaces
kubectl get pods -n default
kubectl get pods -A
kubectl get all -n defaultTo use Minikube's context if several clusters are configured:
kubectl config use-context minikubeminikube status
minikube addons list
minikube addons enable metrics-server
minikube dashboard
minikube tunnel
minikube ip
kubectl get nodes
kubectl get pods -A
kubectl get pods
kubectl get services
kubectl get svc
kubectl get nskubectl get services and kubectl get svc are equivalent. The dashboard and tunnel commands are long-running; run them in separate terminals and leave them open while using them.
| Problem | Check / fix |
|---|---|
| Docker driver fails | Start Docker Desktop; verify docker version |
| Virtualization unavailable | Enable VT-x/AMD-V; confirm WSL 2 configuration |
| No Pods | Check kubectl get pods -A, current context, and namespace |
| Pods not ready | Use kubectl describe pod <pod-name> and kubectl logs <pod-name> |
| Service has no endpoints | Check Pod readiness and the matching app: myapp selector |
EXTERNAL-IP shows <pending> |
Start minikube tunnel or use minikube service myservice |
| Browser cannot connect | Try kubectl port-forward service/myservice 8080:80 |
| Metrics unavailable | Wait for metrics-server readiness; inspect its Pods |
Useful diagnostic commands:
kubectl config current-context
kubectl get all
kubectl describe deployment mydeployment
kubectl describe svc myservice
kubectl logs deployment/mydeployment
kubectl get events --sort-by=.metadata.creationTimestampRemove the Service and Deployment, then confirm they are gone:
kubectl delete -f service.yaml
kubectl delete -f deployment.yaml
kubectl get services
kubectl get deployments
kubectl get podsStop Minikube but keep the cluster configuration:
minikube stopTo remove the entire local cluster and its configuration:
minikube deleteInstall Minikube, kubectl, and a supported driver using the platform-specific instructions. With Docker installed and running, the main cluster commands are the same:
minikube start --driver=docker
kubectl get nodes
minikube addons enable metrics-server
minikube addons enable ingress
minikube dashboardOfficial documentation: https://minikube.sigs.k8s.io/docs/start/