Is there any way to connect to a volume attached to a Kubernetes cluster and explore the content inside it.
Asked
Active
Viewed 80 times
1 Answers
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
-
Thanks @erstaples – anXler Mar 12 '20 at 17:54