|
| 1 | +--- |
| 2 | +title: 从 PodSecurityPolicy 迁移到内置的 PodSecurity 准入控制器 |
| 3 | +content_type: task |
| 4 | +min-kubernetes-server-version: v1.22 |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- |
| 8 | +title: Migrate from PodSecurityPolicy to the Built-In PodSecurity Admission Controller |
| 9 | +reviewers: |
| 10 | +- tallclair |
| 11 | +- liggitt |
| 12 | +content_type: task |
| 13 | +min-kubernetes-server-version: v1.22 |
| 14 | +--> |
| 15 | + |
| 16 | +<!-- overview --> |
| 17 | + |
| 18 | +<!-- |
| 19 | +This page describes the process of migrating from PodSecurityPolicies to the built-in PodSecurity |
| 20 | +admission controller. This can be done effectively using a combination of dry-run and `audit` and |
| 21 | +`warn` modes, although this becomes harder if mutating PSPs are used. |
| 22 | +--> |
| 23 | +本页面描述从 PodSecurityPolicy 迁移到内置的 PodSecurity 准入控制器的过程。 |
| 24 | +这一迁移过程可以通过综合使用试运行、`audit` 和 `warn` 模式等来实现, |
| 25 | +尽管在使用了变更式 PSP 时会变得有些困难。 |
| 26 | + |
| 27 | +## {{% heading "prerequisites" %}} |
| 28 | + |
| 29 | +{{% version-check %}} |
| 30 | + |
| 31 | +<!-- |
| 32 | +- Ensure the `PodSecurity` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/#feature-gates-for-alpha-or-beta-features) is enabled. |
| 33 | +--> |
| 34 | +- 确保 `PodSecurity` [特性门控](/docs/reference/command-line-tools-reference/feature-gates/)被启用。 |
| 35 | + |
| 36 | +<!-- body --> |
| 37 | + |
| 38 | +<!-- |
| 39 | +## Steps |
| 40 | +--> |
| 41 | +## 步骤 {#steps} |
| 42 | + |
| 43 | +<!-- |
| 44 | +- **Eliminate mutating PodSecurityPolicies, if your cluster has any set up.** |
| 45 | + - Clone all mutating PSPs into a non-mutating version. |
| 46 | + - Update all ClusterRoles authorizing use of those mutating PSPs to also authorize use of the |
| 47 | + non-mutating variant. |
| 48 | + - Watch for Pods using the mutating PSPs and work with code owners to migrate to valid, |
| 49 | + non-mutating resources. |
| 50 | + - Delete mutating PSPs. |
| 51 | +--> |
| 52 | +-- **如果你的集群中配置了变更式的 PodSecurityPolicy,将它们删除。** |
| 53 | + - 复制所有变更式 PSP 复制到非变更式版本中。 |
| 54 | + - 更新所有授权使用那些变更式 PSP 的 ClusterRole,使之也能为非变更式版本鉴权。 |
| 55 | + - 检视使用了变更式 PSP 的 Pod,与拥有该代码的人一起将其迁移到合法的、非变更式的资源。 |
| 56 | + - 删除变更式 PSP。 |
| 57 | + |
| 58 | +<!-- |
| 59 | +- **Select a compatible policy level for each namespace.** Analyze existing resources in the |
| 60 | + namespace to drive this decision. |
| 61 | + - Review the requirements of the different [Pod Security Standards](/docs/concepts/security/pod-security-standards). |
| 62 | + - Evaluate the difference in privileges that would come from disabling the PSP controller. |
| 63 | + - In the event that a PodSecurityPolicy falls between two levels, consider: |
| 64 | + - Selecting a _less_ permissive PodSecurity level prioritizes security, and may require adjusting |
| 65 | + workloads to fit within the stricter policy. |
| 66 | + - Selecting a _more_ permissive PodSecurity level prioritizes avoiding disrupting or |
| 67 | + changing workloads, but may allow workload authors in the namespace greater permissions |
| 68 | + than desired. |
| 69 | +--> |
| 70 | +- **为每个名字空间选择一个兼容的策略级别。** |
| 71 | + 要分析名字空间中已有的资源才能作出此决定。 |
| 72 | + - 审阅不同 [Pod 安全标准](/zh/docs/concepts/security/pod-security-standards)的需求。 |
| 73 | + - 评估禁用 PSP 控制器所带来的特权级变化。 |
| 74 | + - 当 PodSecurityPolicy 中的设置介于两种策略级别之间时,考虑: |
| 75 | + - 选择一个安全许可*略弱*的 PodSecurity 级别,可能需要调整负载本身, |
| 76 | + 使之能够在较严格的策略下工作。 |
| 77 | + - 选择一个安全许可*略强*的 PodSecurity 级别,从而避免干扰或变更负载本身。 |
| 78 | + 不过这样做可能会让负载的作者在名字空间中拥有超出预期的权限。 |
| 79 | +<!-- |
| 80 | +- **Apply the selected profiles in `warn` and `audit` mode.** This will give you an idea of how |
| 81 | + your Pods will respond to the new policies, without breaking existing workloads. Iterate on your |
| 82 | + [Pods' configuration](/docs/concepts/security/pod-security-admission#configuring-pods) until |
| 83 | + they are in compliance with the selected profiles. |
| 84 | +- Apply the profiles in `enforce` mode. |
| 85 | +- Stop including `PodSecurityPolicy` in the `--enable-admission-plugins` flag. |
| 86 | +--> |
| 87 | +- **在 `warn` 和 `audit` 模式下应用所选的策略。** |
| 88 | + 这样做会让你了解 Pod 会如何对新的策略作出反应,同时不会破坏现有负载。 |
| 89 | + 反复调试你的[Pod 配置](/zh/docs/concepts/security/pod-security-admission#configuring-pods) |
| 90 | + 直到它们与所选的策略匹配。 |
| 91 | +- 用 `enforce` 模式下应用策略。 |
| 92 | +- 在 `--enable-admission-plugins` 标志中去除 `PodSecurityPolicy`。 |
| 93 | + |
0 commit comments