Kubernetes 如何在pod内使用“安装卷”;“kubectl”;CLI

Kubernetes 如何在pod内使用“安装卷”;“kubectl”;CLI,kubernetes,kubectl,kubernetes-pod,persistent-volumes,Kubernetes,Kubectl,Kubernetes Pod,Persistent Volumes,我想使用kubectlCLI创建一个pod,它将在pod容器中装载hostpath/etc/os release,并显示/etc/os release文件的内容。 是否可以使用一个linerkubectl命令执行此操作 kubectl run -i --rm busybox --image=busybox --overrides='{ "apiVersion": "v1", "spec": { "co

我想使用
kubectl
CLI创建一个pod,它将在pod容器中装载hostpath
/etc/os release
,并显示
/etc/os release
文件的内容。 是否可以使用一个liner
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