我似乎不能理解为什么如果我删除spec.containers.command,下面提到的pod清单不能工作,如果我删除命令,pod就会失败。
我从官方的documentation中取了这个例子
apiVersion: v1
kind: Pod
metadata:
name: security-context-demo
spec:
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000
volumes:
- name: sec-ctx-vol
emptyDir: {}
containers:
- name: sec-ctx-demo
image: busybox
command: [ "sh", "-c", "sleep 1h" ]
volumeMounts:
- name: sec-ctx-vol
mountPath: /data/demo
securityContext:
allowPrivilegeEscalation: false
发布于 2021-10-29 06:03:19
因为busybox
镜像在启动时不会单独运行任何进程。容器被设计为运行单个应用程序,并在应用程序退出时关闭。如果镜像没有运行任何东西,它将立即退出。在Kubernetes中,spec.containers.command
会覆盖默认的容器命令。您可以尝试更改清单镜像,即image: nginx
,删除spec.containers.command
,它将运行,因为该镜像作为默认的Nginx服务器。
https://stackoverflow.com/questions/69769769
复制