liveBook · Manning

Persistent volume claim

As explained in Road to Kubernetes

A PersistentVolumeClaim is a Kubernetes resource that requests storage with specified capacity, access modes, and storage class properties.

A PersistentVolumeClaim (PVC) requests managed storage for a Kubernetes cluster. Kubernetes provisions the volume, attaches it to a node, and makes it available to Pods. section 8.4 section 8.4.1

A PVC manifest specifies the storage requirements and lifecycle:

  • accessModes controls how Pods use the volume; ReadWriteOnce allows attachment to one Pod, while other modes may depend on the cloud provider. section 8.4.1
  • resources.requests.storage sets the requested capacity, such as 10Gi. section 8.4.1
  • storageClassName selects the provider-backed storage behavior, including whether the volume is deleted or retained with the claim. section 8.4.1
  • A Deployment attaches the claim through volumes and volumeMounts, making the storage available at a container path. section 8.4.1

Attach a claim to nginx

Create a PVC requesting 10Gi with ReadWriteOnce, then reference it from an nginx Deployment. Apply both manifests with kubectl apply -f deploy-pvc/ and inspect the claim with kubectl describe pvc first-pvc. section 8.4.1

Listing 8.14 PersistentVolumeClaim resource
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: first-pvc
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: linode-block-storage-retain

Shows a complete PersistentVolumeClaim manifest with access mode, requested capacity, and retained block-storage class. section 8.4.1

Listing 8.15 Deployment resource with a PVC
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 1
  ...
  template:
    ...
    spec:
      ...
      containers:
      - name: nginx
        ...
        volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: first-pv-storage
      volumes:
      - name: first-pv-storage
        persistentVolumeClaim:
          claimName: first-pvc

Shows how a Deployment references the claim and mounts its volume at /usr/share/nginx/html. section 8.4.1

How Road to Kubernetes covers it

How deep it goes
Defines core manifest fields, provider limitations, lifecycle choices, attachment, application, and verification.
Examples
Uses a 10Gi nginx claim, a ReadWriteOnce access mode, volume mounting, kubectl application, and PVC inspection.
What you can do after
Operate/configure a PVC, attach it to a Deployment, apply the manifests, and inspect the resulting claim.
How it connects
Connects Kubernetes storage with PersistentVolumes, Deployments, Pods, StatefulSets, storage classes, and access modes.

Also explained in

Compare how 9 books explain persistent volume claim →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.