Skip to Content

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 , founding engineer running Kubernetes in production. Updated .

usersyour K3s cluster, installed with HelmIngressTLSfrontendHPA 2 to 5podpodapiprobes, limitspodpodpostgresStatefulSet + PVCPrometheus, Grafanadashboards, alerts
The chapter in one pictureWhat you will have running by the end of the course.

By the end you can

0 of 4

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

LayerKubernetes objectsChapter
EntryIngress or Gateway + HTTPRoute, cert-manager Certificate8
FrontendDeployment, Service, PDB4, 5
APIDeployment, Service, HPA, PDB, ConfigMap, ServiceAccount4–6, 9–11
DataStatefulSet, headless Service, PVC, Secret6, 7
Guard railsNamespaces, ResourceQuota, Pod Security labels, NetworkPolicies, Roles11
DeliveryHelm chart, values per environment, pipeline or Argo CD Application12
Visibilitykube-prometheus-stack, ServiceMonitor, PrometheusRule, dashboard14

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.

A head start with podinfo
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.

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.

kind-learn
  1. Tasks0/6
  2. One namespace per environment
    kubectl create namespace dev
    kubectl create namespace prod
  3. Run 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=9898
  4. Run 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:9898
  5. Give them one entry point
    kubectl -n dev create ingress app --rule="/*=frontend:80" --rule="/api*=api:9898"
    curl localhost:8081/api
  6. Autoscale 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=6
  7. Game 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/api

    The node is gone and the API still answers: its replicas were spread, and the dead node's pods are replaced elsewhere.

  8. Lab complete. Keep experimenting, or press Reset to start again.
↑↓ history · Tab complete · Ctrl+C stop
Cluster map live
  • 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:

    1. Context in two sentences: what the app does and who uses it.
    2. Diagram: Ingress, frontend, API, database, plus monitoring and the pipeline.
    3. 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.
    4. Cost: nodes by requests, load balancers, storage, monitoring.
    5. 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

    1. 1. Your API pods are Running but the frontend gets errors. Which do you check first?
    2. 2. Where should the PostgreSQL password live?
    3. 3. What protects the API during a node drain?
    4. 4. Why break the system on purpose in a game day?
    5. 5. Moving this project from k3d to a cloud, which choice usually changes first for a small team?

    Further reading