Containers made the idea of ephemeral systems famous. But almost all systems need to store data permanently. In Kubernetes, the PersistentVolumeClaim (PVC) resources allow you to claim a volume that can be mounted in a container. With systems like rook-ceph, it’s very convenient to provide dynamic provisioning of persistent volumes.

Sometimes, especially during development, you have PVC attached to a pod, and you would like to inspect the PVC’s contents. This article presents a short snippet that let’s you inspect a PVC in Kubernetes without interfering with existing PODs.

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: pvc-inspector
spec:
  containers:
  - image: busybox
    name: pvc-inspector
    command: ["tail"]
    args: ["-f", "/dev/null"]
    volumeMounts:
    - mountPath: /pvc
      name: pvc-mount
  volumes:
  - name: pvc-mount
    persistentVolumeClaim:
      claimName: YOUR_CLAIM_NAME_HERE
EOF