anXler
anXler

Reputation: 317

Explore Azure Kubernetes Volume Content

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

Upvotes: 1

Views: 261

Answers (1)

erstaples
erstaples

Reputation: 2076

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

Upvotes: 2

Related Questions