A storage volume is the stateful part of an application environment: an attached resource that lets an application read and write data while its container remains stateless. This makes volumes essential for practical data stores such as databases and message queues. section 8.4.2
In Kubernetes, a StatefulSet can attach a separate volume to each Pod replica through a volume template. A Postgres deployment requests 20Gi of storage, mounts it at /var/lib/postgresql, and uses an init container to remove the volume's lost+found directory. section 8.4.2
Listing 8.18 StatefulSet for Postgres, part 2
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
...
spec:
...
volumeClaimTemplates:
- metadata:
name: db-vol
spec:
storageClassName: linode-block-storage-retain
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 20Gi
Inspect the volumeClaimTemplates configuration that requests storage and defines the storage class and access mode. section 8.4.2







