Kubernetes - how to download a PersistentVolume's content

只愿长相守 提交于 2019-12-04 07:09:16

I can think about two options to fulfill your needs:

1) create a pod with the PV attached to it and use kubectl cp to copy the contents wherever you need. You could for example use a PodSpec similar the following:

apiVersion: v1
kind: Pod
metadata:
  name: dataaccess
spec:
  containers:
  - name: alpine
    image: alpine:latest
    command:
    - sleep
    - 999999
    volumeMounts:
    - name: mypvc
      mountPath: /data
  volumes:
  - name: mypvc
    persistentVolumeClaim:
      claimName: mypvc

Please note that mypvc should be the name of the PersistentVolumeClaim that is bound to the PV you want to copy data from.

Once the pod is running, you can run something like this to copy the data from any machine that has kubectl configured to connect to your cluster:

kubectl cp dataaccess:/data data/

2) mount the PV's EBS volume in an EC2 instance and copy the data from there. This case is less simple to explain in detail because it needs a little more context about what you're trying to achieve.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!