Skip to content

Persistent volumes in practice

Class behaviour (reclaim policy, ReadWriteOnce, expansion, retained volumes) is in Storage classes. This page covers claiming and mounting volumes.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-data
namespace: <tenant>-prod
spec:
accessModes:
- ReadWriteOnce
storageClassName: csi-cinder-sc-delete # or csi-cinder-sc-retain
resources:
requests:
storage: 10Gi
  • Class: the default, csi-cinder-sc-delete, destroys the volume when the claim is deleted. Use csi-cinder-sc-retain for data that must survive a mistaken delete. No other class exists.
  • Size: the request counts against your tenant’s storage quota whatever you actually write; see Quotas.
  • Start small: volumes can be expanded later but not shrunk.

A new Cinder volume’s root directory is root:root with mode 0755. Kestrel Pods must run as non-root (PodSecurity restricted), so set fsGroup in the Pod’s securityContext; without it, every write to the volume fails with Permission denied.

apiVersion: v1
kind: Pod
metadata:
name: app
namespace: <tenant>-prod
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000 # the volume becomes group-writable by GID 1000
fsGroupChangePolicy: OnRootMismatch # skip the recursive chown when ownership already matches
seccompProfile:
type: RuntimeDefault
containers:
- name: app
image: your-image:latest
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: my-data
  • In a Deployment, StatefulSet or Job, put the same securityContext in the Pod template.
  • A Deployment that mounts an RWO claim needs strategy: {type: Recreate}, or use a StatefulSet. See ReadWriteOnce: one node at a time.
  • fsGroup has no effect on shared (RWX) volumes; see below.

There is no ReadWriteMany StorageClass. There are two ways to get a shared volume:

  • A CephFS share from your Arbutus project, self-service. You create the share in OpenStack and claim it with an annotated PVC, and Kestrel creates the PersistentVolume. See CephFS shares.
  • A static PersistentVolume from RCS, on request, for storage that isn’t in your Arbutus project. The rest of this section covers this option.

Either way the claim’s storage request counts against your tenant’s storage quota, like any PVC.

Request one with an RCS ticket that gives:

  • The namespace that will mount it. Each namespace needs its own PV and claim. PVs that point at the same storage see the same data, so to share data across namespaces, ask for one PV per namespace. For separate storage per namespace, such as dev and prod, say so and give each a size.
  • The size, and any quota increase it needs.
  • The UID and GID your Pods run as. Kubernetes does not change ownership on shared filesystems (fsGroup has no effect), so RCS makes the volume’s root writable by that UID and GID.

RCS replies with the PV name. The PV carries your tenant label and looks like this:

# Created by RCS; shown for reference. Tenants can't list or delete PersistentVolumes.
apiVersion: v1
kind: PersistentVolume
metadata:
name: <pv-name>
labels:
capsule.clastix.io/tenant: <tenant>
spec:
capacity:
storage: 20Gi
accessModes:
- ReadWriteMany
storageClassName: ""
# volume source set by RCS

Claim it from the namespace you named:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: shared-data
namespace: <tenant>-prod
spec:
accessModes:
- ReadWriteMany
storageClassName: "" # required: an omitted class gets the default, and the claim never binds
volumeName: <pv-name> # required: admission rejects a class-less claim without it
resources:
requests:
storage: 20Gi # any size up to the PV's capacity

Mount the claim as in the Pod example above, minus fsGroup, with runAsUser and runAsGroup set to the UID and GID you gave RCS. Any number of Pods, on any node, can mount it at once.

SymptomCause and fix
PVC Pending, event ProvisioningFailed … storageclass.storage.k8s.io "<name>" not foundThe class doesn’t exist. Use csi-cinder-sc-delete or csi-cinder-sc-retain.
Create or resize fails with exceeded quotaYour tenant’s storage ceiling is reached and nothing was created. See Quotas.
Pod stuck in ContainerCreating, event Multi-Attach errorThe RWO volume is still attached on another node. Use strategy: Recreate or a StatefulSet.
Permission denied writing to a Cinder volumeSet fsGroup (above).
Permission denied writing to an RWX volumeThe volume root isn’t writable by your Pod’s UID/GID. Run as the UID/GID you gave RCS, or ask RCS to change the ownership. For a CephFS share, see its troubleshooting.
Claim refused: A PVC without a StorageClass must set spec.volumeName… or spec.volumeName may name only a PersistentVolume reserved for this PVC…Set volumeName to the PV name RCS gave you, and create the claim in the namespace you named. For CephFS share claims, see its admission errors.
RWX claim stays PendingCheck accessModes: [ReadWriteMany] and a request no larger than the PV’s capacity.
PVC condition FileSystemResizePendingRestart the Pod to finish the resize.