【问题标题】:how to inspect the content of persistent volume by kubernetes on azure cloud service如何通过 Kubernetes 在 Azure 云服务上检查持久卷的内容
【发布时间】:2018-09-06 19:32:13
【问题描述】:

我已将软件打包到一个容器中。我需要通过 Azure 容器服务将容器放入集群。该软件有一个目录/src/data/的输出,我想访问整个目录的内容。

搜索后,我必须解决。

  1. 在azure上使用Blob Storage,然后搜索后找不到可执行的方法。
  2. 使用 Persistent Volume,但我发现的所有 azure 和 pages 的官方文档都是关于 Persistent Volume 本身,而不是关于如何检查它。

我需要访问和管理 Azure 集群上的输出目录。换句话说,我需要一个救世主。

【问题讨论】:

  • 您需要救星吗?但是你holding out for a hero? PersistentVolume 在某种程度上是 pod 定义和存储介质之间的抽象层。您不检查 PV,而是检查底层存储介质。除非你的意思是kubectl describe persistentvolume NAME
  • This documentation 展示了如何使用 AzureFile 作为 PersistentVolume 的后备存储。
  • 我已经尝试过这个文档,但是我没有连接容器和 AzureFile。我现在再试一次。
  • 确保在 Azure 门户上使用该名称创建共享(转到存储帐户,单击“文件”,单击工具栏中的“+ 文件共享”)。
  • 示例here 可能有助于首先使用 AzureFile 卷类型进行访问。

标签: docker kubernetes containers azure-cloud-services


【解决方案1】:

正如我解释过的herehere,一般来说,如果您可以使用kubectl 与集群进行交互,您可以创建一个pod/容器,将PVC 挂载在里面,然后使用容器的工具来,例如ls 的内容。如果您需要更高级的编辑工具,请将容器镜像 busybox 替换为自定义镜像。

创建检查器 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

检查内容

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

清理

kubectl delete pod pvc-inspector

【讨论】:

    猜你喜欢
    • 2021-11-22
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    相关资源
    最近更新 更多