Practice · Module 07 — Kubernetes: basic concepts · Level intermediate
Try alone first! Complete the project with this brief only. The solution (commented manifests + commands) is in the README.md, folded. Open it only after you have tried.
demo-k8s:1.0 image already built (otherwise: docker build -t demo-k8s:1.0 ./app).Understand what a Service is for and master the three main types:
All of that on top of the same Deployment: one set of Pods, three ways to expose them.
Pods are ephemeral: they are born, they die, they change IP. You therefore cannot rely on a Pod’s IP. You need a stable address that distributes traffic to the right Pods: that is the role of the Service, which finds its Pods thanks to labels.
demo-k8s:1.0).app: demo-back).ClusterIP Service named demo-clusterip (port 80 → 5000).curl http://demo-clusteripNodePort Service named demo-nodeport (nodePort 30082).http://localhost:30082 from your browser.LoadBalancer Service named demo-lb (port 8090).EXTERNAL-IP (kubectl get svc) and open http://localhost:8090.kubectl get svc) and identify: TYPE, CLUSTER-IP, EXTERNAL-IP, PORT(S).kubectl get endpoints demo-clusterip): those are the Pod IPs behind the Service.k8s/deployment.yaml and the three Services (service-clusterip.yaml, service-nodeport.yaml, service-loadbalancer.yaml).kubectl get svc showing the 3 types.curl http://demo-clusterip from a client Pod) with 2 different Pod names.kubectl get endpoints demo-clusterip.| Criterion | Expected |
|---|---|
| ClusterIP | Reachable by DNS name from another Pod |
| NodePort | Reachable at http://localhost:30082 |
| LoadBalancer | EXTERNAL-IP = localhost, reachable at http://localhost:8090 |
| Distribution | The Pod name changes between two requests |
| Endpoints | The 3 Pod IPs appear behind the Service |
Stuck? The README.md contains the full solution, the ideas are detailed in 01-CONCEPTS-SERVICES.md, and 02-COMMANDES.md lists every useful
kubectl— read them after you have tried.