1

Is there any way to connect to a volume attached to a Kubernetes cluster and explore the content inside it.

anXler
  • 175
  • 1
  • 1
  • 12

1 Answers1

2

First, create a PersistentVolumeClaim and Pod to mount the volume

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-claim
spec:
  accessModes:
    - ReadWriteOnce
  volumeName: <the-volume-that-you-want-to-explore>
  resources:
    requests:
      storage: 3Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: volume-inspector
spec:
  containers:
    - name: foo
      command: ["sleep","infinity"]
      image: ubuntu:latest
      volumeMounts:
      - mountPath: "/tmp/mount"
        name: data
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: my-claim
        readOnly: true

Then exec into the Pod and start exploring

$ kubectl exec -it volume-inspector bash
root@volume-inspector:/# ls /tmp/mount
erstaples
  • 1,986
  • 16
  • 31