在我的 POD 中,我想将所有容器限制为具有
securityContext: readOnlyRootFilesystem: true
示例的只读文件系统(注意:为简洁起见,yaml 已减少)
apiVersion: v1
kind: Pod
metadata:
labels:
run: server123
name: server123
spec:
securityContext:
readOnlyRootFilesystem: true
containers:
- image: server1-image
name: server1
- image: server2-image
name: server2
- image: server3-image
name: server3
这将导致:
错误:验证“server123.yaml”时出错:验证数据时出错:ValidationError(Pod.spec.securityContext):io.k8s.api.core.v1.PodSecurityContext中的未知字段“readOnlyRootFilesystem”;如果您选择忽略这些错误,请使用 --validate=false 关闭验证
相反,我必须配置为:
apiVersion: v1
kind: Pod
metadata:
labels:
run: server123
name: server123
spec:
containers:
- image: server1-image
name: server1
securityContext:
readOnlyRootFilesystem: true
- image: server2-image
name: server2
securityContext:
readOnlyRootFilesystem: true
- image: server3-image
name: server3
securityContext:
readOnlyRootFilesystem: true
有没有办法为所有容器设置一次这个安全限制?如果不是为什么不呢?