确保容器在运行时的不可变性
翻译
原文:https://devopscube.com/cks-exam-guide-tips/#ensure-immutability-of-containers-at-runtime
- name: 翻译
desc: 原文:https://devopscube.com/cks-exam-guide-tips/#ensure-immutability-of-containers-at-runtime
bgColor: '#F0DFB1'
textColor: 'green'
1
2
3
4
2
3
4
# 确保容器在运行时的不可变性
您可以通过将 Pod 使用的所有内容设置为只读(ReadOnly)来使 Pod 不可变。例如,只读文件系统、configmap 和 secrets。
不可变文件系统 | PSP readOnlyRootFilesystem (opens new window) |
注意
PodSecurityPolicy(PSP) 在 Kubernetes v1.21 中被弃用 (opens new window), 在 Kubernetes v1.25 中被移除。
译者加
你可以使用 Pod 容器安全上下文的字段spec.containers.securityContext.readOnlyRootFilesystem
来设置只读根文件系统。
spec:
containers:
- ...
securityContext:
readOnlyRootFilesystem: true
1
2
3
4
5
2
3
4
5
编辑 (opens new window)