Kubernetes - 如何下载 PersistentVolume 的内容 [英] Kubernetes - how to download a PersistentVolume's content

查看:16
本文介绍了Kubernetes - 如何下载 PersistentVolume 的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 K8s 集群中通过 helm 创建了一个测试执行器 Pod,它要求动态创建的 PersistentVolume 存储测试结果.

I have a test executor Pod in K8s cluster created through helm, which asks for a dynamically created PersistentVolume where it stores the test results.

现在我想获取本卷的内容.这似乎是很自然的事情.我希望有一些 kubectl 下载 pv .但我不能用谷歌搜索任何东西.

Now I would like to get the contents of this volume. It seems quite natural thing to do. I would expect some kubectl download pv <id>. But I can't google up anything.

如何获取PersistentVolume的内容?

How can I get the contents of a PersistentVolume?

我在 AWS EKS;所以 AWS API 也是一种选择.我也可以访问 ECR,所以也许我可以以某种方式将它存储为图像并下载?

I am in AWS EKS; so AWS API is also an option. Also I can access ECR so perhaps I could somehow store it as an image and download?

或者,一般来说,我正在寻找一种传输目录的方法,甚至可以在存档中.但它应该是容器完成并且不再运行之后.

Or, in general, I am looking for a way to transfer a directory, can be even in an archive. But It should be after the container finished and doesn't run anymore.

推荐答案

我可以考虑两个选项来满足您的需求:

I can think about two options to fulfil your needs:

  1. 创建一个附有 PV 的 pod,并使用 kubectl cp 将内容复制到您需要的任何位置.例如,您可以使用类似于以下内容的 PodSpec:
  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 to the following:

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

请注意,mypvc 应该是绑定到要从中复制数据的 PV 的 PersistentVolumeClaim 的名称.

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

一旦 Pod 运行,您可以运行如下所示的内容,从任何配置了 kubectl 以连接到您的集群的机器复制数据:

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

kubectl cp dataaccess:/data data/

  1. 在 EC2 实例中安装 PV 的 EBS 卷并从那里复制数据.这个案例不太容易详细解释,因为它需要更多关于您要实现的目标的上下文.

这篇关于Kubernetes - 如何下载 PersistentVolume 的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆