Kubernetes Simulator
intermediate · ~8 min
Find each other
The shop is three deployments: frontend (nginx), and two APIs it calls, catalog and cart. Pods come and go and their IPs with them, so nothing should call a pod by address.
A Service gives a set of pods one stable name and IP. Cluster DNS answers that name from any pod — catalog, or in full catalog.default.svc.cluster.local. catalog listens on port 8080, and it serves its items at /api/catalog/items.
kubectl exec deploy/frontend -- curl … runs curl inside a frontend pod, where the cluster's DNS is.
Objectives
- Give catalog a Service on port 80
- Fetch the items from a frontend pod by name
- Bonus: Look the name up the way curl does: getent hosts catalog
Best on a computer with a keyboard. It works on a phone, with shortcuts under the terminal.