Deploying & Exposing NGINX on Local Kubernetes (Minikube Lab)
This document provides a structured, step-by-step guide to deploy an NGINX application on a local Kubernetes cluster using Minikube and expose it through a Kubernetes Service.
Ensure the following tools are installed and running:
- ✅ Docker Desktop (running in background)
- ✅ Minikube
- ✅ kubectl
- ✅ Stable Internet connection
- ✅ Basic understanding of Kubernetes YAML files
Verify installations:
minikube version
kubectl version --client
docker --versionStart your local Kubernetes cluster:
minikube start
minikube statusVerify cluster node:
kubectl get nodesExpected Output:
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane ...
List available addons:
minikube addons listEnable Metrics Server (for monitoring):
minikube addons enable metrics-serverOpen Kubernetes Dashboard:
minikube dashboardmkdir minikube-nginx
cd minikube-nginxCreate file:
touch deployment.yamlapiVersion: apps/v1
kind: Deployment
metadata:
name: access-app-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80kubectl apply -f deployment.yamlVerify:
kubectl get deployments
kubectl get podsCreate file:
touch service.yamlapiVersion: v1
kind: Service
metadata:
name: access-app-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
type: NodePortkubectl apply -f service.yamlVerify:
kubectl get servicesminikube service access-app-serviceThis will automatically open the NGINX application in your browser.
For LoadBalancer support in Minikube:
minikube tunnelKeep this running in a separate terminal.
Update replicas in deployment.yaml:
replicas: 5Apply changes:
kubectl apply -f deployment.yamlVerify:
kubectl get podsYou should now see 5 running pods.
After enabling metrics-server:
kubectl top nodes
kubectl top podskubectl get all
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl delete -f deployment.yaml
kubectl delete -f service.yamlOn AKS, expose deployment using LoadBalancer:
kubectl expose deployment access-app-deployment \
--name=access-app-service \
--type=LoadBalancer \
--port=80 \
--target-port=80Then check external IP:
kubectl get services✔ Minikube started ✔ Deployment created ✔ Pods running ✔ Service exposed ✔ Application accessible in browser ✔ Scaling verified ✔ Monitoring enabled
This lab demonstrated:
- Kubernetes Deployment creation
- Replica management
- Service exposure (NodePort / LoadBalancer)
- Local cluster management with Minikube
- Basic monitoring using metrics-server