Kubernetes Simulator
beginner · ~8 min
Give it an address
Pods come and go, and each new one gets a new IP address. Nothing should depend on a pod's IP. A Service gives a set of pods one stable address and spreads traffic across whichever of them are ready.
A Service finds its pods by label, not by name: its selector — here app=web — matches the labels the deployment puts on every pod. The pods it picks are its endpoints.
You can make one with kubectl expose, or write it as YAML and kubectl apply -f it. Type vi svc.yaml to open the editor.
Objectives
- Create a Service called web that selects the app=web pods
- Listen on port 80 and send traffic to the pods' port 80
- All 3 pods sit behind it as endpoints
- Bonus: Write the Service as YAML and kubectl apply -f it
Best on a computer with a keyboard. It works on a phone, with shortcuts under the terminal.