PVC Read-Back Test¶
A minimal workload that writes a file to a PersistentVolumeClaim, then spins up a second pod that mounts the same PVC and reads the file back. This validates end-to-end that the CSI driver, StorageClass, and persistent storage are functioning correctly.
Prerequisites¶
- Storage configured with a default StorageClass
Deploy¶
-
Create a namespace:
-
Create the PersistentVolumeClaim:
-
Run a pod that writes a file to the PVC:
apiVersion: v1 kind: Pod metadata: name: pvc-writer namespace: pvc-readback spec: restartPolicy: Never containers: - name: writer image: registry.redhat.io/ubi9/ubi-minimal command: - sh - -c - | echo "Hello from OpenShift PVC test - written at $(date)" > /data/testfile.txt echo "File written successfully." volumeMounts: - name: data mountPath: /data volumes: - name: data persistentVolumeClaim: claimName: readback-pvc -
Wait for the writer pod to complete:
The pod should reach
Completedstatus. Confirm the write succeeded: -
Run a second pod that reads the file back from the same PVC:
apiVersion: v1 kind: Pod metadata: name: pvc-reader namespace: pvc-readback spec: restartPolicy: Never containers: - name: reader image: registry.redhat.io/ubi9/ubi-minimal command: - sh - -c - | echo "Reading file from PVC:" cat /data/testfile.txt volumeMounts: - name: data mountPath: /data readOnly: true volumes: - name: data persistentVolumeClaim: claimName: readback-pvc -
Verify the reader pod can see the data:
You should see:
What This Validates¶
- PVC provisioning — the StorageClass dynamically provisions a volume
- Data persistence — data written by one pod is available to another pod mounting the same PVC
- CSI driver functionality — the full attach/mount/read/write path works end-to-end