@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"
}
}
]
}
}