diff --git a/content/zh-cn/docs/concepts/security/pod-security-standards.md b/content/zh-cn/docs/concepts/security/pod-security-standards.md index 1aafe77bf2..243bd9529c 100644 --- a/content/zh-cn/docs/concepts/security/pod-security-standards.md +++ b/content/zh-cn/docs/concepts/security/pod-security-standards.md @@ -21,17 +21,18 @@ weight: 10 The Pod Security Standards define three different _policies_ to broadly cover the security spectrum. These policies are _cumulative_ and range from highly-permissive to highly-restrictive. This guide outlines the requirements of each policy. +--> +Pod 安全性标准定义了三种不同的 **策略(Policy)**,以广泛覆盖安全应用场景。 +这些策略是 **叠加式的(Cumulative)**,安全级别从高度宽松至高度受限。 +本指南概述了每个策略的要求。 + -Pod 安全性标准定义了三种不同的 _策略(Policy)_,以广泛覆盖安全应用场景。 -这些策略是 _渐进式的(Cumulative)_,安全级别从高度宽松至高度受限。 -本指南概述了每个策略的要求。 - | Profile | 描述 | | ------ | ----------- | | Privileged | 不受限制的策略,提供最大可能范围的权限许可。此策略允许已知的特权提升。 | @@ -97,151 +98,74 @@ fail validation.
限制的字段
spec.securityContext.windowsOptions.hostProcess
spec.containers[*].securityContext.windowsOptions.hostProcess
spec.initContainers[*].securityContext.windowsOptions.hostProcess
spec.ephemeralContainers[*].securityContext.windowsOptions.hostProcess
Allowed Values
+准许的取值
false
Windows Pod 提供了运行 - HostProcess 容器 的能力, - 这使得对 Windows 节点的特权访问成为可能。 - 基线策略中对宿主的特权访问是被禁止的。 - HostProcess Pod 是 Kubernetes v1.22 版本的 - alpha 特性。
-限制的字段
-spec.securityContext.windowsOptions.hostProcess
spec.containers[*].securityContext.windowsOptions.hostProcess
spec.initContainers[*].securityContext.windowsOptions.hostProcess
spec.ephemeralContainers[*].securityContext.windowsOptions.hostProcess
允许的值
-false
必须禁止共享宿主上的名字空间。
+限制的字段
spec.hostNetwork
spec.hostPID
spec.hostIPC
Allowed Values
+准许的取值
false
必须禁止共享宿主名字空间。
-限制的字段
-spec.hostNetwork
spec.hostPID
spec.hostIPC
允许的值
-false
特权 Pod 关闭了大多数安全性机制,必须被禁止。
-限制的字段
+特权 Pod 会使大多数安全性机制失效,必须被禁止。
+限制的字段
spec.containers[*].securityContext.privileged
spec.initContainers[*].securityContext.privileged
spec.ephemeralContainers[*].securityContext.privileged
允许的值
+准许的取值
false
必须禁止添加除下列字段之外的权能。
-限制的字段
+必须禁止添加除下列字段之外的权能。
+限制的字段
spec.containers[*].securityContext.capabilities.add
spec.initContainers[*].securityContext.capabilities.add
spec.ephemeralContainers[*].securityContext.capabilities.add
允许的值
+准许的取值
AUDIT_WRITE
CHOWN
DAC_OVERRIDE
必须禁止 HostPath 卷。
-限制的字段
+必须禁止 HostPath 卷。
+限制的字段
spec.volumes[*].hostPath
允许的值
+准许的取值
应该禁止使用宿主端口,或者至少限制只能使用某确定列表中的端口。
+限制的字段
spec.containers[*].ports[*].hostPort
spec.initContainers[*].ports[*].hostPort
spec.ephemeralContainers[*].ports[*].hostPort
Allowed Values
+准许的取值
0
应禁止使用宿主端口,或者至少限定为已知列表。
-限制的字段
-spec.containers[*].ports[*].hostPort
spec.initContainers[*].ports[*].hostPort
spec.ephemeralContainers[*].ports[*].hostPort
允许的值
-0
在受支持的主机上,默认使用 runtime/default
AppArmor Profile。
- 基线策略应避免覆盖或者禁用默认策略,以及限制覆盖一些 Profile 集合的权限。
限制的字段
+在受支持的主机上,默认使用 runtime/default
AppArmor 配置。Baseline 策略应避免覆盖或者禁用默认策略,以及限制覆盖一些配置集合的权限。
限制的字段
metadata.annotations["container.apparmor.security.beta.kubernetes.io/*"]
允许的值
+准许的取值
runtime/default
localhost/*
设置 SELinux 类型的操作是被限制的,设置自定义的 SELinux 用户或角色选项是被禁止的。
-限制的字段
+设置 SELinux 类型的操作是被限制的,设置自定义的 SELinux 用户或角色选项是被禁止的。
+限制的字段
spec.securityContext.seLinuxOptions.type
spec.containers[*].securityContext.seLinuxOptions.type
spec.initContainers[*].securityContext.seLinuxOptions.type
spec.ephemeralContainers[*].securityContext.seLinuxOptions.type
允许的值
+准许的取值
container_t
container_init_t
container_kvm_t
限制的字段
+限制的字段
spec.securityContext.seLinuxOptions.user
spec.containers[*].securityContext.seLinuxOptions.user
spec.initContainers[*].securityContext.seLinuxOptions.role
spec.ephemeralContainers[*].securityContext.seLinuxOptions.role
允许的值
+准许的取值
/proc
挂载类型/proc
挂载类型要求使用默认的 /proc
掩码以减小攻击面。
限制的字段
+要求使用默认的 /proc
掩码以减小攻击面。
限制的字段
spec.containers[*].securityContext.procMount
spec.initContainers[*].securityContext.procMount
spec.ephemeralContainers[*].securityContext.procMount
允许的值
+准许的取值
Default
Unconfined
。
+ 限制的字段
spec.securityContext.seccompProfile.type
spec.containers[*].securityContext.seccompProfile.type
spec.initContainers[*].securityContext.seccompProfile.type
spec.ephemeralContainers[*].securityContext.seccompProfile.type
Allowed Values
+准许的取值
RuntimeDefault
Localhost
Seccomp Profile 禁止被显式设置为 Unconfined
。
限制的字段
-spec.securityContext.seccompProfile.type
spec.containers[*].securityContext.seccompProfile.type
spec.initContainers[*].securityContext.seccompProfile.type
spec.ephemeralContainers[*].securityContext.seccompProfile.type
允许的值
-RuntimeDefault
Localhost
Sysctls 可以禁用安全机制或影响宿主上所有容器,因此除了若干“安全”的子集之外,应该被禁止。 - 如果某 sysctl 是受容器或 Pod 的名字空间限制,且与节点上其他 Pod 或进程相隔离,可认为是安全的。
-限制的字段
+Sysctls 可以禁用安全机制或影响宿主上所有容器,因此除了若干“安全”的子集之外,应该被禁止。如果某 sysctl 是受容器或 Pod 的名字空间限制,且与节点上其他 Pod 或进程相隔离,可认为是安全的。
+限制的字段
spec.securityContext.sysctls[*].name
允许的值
+准许的取值
kernel.shm_rmid_forced
net.ipv4.ip_local_port_range
net.ipv4.ip_unprivileged_port_start
控制(Control) | - -策略(Policy) | +控制 | +策略 |
基线策略的所有要求。 | +Baseline 策略的所有要求。 | ||
- In addition to restricting HostPath volumes, the restricted policy limits usage of non-core volume types to those defined through PersistentVolumes. -Restricted Fields +除了限制 HostPath 卷之外,此类策略还限制可以通过 PersistentVolumes 定义的非核心卷类型。 +限制的字段
Allowed Values - Every item in thespec.volumes[*] list must set one of the following fields to a non-null value:
-
| -->
- 卷类型 | -
- 除了限制 HostPath 卷之外,此类策略还限制可以通过 PersistentVolumes 定义的非核心卷类型。 -限制的字段 -
允许的值 -spec.volumes[*] 列表中的每个条目必须将下面字段之一设置为非空值:
+ 准许的取值 +spec.volumes[*] 列表中的每个条目必须将下面字段之一设置为非空值:
|
|
- Privilege escalation (such as via set-user-ID or set-group-ID file mode) should not be allowed. -Restricted Fields +禁止(通过 SetUID 或 SetGID 文件模式)获得特权提升。 +限制的字段
Allowed Values -
| -->
- 特权提升(v1.8+) | -
- 禁止(通过 SetUID 或 SetGID 文件模式)获得特权提升。 -- 限制的字段 -
允许的值 +允许的取值
|
|
以非 root 账号运行 | - 以非 root 账号运行 +
+ 容器必须以非 root 账号运行。 +限制的字段
Allowed Values +准许的取值
nil if the pod-level
- spec.securityContext.runAsNonRoot is set to true .
-
- | -->
-
- 必须要求容器以非 root 用户运行。 -限制的字段 -
允许的值 -
spec.securityContext.runAsNonRoot 设置为
- true ,则允许容器组的安全上下文字段设置为 未定义/nil 。
+ 如果 Pod 级别 spec.securityContext.runAsNonRoot 设置为 true ,则允许容器组的安全上下文字段设置为 未定义/nil 。
|
|
非 root 用户(v1.23+) | +非 root 用户(v1.23+) |
- 容器不可以将 runAsUser 设置为 0
+ 限制的字段
Allowed Values +准许的取值
| -->
- |
Seccomp (v1.19+) |
- Seccomp Profile 必须被显式设置成一个允许的值。禁止使用 Unconfined Profile 或者指定 不存在的 Profile。
+ 限制的字段
Allowed Values +准许的取值
nil if the pod-level
- spec.securityContext.seccompProfile.type field is set appropriately.
- Conversely, the pod-level field may be undefined/nil if _all_ container-
- level fields are set.
+ 如果 Pod 级别的 spec.securityContext.seccompProfile.type 已设置得当,容器级别的安全上下文字段可以为 未定义/nil 。反而言之,如果 nil 。
- | -->
- ||
权能(v1.22+) | - 权能(v1.22+) +
- Containers must drop Restricted Fields +限制的字段
Allowed Values +准许的取值
- Restricted Fields +限制的字段
Allowed Values +准许的取值
| -->
-
-
- 容器组必须弃用 限制的字段 -
允许的值 -
- 限制的字段 -
允许的值 -
|
@@ -833,12 +507,18 @@ of individual policies are not defined here.
随着相关机制的成熟,这些机制会按策略分别定义在下面。特定策略的实施方法不在这里定义。
+
[**Pod 安全性准入控制器**](/zh-cn/docs/concepts/security/pod-security-admission/)
- {{< example file="security/podsecurity-privileged.yaml" >}}Privileged 名字空间{{< /example >}}
- {{< example file="security/podsecurity-baseline.yaml" >}}Baseline 名字空间{{< /example >}}
- {{< example file="security/podsecurity-restricted.yaml" >}}Restricted 名字空间{{< /example >}}
+
[**PodSecurityPolicy**](/zh-cn/docs/concepts/security/pod-security-policy/) (已弃用)
- {{< example file="policy/privileged-psp.yaml" >}}Privileged{{< /example >}}
@@ -953,7 +633,7 @@ There is not currently an API standard that controls whether a Pod is considered
not. Sandbox Pods may be identified by the use of a sandboxed runtime (such as gVisor or Kata
Containers), but there is no standard definition of what a sandboxed runtime is.
-->
-### 沙箱(Sandboxed) Pod 怎么处理?
+### 沙箱(Sandboxed)Pod 怎么处理? {#what-about-sandboxed-pods}
现在还没有 API 标准来控制 Pod 是否被视作沙箱化 Pod。
沙箱 Pod 可以通过其是否使用沙箱化运行时(如 gVisor 或 Kata Container)来辨别,