我想使用 kubectl
CLI 创建一个 pod,它将在 pod 容器内挂载主机路径 /etc/os-release
并显示 /etc/os 的内容-发布
文件。
是否可以使用一行 kubectl
命令来做到这一点?
最佳答案
kubectl run -i --rm busybox --image=busybox --overrides='{
"apiVersion": "v1",
"spec": {
"containers": [
{
"image": "busybox",
"name": "busybox",
"command": ["cat", "/etc/os-release"],
"resources": {},
"volumeMounts": [
{
"mountPath": "/etc/os-release",
"name": "release"
}
]
}
],
"volumes": [
{
"name": "release",
"hostPath": {
"path": "/etc/os-release",
"type": "File"
}
}
],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Never"
},
"status": {}
}'
NAME=Buildroot
VERSION=2019.02.10
ID=buildroot
VERSION_ID=2019.02.10
PRETTY_NAME="Buildroot 2019.02.10"
pod "busybox" deleted
关于kubernetes - 如何使用 "kubectl"CLI 在 pod 内挂载卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61803186/