Source: Dev.to | Jan 04, 2026 (UTC)
“Production Basics: Deployment + Service + Rolling Update”
Browser → Service (NodePort) → Deployment → Pods (replicas=2) → nginx containers
Enter fullscreen mode
Exit fullscreen mode

What you will learn (DevOps core)
Start/verify:
minikube start kubectl get nodes
Enter fullscreen mode
Exit fullscreen mode
Step 0 — Clean up from Project #1 (if you ran it)
This prevents conflicts and confusion.
kubectl delete pod hello-pod --ignore-not-found kubectl delete svc hello-service --ignore-not-found
Enter fullscreen mode
Exit fullscreen mode
Check nothing left:
kubectl get pods kubectl get svc
Enter fullscreen mode
Exit fullscreen mode
Step 1 — Create a Deployment (NOT a Pod)
A Deployment is a “manager” that ensures the desired number of Pods are always running.
Create file: deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: hello-deploy spec: replicas: 2 selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: nginx image: nginx:1.25 ports: - containerPort: 80
Enter fullscreen mode
Exit fullscreen mode
Apply it:
kubectl apply -f deployment.yaml
Enter fullscreen mode
Exit fullscreen mode
What each part means (important)
kubectl get deployments kubectl get pods -o wide
Enter fullscreen mode
Exit fullscreen mode
Expected:
hello-deploy READY 2/2 hello-deploy-xxxxx Step 2 — Understand what Deployment created
A Deployment automatically creates:
Check:
kubectl get rs
Enter fullscreen mode
Exit fullscreen mode
Explain:
Step 3 — Expose it using a Service (stable access)
Pods get replaced and IPs change, so we use a Service.
Create file: service.yaml
apiVersion: v1 kind: Service metadata: name: hello-service spec: type: NodePort selector: app: hello ports: - port: 80 targetPort: 80
Enter fullscreen mode
Exit fullscreen mode
Apply:
kubectl apply -f service.yaml
Enter fullscreen mode
Exit fullscreen mode
selector: app: hello → finds pods with that labelport: 80 → service porttargetPort: 80 → container portNodePort → opens a port on the node so your browser can reach itVerify:
kubectl get svc kubectl describe svc hello-service
Enter fullscreen mode
Exit fullscreen mode
Key thing to check inside describe:
Endpoints should show 2 pod IPs
Run:
minikube service hello-service --url
Enter fullscreen mode
Exit fullscreen mode
It prints something like:
http://127.0.0.1:5xxxx
Enter fullscreen mode
Exit fullscreen mode
Open that URL in a browser → you should see Welcome to nginx!
Why this is best:
Step 5 — Prove High Availability (Replica behavior)
Delete one Pod manually:
kubectl get pods
Enter fullscreen mode
Exit fullscreen mode
kubectl delete pod <one-pod-name>
Enter fullscreen mode
Exit fullscreen mode
kubectl get pods -w
Enter fullscreen mode
Exit fullscreen mode
What you will observe:
Explain to students:
This is Kubernetes self-healing. You don’t “restart containers” manually in prod. The controller does it.
Step 6 — Scale Up (simulate traffic growth)
Scale to 5 replicas:
kubectl scale deployment hello-deploy --replicas=5
Enter fullscreen mode
Exit fullscreen mode
Check:
kubectl get pods kubectl get deployment hello-deploy
Enter fullscreen mode
Exit fullscreen mode
Expected: 5 pods running.
Explain:
Scaling is a normal DevOps operation during peak traffic.
Scale back down:
kubectl scale deployment hello-deploy --replicas=2
Enter fullscreen mode
Exit fullscreen mode
Step 7 — Rolling Update (Zero-downtime deployment)
Now you will change the image version and watch Kubernetes update pods gradually.
Update to a newer nginx (example):
kubectl set image deployment/hello-deploy nginx=nginx:1.26
Enter fullscreen mode
Exit fullscreen mode
Watch rollout:
kubectl rollout status deployment/hello-deploy kubectl get pods -w
Enter fullscreen mode
Exit fullscreen mode
What you’ll see:
Check rollout history:
kubectl rollout history deployment/hello-deploy
Enter fullscreen mode
Exit fullscreen mode
Rollback (very important skill):
kubectl rollout undo deployment/hello-deploy
Enter fullscreen mode
Exit fullscreen mode
Explain:
Rollback is what you do when a release breaks production.
Step 8 — Troubleshooting Checklist (Most important for DevOps)
Case A: Service exists but website doesn’t open
Run in this order:
kubectl get pods
Enter fullscreen mode
Exit fullscreen mode
kubectl describe pod <pod>
Enter fullscreen mode
Exit fullscreen mode
kubectl describe svc hello-service
Enter fullscreen mode
Exit fullscreen mode
Look for:
Endpoints: <ip1>:80, <ip2>:80 If endpoints empty → selector mismatch.kubectl get pods --show-labels kubectl get svc hello-service -o yaml
Enter fullscreen mode
Exit fullscreen mode
Check:
kubectl describe pod <pod>
Enter fullscreen mode
Exit fullscreen mode
Typical reasons:
kubectl logs <pod> kubectl describe pod <pod>
Enter fullscreen mode
Exit fullscreen mode
Look for:
What you should be able to explain after Project #2
If you can explain these, you’re at a strong DevOps level:
kubectl delete -f service.yaml kubectl delete -f deployment.yaml
Enter fullscreen mode
Exit fullscreen mode
For further actions, you may consider blocking this person and/or reporting abuse
Залишити відповідь