简体   繁体   English

如何在 azure 云服务上通过 kubernetes 检查持久卷的内容

[英]how to inspect the content of persistent volume by kubernetes on azure cloud service

I have packed the software to a container.我已将软件打包到容器中。 I need to put the container to cluster by Azure Container Service.我需要通过 Azure 容器服务将容器放入集群。 The software have outputs of an directory /src/data/ , I want to access the content of the whole directory.该软件具有目录/src/data/ ,我想访问整个目录的内容。

After searching, I have to solution.搜索后,我必须解决。

  1. use Blob Storage on azure, but then after searching, I can't find the executable method.在 azure 上使用 Blob Storage,但是搜索之后,我找不到可执行方法。
  2. use Persistent Volume, but all the official documentation of azure and pages I found is about Persistent Volume itself, not about how to inspect it.使用 Persistent Volume,但是我找到的所有 azure 和 pages 的官方文档都是关于 Persistent Volume 本身,而不是关于如何检查它。

I need to access and manage my output directory on Azure cluster.我需要访问和管理 Azure 集群上的输出目录。 In other words, I need a savior.换句话说,我需要一个救世主。

As I've explained here , in general, if you can interact with the cluster using kubectl , you can create a pod/container, mount the PVC inside, and use the container's tools to, eg, ls the contents.正如我在这里解释的那样,通常,如果您可以使用kubectl与集群kubectl ,您可以创建一个 pod/容器,将 PVC 安装在里面,并使用容器的工具来,例如, ls的内容。 If you need more advanced editing tools, replace the container image busybox with a custom one.如果您需要更高级的编辑工具,请将容器图像busybox替换为自定义工具。

Create the inspector pod创建检查员窗格

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: pvc-inspector
spec:
  containers:
  - image: busybox
    name: pvc-inspector
    command: ["tail"]
    args: ["-f", "/dev/null"]
    volumeMounts:
    - mountPath: /pvc
      name: pvc-mount
  volumes:
  - name: pvc-mount
    persistentVolumeClaim:
      claimName: YOUR_CLAIM_NAME_HERE
EOF

Inspect the contents检查内容

kubectl exec -it pvc-inspector -- sh
$ ls /pvc

Clean Up清理

kubectl delete pod pvc-inspector

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM