kubernetes - Kubernetes 安全上下文
问题描述
如果我删除 spec.containers.command,我似乎无法理解为什么下面提到的 pod 清单不起作用,如果我删除命令,pod 会失败。
我从官方文档中拿了这个例子
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
解决方案
因为busybox
图像本身在启动时不会运行任何进程。容器旨在运行单个应用程序并在应用程序退出时关闭。如果图像没有运行任何东西,它将立即退出。在 Kubernetes 中,spec.containers.command
覆盖默认容器命令。您可以尝试更改 ie 的清单图像image: nginx
,删除spec.containers.command
它并且它将运行,因为该图像作为默认 Nginx 服务器。
推荐阅读
- javascript - 如何在javascript中将两个方法一起添加
- python - 学位折扣启发式程序
- gitlab-ci-runner - 在程序集路径中使用通配符执行 MSpec 控制台运行程序
- hsl - 如何在 HSL 中计算亮度
- java - 谷歌云存储 Java 客户端池
- python - 如何更改列表中的字母,然后检查该单词在文本文件中是否有效?
- cordova - 应用程序在 2019 年 8 月 1 日之前准备好满足 64 位要求
- html - “ng serve --aot”在监视的 Angular 库中未检测到 Html 更改
- javascript - 将数组和其他参数传递给函数。如何?
- ios - React Native White screen with any crash or error iOS