Paths/DevOps Engineer/Kubernetes / Services
Expose a Deployment
Pods come and go, so their IPs are useless as an address. A Service gives a stable virtual IP and DNS name in front of a set of Pods.
Validator
IDLE — checks run live as you type commands; submit when done
01Requirements
live checks- A Service named web-svc exists○
- The Service forwards to the web deployment on port 80○
02Walkthrough
4 steps- 01
Make sure the Deployment exists
Services select Pods by label. If you completed the deployment task it's already there; otherwise create one replica.
kubectl create deployment web --image=nginx:1.27 - 02
Expose it
kubectl expose creates a Service targeting the Deployment's Pods. --port is what clients call (80); --target-port is what the container listens on (8080 here — the app's port).
kubectl expose deployment web --name=web-svc --port=80 --target-port=8080 - 03
Verify the Service
kubectl get services lists it with a stable CLUSTER-IP and the port mapping 80/TCP.
kubectl get services - 04
Submit for validation
The validator checks the Service and the Deployment behind it.
03Stuck?
0 of 3 revealedTake a hint without losing the lab — each one points at the thing to look at, not at the answer.
04AI Tutor
guides, never solvesTell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?
04Notebook
saved locally in this browserlearner@lab — kubernetes 1.30 (kind)
Session is disposable
↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list