Kubernetes Field Guide · Chapter 16 of 16
Capstone: ship a three-tier app to your own cluster
Put every chapter together. Ship a three-tier app to a cluster you run yourself, with probes, autoscaling, TLS, security policies, dashboards and a pipeline, then break it on purpose and write up what you learned. This is the project you show in an interview.
- 50 min
- Advanced
- Project
- Free
By Joshua Sequeira, founding engineer running Kubernetes in production. Updated .
By the end you can
0 of 4
Live lab in this chapter
A real-feeling terminal and a live cluster map, right in your browser. Every command block below has a ▶ Run in lab button.
The brief
Build and operate a small three-tier app: a frontend, an API and a PostgreSQL database, on a cluster you run. Use your own app if you have one. If not, podinfo works well: it has health endpoints, Prometheus metrics, and a frontend mode that calls a backend. Pin a current image tag.
The goal is not the app. It is to show that you can take software from a repository to a platform that is secure, observable, scalable and recoverable, and explain every decision.
Target architecture
| Layer | Kubernetes objects | Chapter |
|---|---|---|
| Entry | Ingress or Gateway + HTTPRoute, cert-manager Certificate | 8 |
| Frontend | Deployment, Service, PDB | 4, 5 |
| API | Deployment, Service, HPA, PDB, ConfigMap, ServiceAccount | 4–6, 9–11 |
| Data | StatefulSet, headless Service, PVC, Secret | 6, 7 |
| Guard rails | Namespaces, ResourceQuota, Pod Security labels, NetworkPolicies, Roles | 11 |
| Delivery | Helm chart, values per environment, pipeline or Argo CD Application | 12 |
| Visibility | kube-prometheus-stack, ServiceMonitor, PrometheusRule, dashboard | 14 |
Traffic flows one way: Ingress → frontend → API → database. Your network policies should allow exactly those three paths and nothing else.
Milestones
Tick them off as you go. Progress is saved in this browser.
helm repo add podinfo https://stefanprodan.github.io/podinfo
helm upgrade --install backend podinfo/podinfo -n dev --create-namespace
helm upgrade --install frontend podinfo/podinfo -n dev --set backend=http://backend-podinfo:9898/echo
backend=...- The frontend calls the backend Service by its DNS name. Replace both with your own chart as you progress.
The lab is docked at the bottom of your screen.
Live lab · no install
Build the skeleton in your browser
Namespaces, an API, a frontend, one entry point, autoscaling and a game day, on a three-node K3s cluster.
- Tasks0/6
One namespace per environment
kubectl create namespace dev kubectl create namespace prodRun the API with two replicas
kubectl -n dev create deployment api --image=ghcr.io/stefanprodan/podinfo:6.7.1 --replicas=2 --port=9898 kubectl -n dev expose deployment api --port=9898Run a frontend that calls it by name
kubectl -n dev create deployment frontend --image=nginx:1.27 --port=80 kubectl -n dev expose deployment frontend --port=80 kubectl -n dev rollout status deployment/frontend kubectl -n dev exec deploy/frontend -- curl -s http://api:9898Give them one entry point
kubectl -n dev create ingress app --rule="/*=frontend:80" --rule="/api*=api:9898" curl localhost:8081/apiAutoscale the API
kubectl -n dev set resources deployment api --requests=cpu=50m,memory=32Mi kubectl -n dev autoscale deployment api --cpu-percent=60 --min=2 --max=6Game day: lose a node
Before you trust it, break it. Do users still get answers?
docker stop k3d-learn-k3s-agent-0 sleep 4 kubectl get nodes curl localhost:8081/apiThe node is gone and the API still answers: its replicas were spread, and the dead node's pods are replaced elsewhere.
- Lab complete. Keep experimenting, or press Reset to start again.
- ready
- starting / not ready
- failing
- terminating
Chaos day: will it survive?
Before you call it done, be honest about what you built. Tick only what is really in your repository, then read down the list. Every failure here happens to real clusters; each one maps to a chapter.
Interactive · Chaos day
Tick what your build has. Then see what it survives.
Stretch goals
- GitOps. Argo CD syncing both environments from a deploy repository, with self-heal on.
- Canary. A Gateway API HTTPRoute sending 10% of traffic to a new API version, promoted by hand after checking the dashboard.
- Secrets from a manager. External Secrets Operator pulling the database password from a real secret store.
- Real servers. Two small VMs from any provider running K3s, with etcd snapshots copied to object storage, and a restore you have actually tested.
- A cost report. Requests versus real usage for every workload after a week, and what right-sizing would save.
Self-review checklist
Before you call it done, answer each of these in your README:
- If I delete any one pod, does anything break for users? How do I know?
- If I deploy a broken image, what stops it reaching users, and how do I roll back?
- Which pod can reach the database, and what prevents the others?
- Where does the database password live, and who can read it?
- What alert fires when the API is slow, and what does its runbook say?
- How much does this cost per month on a cloud, and which single change would cut that most?
- What would I change first if this had to serve ten times the traffic?
Mini mission
Write the one-page architecture note
Write one page a teammate could read in five minutes: what you built, a diagram, three decisions with the alternative you rejected and why, the monthly cost estimate, and the top risk you would fix next.
Reveal one safe solution
A structure that works:
- Context in two sentences: what the app does and who uses it.
- Diagram: Ingress, frontend, API, database, plus monitoring and the pipeline.
- Decisions: for example K3s over a managed cluster (cost, control) against operational load; Postgres in-cluster for the project but managed in production; no CPU limits but memory limits equal to requests.
- Cost: nodes by requests, load balancers, storage, monitoring.
- Risks: the single points of failure left, and the next fix.
Link it from your portfolio. That is the kind of write-up the case studies on this site are built from.
Check yourself
Quiz
0 of 5 answered