Ken*_* Ho 20 kubernetes kubectl
我知道你可以使用kubectl run创建一个带有Deployment/Job的pod.但是有可能创建一个附加了卷的卷吗?我试过运行这个命令:
kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1", "spec": {"containers": {"image": "ubuntu:14.04", "volumeMounts": {"mountPath": "/home/store", "name":"store"}}, "volumes":{"name":"store", "emptyDir":{}}}}' --image=ubuntu:14.04 --restart=Never -- bash
Run Code Online (Sandbox Code Playgroud)
但是音量不会出现在交互式bash中.
有没有更好的方法来创建一个可以附加到卷的pod?
Tim*_*air 28
您的JSON覆盖指定不正确.不幸的是,kubectl运行只是忽略了它不理解的字段.
kubectl run -i --rm --tty ubuntu --overrides='
{
"apiVersion": "batch/v1",
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "ubuntu",
"image": "ubuntu:14.04",
"args": [
"bash"
],
"stdin": true,
"stdinOnce": true,
"tty": true,
"volumeMounts": [{
"mountPath": "/home/store",
"name": "store"
}]
}
],
"volumes": [{
"name":"store",
"emptyDir":{}
}]
}
}
}
}
' --image=ubuntu:14.04 --restart=Never -- bash
Run Code Online (Sandbox Code Playgroud)
要调试此问题,我运行了您指定的命令,然后在另一个终端运行:
kubectl get job ubuntu -o json
Run Code Online (Sandbox Code Playgroud)
从那里你可以看到实际的作业结构与你的json覆盖不同(你缺少嵌套的模板/规范,而卷,volumeMounts和容器需要是数组).
| 归档时间: |
|
| 查看次数: |
11091 次 |
| 最近记录: |