Final project: run a shop on Kubernetes from start to finish
In this task you'll put every Kubernetes skill together by running, securing, scaling and fixing a small shop.
This project joins the section's tasks into one realistic job. You run a three-part shop (web front, API and a database), expose it through a Gateway, keep the database's data on a claim, give the team only the access it needs, add probes and resource limits, scale on load, back up the cluster, and then fix three faults someone has planted.
Work as you would at work: write down what you change and why, prove each step with a command, and keep everything in YAML files you could commit to Git.
Example. A new platform engineer at Brindle Outdoor is asked to take over the shop's test environment. They rebuild it from YAML on kind, fix the faults left in it, and hand back a short report with the commands that prove each part works.
Before you start
You need: Docker Desktop, kind and kubectl on your computer (all free), and a cluster from Run a practice cluster on your computer, plus the Gateway API controller and metrics-server from earlier tasks. Time: 3 hours.
Where to look
- Terminal
- kubectl
- Helm
Steps
- Create namespaces
shopandshop-db. Deploy PostgreSQL as a StatefulSet with a 1Gi claim inshop-db, its password in a Secret. - Deploy the API (2 replicas) and web front (2 replicas) in
shop, with settings from a ConfigMap, requests and limits, and startup, readiness and liveness probes. - Expose the web front through a Gateway and HTTPRoute for host
shop.local, and the API on path/api. - Create a
shop-teamservice account with edit rights inshoponly, and prove withkubectl auth can-ithat it can't touchshop-db. - Add a HorizontalPodAutoscaler to the API (target 60% CPU) and a disruption budget allowing one pod down; load it and watch it scale.
- Take an etcd snapshot, then fix three planted faults: a Service with the wrong selector, a CronJob that overlaps itself, and a liveness probe that calls the database.
- Write a one-page report: what you built, the three faults and their fixes, and the commands that prove the shop works.
Commands
kubectl create namespace shop
kubectl create namespace shop-db
kubectl apply -f ./shop/ # your manifests
kubectl get all,pvc,httproute,hpa,pdb -n shop
kubectl auth can-i delete statefulsets -n shop-db --as=system:serviceaccount:shop:shop-team
Watch out for
- Cost
- Free on kind. Give Docker Desktop at least 6 GB of memory.
- Security
- Keep the database in its own namespace, its password in a Secret you never commit, and the team's rights to its own namespace.
- Common mistakes
- Building everything with imperative commands you can't repeat; keep the YAML.
Clean up
kind delete cluster --name lab when you've finished, after saving your YAML and report.
Words to know
- Capstone
- A final project that uses everything a course has taught.
- Manifest
- A YAML file describing Kubernetes objects.
- Runbook
- Written steps for running or fixing a system.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On