A database is a stateful data store: its application may run in a container, but the data it reads and writes must persist in a storage volume. This persistence makes databases more complex to deploy than stateless web applications. section 8.4.2 section 1.6
Deploying a database with Kubernetes requires coordinating:
- A persistent volume so data survives beyond the container. section 8.4.2
- A StatefulSet that gives each Pod a volume, predictable name, and ordered creation and deletion. section 8.4.2
PostgreSQL with a StatefulSet
A PostgreSQL deployment requests a 20Gi retained block-storage volume, mounts it at /var/lib/postgresql, loads credentials from a Secret, and exposes port 5432 through a ClusterIP Service. An init container removes the volume's lost+found directory before PostgreSQL starts. A StatefulSet can run the database with persistent storage, but multiple replicas do not automatically form a PostgreSQL cluster. section 8.4.2























