Services and Storage Clinic
Retrieval Prompts
- State the four guarantees of the Kubernetes pod network model.
- Name the four Service types and what each gives you.
- State the difference between
port,targetPort, andnodePort. - Explain what an EndpointSlice is and who populates it.
- State the difference between
ReadWriteOnce,ReadOnlyMany, andReadWriteMany.
Compare and Distinguish
Separate:
- ClusterIP versus headless Service
- Ingress versus Gateway API
- Volume versus PersistentVolume versus PersistentVolumeClaim
- StatefulSet versus Deployment
emptyDirversusconfigMapvolume versus PVC-backed volume
Common Mistake Check
For each, identify the error:
- "My Service has no endpoints because the selector is wrong." (Is that always the reason?)
- "I'll just use Ingress; I don't need to install anything."
- "ReadWriteOnce means one Pod at a time can mount the volume."
- "Deleting a PVC deletes the disk."
- "A StatefulSet gives me automatic database failover."
Mini Application
East-west: Service + DNS
Apply the Deployment from Workshop 02 and a ClusterIP Service:
apiVersion: v1
kind: Service
metadata: { name: web }
spec:
selector: { app: web }
ports:
- { name: http, port: 80, targetPort: 80 }
From a debug pod (kubectl run -it --rm debug --image=nicolaka/netshoot -- bash):
dig +short web.default.svc.cluster.local
curl -v http://web
Break the readiness probe intentionally (set path: /definitely-not-here). Verify that kubectl get endpointslices -l kubernetes.io/service-name=web goes empty and curl begins to fail. Restore and verify recovery.
North-south: Ingress
Install the NGINX ingress controller. Add a second Deployment api. Write one Ingress that routes / -> web and /api -> api. Verify both paths via port-forward.
Draw the path
Produce a hand-drawn or ASCII diagram for the full path external client -> LB -> node -> ingress controller Pod -> Service -> Pod -> container. Label who is responsible for each hop.
Stateful: PVC + StatefulSet
Deploy a three-replica Postgres StatefulSet with a headless Service as in Concept 12. Verify:
kubectl get sts,pvc,pv,svc
dig +short db-1.db.default.svc.cluster.local
Delete db-1. Confirm the new Pod has the same name, the same DNS, and the same PVC.
Evidence Check
This page is complete only if you can produce, from memory, a working Deployment + Service + Ingress configuration and a StatefulSet + headless Service + PVC configuration, and trace the packet path for a request into each.