From 7933d10e52f45ed2fee1c07ba6744ce5aebf654c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jul 2022 21:14:33 +0800 Subject: [PATCH] [zh-cn] resync pod-security-policy-v1beta1.md --- .../pod-security-policy-v1beta1.md | 1091 +++++++++++++++++ 1 file changed, 1091 insertions(+) create mode 100644 content/zh-cn/docs/reference/kubernetes-api/policy-resources/pod-security-policy-v1beta1.md diff --git a/content/zh-cn/docs/reference/kubernetes-api/policy-resources/pod-security-policy-v1beta1.md b/content/zh-cn/docs/reference/kubernetes-api/policy-resources/pod-security-policy-v1beta1.md new file mode 100644 index 0000000000..5817459bc2 --- /dev/null +++ b/content/zh-cn/docs/reference/kubernetes-api/policy-resources/pod-security-policy-v1beta1.md @@ -0,0 +1,1091 @@ +--- +api_metadata: + apiVersion: "policy/v1beta1" + import: "k8s.io/api/policy/v1beta1" + kind: "PodSecurityPolicy" +content_type: "api_reference" +description: "PodSecurityPolicy 对影响到安全上下文的请求能力进行治理,而安全上下文可以应用到 Pod 和容器上。" +title: "PodSecurityPolicy v1beta1" +weight: 5 +--- + + +`apiVersion: policy/v1beta1` + +`import "k8s.io/api/policy/v1beta1"` + +## PodSecurityPolicy {#PodSecurityPolicy} + + +PodSecurityPolicy 对影响到安全上下文的请求能力进行治理,而安全上下文可以应用到 Pod 和容器上。 +在 1.21 中已被弃用。 + +
+ +- **apiVersion**: policy/v1beta1 + +- **kind**: PodSecurityPolicy + + +- **metadata** (}}">ObjectMeta) + + 标准的对象元数据。更多信息: + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + +- **spec** (}}">PodSecurityPolicySpec) + + spec 定义强制执行的策略。 + +## PodSecurityPolicySpec {#PodSecurityPolicySpec} + + +PodSecurityPolicySpec 定义强制执行的策略。 + +
+ + +- **runAsUser** (RunAsUserStrategyOptions),必需 + + runAsUser 是一种策略,它将规定允许为 runAsUser 设置的值。 + + + **RunAsUserStrategyOptions 定义策略类型和用于创建该策略的任意选项。** + + + + - **runAsUser.rule** (string),必需 + + rule 是一种策略,它将规定允许为 runAsUser 设置的值。 + + - **runAsUser.ranges** ([]IDRange) + + ranges 是可以使用的 UID 的允许范围。 + 如果你要强制使用某个确定 UID,则应提供起点值和终点值相同的范围设定。 + 对于 mustRunAs 而言是必需的。 + + + **IDRange 提供了 ID 的最小/最大允许范围。** + + + + - **runAsUser.ranges.max** (int64),必需 + + max 是范围的终点,该值包含在此范围内。 + + - **runAsUser.ranges.min** (int64),必需 + + min 是范围的起点,该值包含在此范围内。 + + +- **runAsGroup** (RunAsGroupStrategyOptions) + + runAsGroup 是一种策略,它将规定可以为 runAsGroup 设置的值。 + 如果省略此字段,则 Pod 的 runAsGroup 可以取任何值。 + 此字段要求启用 `RunAsGroup` 特性门控。 + + + **RunAsGroupStrategyOptions 定义策略类型和用于创建该策略的任意选项。** + + + + - **runAsGroup.rule** (string),必需 + + rule 是一种策略,它将规定可以为 runAsGroup 设置的值。 + + - **runAsGroup.ranges** ([]IDRange) + + ranges 是可以使用的 GID 的范围。 + 如果你要强制使用某个确定的 GID,则可提供起点和终点相同的范围设定。 + 对于 mustRunAs 而言是必需的。 + + + **IDRange 提供了 ID 的最小/最大允许范围。** + + + + - **runAsGroup.ranges.max** (int64),必需 + + max 是范围的终点,该值包含在此范围内。 + + - **runAsGroup.ranges.min** (int64),必需 + + min 是范围的起点,该值包含在此范围内。 + + +- **fsGroup** (FSGroupStrategyOptions),必需 + + fsGroup 是一种策略,它将规定 SecurityContext 将使用哪个 fs 组。 + + + **FSGroupStrategyOptions 定义策略类型和用于创建该策略的任意选项。** + + + + - **fsGroup.ranges** ([]IDRange) + + ranges 是 fs 组的允许范围。 + 如果你要强制使用某个确定的 fs 组,则应提供起点和终点相同的范围设定。 + 对于 mustRunAs 而言是必需的。 + + + **IDRange 提供了 ID 的最小/最大允许范围。** + + + + - **fsGroup.ranges.max** (int64),必需 + + max 是范围的终点,该值包含在此范围内。 + + - **fsGroup.ranges.min** (int64),必需 + + min 是范围的起点,该值包含在此范围内。 + + + + - **fsGroup.rule** (string) + + rule 是一种策略,它将规定 SecurityContext 中使用哪个 FSGroup。 + + +- **supplementalGroups** (SupplementalGroupsStrategyOptions),必需 + + supplementalGroups 是一种策略,它将规定 SecurityContext 将使用哪个补充组。 + + + **SupplementalGroupsStrategyOptions 定义策略类型和用于创建该策略的任意选项。** + + + + - **supplementalGroups.ranges** ([]IDRange) + + ranges 是补充组的允许范围。 + 如果你要强制使用固定的某个补充组,则应提供起点和终点相同的范围设定。 + 对于 mustRunAs 而言是必需的。 + + + **IDRange 提供了 ID 的最小/最大允许范围。** + + + + - **supplementalGroups.ranges.max** (int64),必需 + + max 是范围的终点,该值包含在此范围内。 + + - **supplementalGroups.ranges.min** (int64),必需 + + min 是范围的起点,该值包含在此范围内。 + + + + - **supplementalGroups.rule** (string) + + rule 是一种策略,它将规定 SecurityContext 中使用哪个补充组。 + + +- **seLinux** (SELinuxStrategyOptions),必需 + + seLinux 是一种策略,它将规定可以设置的标签集合。 + + + **SELinuxStrategyOptions 定义策略类型和用于创建该策略的任意选项。** + + + + - **seLinux.rule** (string),必需 + + rule 是一种策略,它将规定可以设置的标签集合。 + + - **seLinux.seLinuxOptions** (SELinuxOptions) + + seLinuxOptions 是运行所必需的。对于 mustRunAs 而言是必需的。更多信息: + https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/ + + + **SELinuxOptions 是应用到容器的标签。** + + + + - **seLinux.seLinuxOptions.level** (string) + + level 是应用到容器的 SELinux 级别标签。 + + - **seLinux.seLinuxOptions.role** (string) + + role 是应用到容器的 SELinux 角色标签。 + + - **seLinux.seLinuxOptions.type** (string) + + type 是应用到容器的 SELinux 类型标签。 + + - **seLinux.seLinuxOptions.user** (string) + + user 是应用到容器的 SELinux 用户标签。 + + +- **readOnlyRootFilesystem** (boolean) + + readOnlyRootFilesystem 设为 true 时将强制容器使用只读根文件系统来运行。 + 如果容器明确请求以非只读根文件系统来运行,则 PSP 应拒绝该 Pod。 + 如果设置为 false,则如果愿意,容器可以以只读根文件系统来运行,但不是必须使用只读根文件系统。 + +- **privileged** (boolean) + + privileged 决定 Pod 是否可以请求以特权模式运行。 + + +- **allowPrivilegeEscalation** (boolean) + + allowPrivilegeEscalation 决定 Pod 是否可以请求允许提升特权。如果未指定,则默认为 true。 + +- **defaultAllowPrivilegeEscalation** (boolean) + + defaultAllowPrivilegeEscalation 控制一个进程是否可以获得比其父进程更多权限的默认设置。 + + +- **allowedCSIDrivers** ([]AllowedCSIDriver) + + allowedCSIDrivers 是允许使用的内联 CSI 驱动列表,这些驱动必须被显式嵌入到 Pod 规约中。 + 空值表示任何 CSI 驱动都可以用于内联临时卷。这是一个 beta 字段, + 只有 API 服务器启用 CSIInlineVolume 特性门控,才会使用此字段。 + + + **AllowedCSIDriver 表示允许使用的单个内联 CSI 驱动。** + + + + - **allowedCSIDrivers.name** (string),必需 + + name 是 CSI 驱动的注册名称。 + + +- **allowedCapabilities** ([]string) + + allowedCapabilities 是可以请求添加到容器的权能列表。 + 这个字段中的权能可以由 Pod 作者自行添加。 + 你不得同时在 allowedCapabilities 和 requiredDropCapabilities 中列出同一个权能。 + +- **requiredDropCapabilities** ([]string) + + requiredDropCapabilities 是将从容器中丢弃的权能。这些权能需要被丢弃,且不能添加。 + + +- **defaultAddCapabilities** ([]string) + + defaultAddCapabilities 是默认被添加到容器的权能集,除非 Pod 规约特意丢弃该权能。 + 你不可以同时在 defaultAddCapabilities 和 requiredDropCapabilities 中列出同一个权能。 + 此处添加的权能是被隐式允许的,不必包括在 allowedCapabilities 列表中。 + + +- **allowedFlexVolumes** ([]AllowedFlexVolume) + + allowedFlexVolumes 是允许设置的 FlexVolume 卷的列表。 + 空或 nil 值表示可以使用所有 FlexVolume。 + 只有在 “volumes” 字段中允许使用 Flexvolume 卷时,此参数才有效。 + + + **AllowedFlexVolume 表示允许使用的单个 Flexvolume。** + + + + - **allowedFlexVolumes.driver** (string),必需 + + driver 是 FlexVolume 驱动的名称。 + + +- **allowedHostPaths** ([]AllowedHostPath) + + allowedHostPaths 是允许使用的主机路径的列表。空表示可以使用所有主机路径。 + + + **allowedHostPath 定义将按 Pod 使用的策略启用的主机卷条件。它要求定义路径前缀。** + + + + - **allowedHostPaths.pathPrefix** (string) + + pathPrefix 是主机卷必须匹配的路径前缀。 + 此字段不支持 `*`。使用主机路径检验路径前缀时,会裁剪掉尾部的斜线。 + + 例如:`/foo` 将允许 `/foo`、`/foo/` 和 `/foo/bar`。 + `/foo` 将不允许 `/food` 或 `/etc/foo`。 + + + + - **allowedHostPaths.readOnly** (boolean) + + 当设置为 true 时,仅当所有与 pathPrefix 匹配的主机卷的卷挂载均为 readOnly 时,才允许使用。 + + +- **allowedProcMountTypes** ([]string) + + AllowedProcMountTypes 是允许使用的 ProcMountType 的列表。 + 空表或 nil 表示仅可以使用 DefaultProcMountType。 + 此字段要求启用 ProcMountType 特性门控。 + + +- **allowedUnsafeSysctls** ([]string) + + allowedUnsafeSysctls 是明确允许的不安全 sysctl 的列表,默认为空。 + 每个条目要么是一个普通的 sysctl 名称,要么以 “*” 结尾, + 在后面这种情况下字符串值被视为所允许的 sysctl 的前缀。 + 单个 `*` 意味着允许所有不安全的 sysctl。 + Kubelet 必须显式列出所有被允许的、不安全的 sysctl,以防被拒绝。 + + 例如 `foo/*` 允许 `foo/bar`、`foo/baz` 等。 + 例如 `foo.*` 允许 `foo.bar`、`foo.baz` 等。 + + +- **forbiddenSysctls** ([]string) + + forbiddenSysctls 是被明确禁止的 sysctl 的列表,默认为空。 + 每个条目要么是一个普通的 sysctl 名称,要么以 `*` 结尾, + 以 `*` 结尾的字符串值表示被禁止的 sysctl 的前缀。 + 单个 `*` 意味着禁止所有 sysctl。 + + 例如 `foo/*` 禁止 `foo/bar`、`foo/baz` 等。 + 例如 `foo.*` 禁止 `foo.bar`、`foo.baz` 等。 + + +- **hostIPC** (boolean) + + hostIPC 决定此策略是否允许在 Pod 规约中使用 hostIPC。 + +- **hostNetwork** (boolean) + + hostNetwork 决定此策略是否允许在 Pod 规约中使用 hostNetwork。 + +- **hostPID** (boolean) + + hostPID 决定此策略是否允许在 Pod 规约中使用 hostPID。 + + +- **hostPorts** ([]HostPortRange) + + hostPorts 决定允许暴露哪些主机端口范围。 + + + **HostPortRange 定义将按 Pod 使用的策略启用的主机端口范围。它要求同时定义起点和终点。** + + + + - **hostPorts.max** (int32),必需 + + max 是范围的终点,该值包含在此范围内。 + + - **hostPorts.min** (int32),必需 + + min 是范围的起点,该值包含在此范围内。 + + +- **runtimeClass** (RuntimeClassStrategyOptions) + + runtimeClass 是一种策略,它将规定 Pod 所被允许的 RuntimeClass。 + 如果省略此字段,则 Pod 的 runtimeClassName 将不受限制。 + 该字段的实施取决于被启用的 RuntimeClass 特性门控。 + + + **RuntimeClassStrategyOptions 定义一种策略,它将规定 Pod 所被允许的 RuntimeClass。** + + + + - **runtimeClass.allowedRuntimeClassNames** ([]string),必需 + + allowedRuntimeClassNames 是可以在 Pod 中指定的 runtimeClass 名称的列表。 + `*` 值意味着允许任何 runtimeClass 值,并且如果设置了 `*`,则它必须是唯一的列表项。 + 空列表要求不能设置 runtimeClassName 字段。 + + - **runtimeClass.defaultRuntimeClassName** (string) + + defaultRuntimeClassName 是要在 Pod 中设置的默认 runtimeClassName。 + 该默认值必须被 allowedRuntimeClassNames 列表所允许。nil 值不会改变 Pod 设置。 + + +- **volumes** ([]string) + + volumes 是所允许的卷插件的列表。空的列表意味着不可以使用卷。要允许所有卷,你可以使用 `*`。 + +## PodSecurityPolicyList {#PodSecurityPolicyList} + + +PodSecurityPolicyList 是 PodSecurityPolicy 对象的列表。 + +
+ +- **apiVersion**: policy/v1beta1 + +- **kind**: PodSecurityPolicyList + + +- **metadata** (}}">ListMeta) + + 标准的列表元数据。更多信息: + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + +- **items** ([]}}">PodSecurityPolicy),必需 + + items 是 PodSecurityPolicy 对象的列表。 + + +## 操作 {#Operations} + +
+ +### `get` 读取指定的 PodSecurityPolicy + +#### HTTP 请求 + +GET /apis/policy/v1beta1/podsecuritypolicies/{name} + + +#### 参数 + +- **name** (**路径参数**): string,必需 + + PodSecurityPolicy 的名称 + +- **pretty** (**查询参数**): string + + }}">pretty + + +#### 响应 + +200 (}}">PodSecurityPolicy): OK + +401: Unauthorized + + +### `list` 列出或监视 PodSecurityPolicy 类别的对象 + +#### HTTP 请求 + +GET /apis/policy/v1beta1/podsecuritypolicies + + +#### 参数 + +- **allowWatchBookmarks** (**查询参数**): boolean + + }}">allowWatchBookmarks + +- **continue** (**查询参数**): string + + }}">continue + +- **fieldSelector** (**查询参数**): string + + }}">fieldSelector + +- **labelSelector** (**查询参数**): string + + }}">labelSelector + +- **limit** (**查询参数**): integer + + }}">limit + +- **pretty** (**查询参数**): string + + }}">pretty + +- **resourceVersion** (**查询参数**): string + + }}">resourceVersion + +- **resourceVersionMatch** (**查询参数**): string + + }}">resourceVersionMatch + +- **timeoutSeconds** (**查询参数**): integer + + }}">timeoutSeconds + +- **watch** (**查询参数**): boolean + + }}">watch + + +#### 响应 + +200 (}}">PodSecurityPolicyList): OK + +401: Unauthorized + + +### `create` 创建 PodSecurityPolicy + +#### HTTP 请求 + +POST /apis/policy/v1beta1/podsecuritypolicies + + +#### 参数 + +- **body**: }}">PodSecurityPolicy,必需 + +- **dryRun** (**查询参数**): string + + }}">dryRun + +- **fieldManager** (**查询参数**): string + + }}">fieldManager + +- **fieldValidation** (**查询参数**): string + + }}">fieldValidation + +- **pretty** (**查询参数**): string + + }}">pretty + + +#### 响应 + +200 (}}">PodSecurityPolicy): OK + +201 (}}">PodSecurityPolicy): Created + +202 (}}">PodSecurityPolicy): Accepted + +401: Unauthorized + + +### `update` 替换指定的 PodSecurityPolicy + +#### HTTP 请求 + +PUT /apis/policy/v1beta1/podsecuritypolicies/{name} + + +#### 参数 + +- **name** (**路径参数**): string,必需 + + PodSecurityPolicy 的名称 + +- **body**: }}">PodSecurityPolicy,必需 + +- **dryRun** (**查询参数**): string + + }}">dryRun + +- **fieldManager** (**查询参数**): string + + }}">fieldManager + +- **fieldValidation** (**查询参数**): string + + }}">fieldValidation + +- **pretty** (**查询参数**): string + + }}">pretty + + +#### 响应 + +200 (}}">PodSecurityPolicy): OK + +201 (}}">PodSecurityPolicy): Created + +401: Unauthorized + + +### `patch` 部分更新指定的 PodSecurityPolicy + +#### HTTP 请求 + +PATCH /apis/policy/v1beta1/podsecuritypolicies/{name} + + +#### 参数 + +- **name** (**路径参数**): string,必需 + + PodSecurityPolicy 的名称 + +- **body**: }}">Patch,必需 + +- **dryRun** (**查询参数**): string + + }}">dryRun + +- **fieldManager** (**查询参数**): string + + }}">fieldManager + +- **fieldValidation** (**查询参数**): string + + }}">fieldValidation + +- **force** (**查询参数**): boolean + + }}">force + +- **pretty** (**查询参数**): string + + }}">pretty + + +#### 响应 + +200 (}}">PodSecurityPolicy): OK + +201 (}}">PodSecurityPolicy): Created + +401: Unauthorized + + +### `delete` 删除 PodSecurityPolicy + +#### HTTP 请求 + +DELETE /apis/policy/v1beta1/podsecuritypolicies/{name} + + +#### 参数 + +- **name** (**路径参数**): string,必需 + + PodSecurityPolicy 的名称 + +- **body**: }}">DeleteOptions + +- **dryRun** (**查询参数**): string + + }}">dryRun + +- **gracePeriodSeconds** (**查询参数**): integer + + }}">gracePeriodSeconds + +- **pretty** (**查询参数**): string + + }}">pretty + +- **propagationPolicy** (**查询参数**): string + + }}">propagationPolicy + + +#### 响应 + +200 (}}">PodSecurityPolicy): OK + +202 (}}">PodSecurityPolicy): Accepted + +401: Unauthorized + + +### `deletecollection` 删除 PodSecurityPolicy 的集合 + +#### HTTP 请求 + +DELETE /apis/policy/v1beta1/podsecuritypolicies + + +#### 参数 + +- **body**: }}">DeleteOptions + +- **continue** (**查询参数**): string + + }}">continue + +- **dryRun** (**查询参数**): string + + }}">dryRun + +- **fieldSelector** (**查询参数**): string + + }}">fieldSelector + +- **gracePeriodSeconds** (**查询参数**): integer + + }}">gracePeriodSeconds + +- **labelSelector** (**查询参数**): string + + }}">labelSelector + +- **limit** (**查询参数**): integer + + }}">limit + +- **pretty** (**查询参数**): string + + }}">pretty + +- **propagationPolicy** (**查询参数**): string + + }}">propagationPolicy + +- **resourceVersion** (**查询参数**): string + + }}">resourceVersion + +- **resourceVersionMatch** (**查询参数**): string + + }}">resourceVersionMatch + +- **timeoutSeconds** (**查询参数**): integer + + }}">timeoutSeconds + + +#### 响应 + +200 (}}">Status): OK + +401: Unauthorized