Example Documentation: Stateful Postgres
Goal
Run a stateful application with persistent storage, initialization, service discovery and a backup Job.
What Is Done
The lab creates a PostgreSQL instance as a StatefulSet, seeds data through a ConfigMap, stores data in a PVC and runs backups through a CronJob.
Typical Commands
kubectl apply -f manifests/
kubectl get pods,pvc,svc -n postgres-lab
kubectl describe statefulset postgres -n postgres-lab
kubectl create job manual-postgres-backup --from=cronjob/postgres-backup -n postgres-lab
Validate Success
postgres-0is ready.- The PVC
data-postgres-0is bound. - A manual backup Job reaches
Complete. - NetworkPolicies allow backup traffic to PostgreSQL, but no broad egress.
Common Mistakes
- No default StorageClass exists in the cluster.
- Secret values are accidentally reused in production.
- Backup Pods have no DNS or database egress.