Skip to content

Storage

Servers are replaced at every update of the cluster: nothing written to a node's disk lasts, an emptyDir goes with its pod. Data lives in volumes: PersistentVolumeClaims of the default StorageClass (cinder).

apiVersion: v1
kind: PersistentVolumeClaim
metadata: {name: my-app-data, namespace: my-app}
spec:
  accessModes: [ReadWriteOnce]
  resources: {requests: {storage: 10Gi}}
  • ReadWriteOnce: a volume is attached to one node at a time. Several pods sharing data need a service of their own (a database, object storage), not a shared volume.
  • Created where its pod goes (WaitForFirstConsumer): in the availability zone of the node the pod is scheduled on. When a server is replaced, the pod moves and its volume follows it.
  • Deleted with its claim (Delete): deleting the PersistentVolumeClaim deletes the data. A namespace removed from the cluster's declaration is kept, its claims with it.
  • Expandable: raise resources.requests.storage on the claim.
  • A Deployment with a volume: strategy: {type: Recreate} (Deploying); a StatefulSet for several instances, each with its own volume (volumeClaimTemplates).
  • Backups are the application's: a volume isn't backed up by the cluster.