How Can I Verify Whether My Persistent Volume Claim Is Working?
Question
How can I check if my Persistent Volume Claim (PVC) is working correctly?
Environment
Container platform: Kubernetes
Answer
When you deploy the Hybrid Deployment Agent in Kubernetes, you need persistent shared storage across all worker nodes.
To set this up, you do the following:
- Specify a Storage Class (SC)
- Define a Persistent Volume (PV)
- Create a Persistent Volume Claim.
After creating the PVC, you can verify it by deploying a test Pod that mounts the PVC and writes a file to the storage.
To check your persistent shared storage, do the following:
Save the following YAML as
test-pvc-pod.yaml
.- The sample uses a PVC named
your-data-vol-claim-name
and thenamespace
default. - Modify these values as needed for your environment.
apiVersion: v1 kind: Pod metadata: name: test-pvc-pod namespace: default spec: containers: - name: test-pvc-container image: alpine command: ["/bin/sh"] args: ["-c", "echo 'Testing pvc storage is working' >> /data/$(date -u).txt; tail -f /dev/null"] volumeMounts: - name: test-storage mountPath: /data volumes: - name: test-storage persistentVolumeClaim: claimName: your-data-vol-claim-name
- The sample uses a PVC named
Deploy the test Pod:
kubectl apply -f test-pvc-pod.yaml
Verify that the file was written:
kubectl exec -it test-pvc-pod -- ls /data
If you see a file with a UTC timestamp in the /data
directory, your PVC is working correctly.