【问题标题】:How to display the content of the volume?如何显示卷的内容?
【发布时间】:2019-04-19 17:43:57
【问题描述】:

如何显示openshift卷的内容? (其中的文件、使用的总空间等)。

我设法在 the docs 中找到的唯一信息是将 oc rsh 放入正在运行的 POD 并使用 ls,如果没有使用该卷的 Pod 正在运行并且可以'由于音量的一些问题而无法启动...

【问题讨论】:

  • 如果您的应用程序由于数据损坏而无法启动,请针对部署使用oc debug。这将为您提供安装了卷的 shell,但不会启动您的应用程序。

标签: openshift volume


【解决方案1】:

@Daein Park 提出的显示 PersistentVolume(PV/PVC 对) 内容的解决方案对我不起作用。命令 oc run tmp-pod 不会创建 dc deploymentConfig 并且似乎无法为 Pod 设置卷。

我的解决方案是使用以下命令:

oc run tmp-pod --image=dummy --restart=Never --overrides='{"spec":{"containers":[{"command":["tail","-f","/dev/null"],"image":"registry.access.redhat.com/rhel7","name":"tmp-pod","volumeMounts":[{"mountPath":"/mountpath","name":"volume"}]}],"volumes":[{"name":"volume","persistentVolumeClaim":{"claimName":"pv-clain"}}]}}'

NOTE2:--image=dummy 仅用于使oc run 命令满意,无论如何图像字段都会被 json 覆盖。

最后,列出挂载卷的内容:

oc rsh tmp-pod ls /mountpath

由于json内容在命令行中不易阅读,这里提供给--overrides参数:

{
"spec": {
    "containers": [{
            "command": ["tail", "-f", "/dev/null"],
            "image": "registry.access.redhat.com/rhel7",
            "name": "tmp-pod",
            "volumeMounts": [{
                    "mountPath": "/mountpath",
                    "name": "volume"
                }
            ]
        }
    ],
    "volumes": [{
            "name": "volume",
            "persistentVolumeClaim": {
                "claimName": "pv-clain"
            }
        }
    ]
}

}

【讨论】:

    【解决方案2】:

    目前,Openshift 中没有“卷文件资源管理器”或任何界面。 目前,您始终需要将卷附加到正在运行的 pod 并列出其中的文件。 如果您使用 glusterfs(并且是集群/存储管理员),所有卷也都安装在 storage pod 中,因此您可以在 storage pod 中获得完整的概览。

    【讨论】:

      【解决方案3】:

      我不知道这些方式是否适合你,但我只是将可用性列出如下。

      据我所知,如果pod可以基于docker image创建,那么你可以在不运行应用程序的情况下像这样运行。

      oc run tmp-pod --image=your-docker-registry.default.svc/yourapplication  -- tail -f /dev/null
      

      您正在为您的volume 使用PersistentVolume(PV/PVC 对),然后您可以在将PV 临时安装到临时吊舱后显示volume,如下所示。

      oc run tmp-pod --image=registry.access.redhat.com/rhel7  -- tail -f /dev/null
      oc set volume dc/tmp-pod --add -t pvc --name=new-registry --claim-name=new-registry --mount-path=/mountpath
      

      通过tmp-pod可以看到上面配置挂载的volume内容,检查后可以简单的移除上面的临时pod。

      希望对你有帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-11-17
        • 1970-01-01
        • 2016-01-21
        • 1970-01-01
        • 2021-01-26
        • 1970-01-01
        • 1970-01-01
        • 2015-05-11
        相关资源
        最近更新 更多