Skip to content

Commit 49b31ed

Browse files
authored
Merge pull request #36959 from sarazqy/qy0
translate content/en/blog/_posts/2022-08-16-PSP-historical-context/index.md into Chinese
2 parents df20363 + 142b5d0 commit 49b31ed

File tree

3 files changed

+2274
-0
lines changed

3 files changed

+2274
-0
lines changed
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
---
2+
layout: blog
3+
title: "PodSecurityPolicy:历史背景"
4+
date: 2022-08-23T15:00:00-0800
5+
slug: podsecuritypolicy-the-historical-context
6+
---
7+
8+
<!--
9+
layout: blog
10+
title: "PodSecurityPolicy: The Historical Context"
11+
date: 2022-08-23T15:00:00-0800
12+
slug: podsecuritypolicy-the-historical-context
13+
-->
14+
15+
<!--
16+
**Author:** Mahé Tardy (Quarkslab)
17+
-->
18+
**作者:** Mahé Tardy (Quarkslab)
19+
20+
<!--
21+
The PodSecurityPolicy (PSP) admission controller has been removed, as of
22+
Kubernetes v1.25. Its deprecation was announced and detailed in the blog post
23+
[PodSecurityPolicy Deprecation: Past, Present, and Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/),
24+
published for the Kubernetes v1.21 release.
25+
-->
26+
从 Kubernetes v1.25 开始,PodSecurityPolicy (PSP) 准入控制器已被移除。
27+
在为 Kubernetes v1.21 发布的博文 [PodSecurityPolicy 弃用:过去、现在和未来](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/)
28+
中,已经宣布并详细说明了它的弃用情况。
29+
30+
<!--
31+
This article aims to provide historical context on the birth and evolution of
32+
PSP, explain why the feature never made it to stable, and show why it was
33+
removed and replaced by Pod Security admission control.
34+
-->
35+
本文旨在提供 PSP 诞生和演变的历史背景,解释为什么从未使该功能达到稳定状态,并说明为什么它被移除并被 Pod 安全准入控制取代。
36+
37+
<!--
38+
PodSecurityPolicy, like other specialized admission control plugins, provided
39+
fine-grained permissions on specific fields concerning the pod security settings
40+
as a built-in policy API. It acknowledged that cluster administrators and
41+
cluster users are usually not the same people, and that creating workloads in
42+
the form of a Pod or any resource that will create a Pod should not equal being
43+
"root on the cluster". It could also encourage best practices by configuring
44+
more secure defaults through mutation and decoupling low-level Linux security
45+
decisions from the deployment process.
46+
-->
47+
PodSecurityPolicy 与其他专门的准入控制插件一样,作为内置的策略 API,对有关 Pod 安全设置的特定字段提供细粒度的权限。
48+
它承认集群管理员和集群用户通常不是同一个人,并且以 Pod 形式或任何将创建 Pod 的资源的形式创建工作负载的权限不应该等同于“集群上的 root 账户”。
49+
它还可以通过变更配置来应用更安全的默认值,并将底层 Linux 安全决策与部署过程分离来促进最佳实践。
50+
51+
<!--
52+
## The birth of PodSecurityPolicy
53+
54+
PodSecurityPolicy originated from OpenShift's SecurityContextConstraints
55+
(SCC) that were in the very first release of the Red Hat OpenShift Container Platform,
56+
even before Kubernetes 1.0. PSP was a stripped-down version of the SCC.
57+
-->
58+
## PodSecurityPolicy 的诞生
59+
60+
PodSecurityPolicy 源自 OpenShift 的 SecurityContextConstraints (SCC),
61+
它出现在 Red Hat OpenShift 容器平台的第一个版本中,甚至在 Kubernetes 1.0 之前。PSP 是 SCC 的精简版。
62+
63+
<!--
64+
The origin of the creation of PodSecurityPolicy is difficult to track, notably
65+
because it was mainly added before Kubernetes Enhancements Proposal (KEP)
66+
process, when design proposals were still a thing. Indeed, the archive of the final
67+
[design proposal](https://github.com/kubernetes/design-proposals-archive/blob/main/auth/pod-security-policy.md)
68+
is still available. Nevertheless, a [KEP issue number five](https://github.com/kubernetes/enhancements/issues/5)
69+
was created after the first pull requests were merged.
70+
-->
71+
PodSecurityPolicy 的创建起源很难追踪,特别是因为它主要是在 Kubernetes 增强提案 (KEP) 流程之前添加的,
72+
当时仍在使用设计提案(Design Proposal)。事实上,最终[设计提案](https://github.com/kubernetes/design-proposals-archive/blob/main/auth/pod-security-policy.md)的存档仍然可以找到。
73+
尽管如此,[编号为 5 的 KEP](https://github.com/kubernetes/enhancements/issues/5)
74+
是在合并第一个拉取请求后创建的。
75+
76+
<!--
77+
Before adding the first piece of code that created PSP, two main pull
78+
requests were merged into Kubernetes, a [`SecurityContext` subresource](https://github.com/kubernetes/kubernetes/pull/7343)
79+
that defined new fields on pods' containers, and the first iteration of the [ServiceAccount](https://github.com/kubernetes/kubernetes/pull/7101)
80+
API.
81+
-->
82+
在添加创建 PSP 的第一段代码之前,两个主要的拉取请求被合并到 Kubernetes 中,
83+
[`SecurityContext` 子资源](https://github.com/kubernetes/kubernetes/pull/7343)
84+
定义了 Pod 容器上的新字段,以及 [ServiceAccount](https://github.com/kubernetes/kubernetes/pull/7101)
85+
API 的第一次迭代。
86+
87+
88+
<!--
89+
Kubernetes 1.0 was released on 10 July 2015 without any mechanism to restrict the
90+
security context and sensitive options of workloads, other than an alpha-quality
91+
SecurityContextDeny admission plugin (then known as `scdeny`).
92+
The [SecurityContextDeny plugin](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#securitycontextdeny)
93+
is still in Kubernetes today (as an alpha feature) and creates an admission controller that
94+
prevents the usage of some fields in the security context.
95+
-->
96+
Kubernetes 1.0 于 2015 年 7 月 10 日发布,除了 Alpha 阶段的 SecurityContextDeny 准入插件
97+
(当时称为 `scdeny`)之外,
98+
没有任何机制来限制安全上下文和工作负载的敏感选项。
99+
[SecurityContextDeny 插件](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#securitycontextdeny)
100+
今天仍存在于 Kubernetes 中(作为 Alpha 特性),负责创建一个准入控制器,以防止在安全上下文中使用某些字段。
101+
102+
<!--
103+
The roots of the PodSecurityPolicy were added with
104+
[the very first pull request on security policy](https://github.com/kubernetes/kubernetes/pull/7893),
105+
which added the design proposal with the new PSP object, based on the SCC (Security Context Constraints). It
106+
was a long discussion of nine months, with back and forth from OpenShift's SCC,
107+
many rebases, and the rename to PodSecurityPolicy that finally made it to
108+
upstream Kubernetes in February 2016. Now that the PSP object
109+
had been created, the next step was to add an admission controller that could enforce
110+
these policies. The first step was to add the admission
111+
[without taking into account the users or groups](https://github.com/kubernetes/kubernetes/pull/7893#issuecomment-180410539).
112+
A specific [issue to bring PodSecurityPolicy to a usable state](https://github.com/kubernetes/kubernetes/issues/23217)
113+
was added to keep track of the progress and a first version of the admission
114+
controller was merged in [pull request named PSP admission](https://github.com/kubernetes/kubernetes/pull/24600)
115+
in May 2016. Then around two months later, Kubernetes 1.3 was released.
116+
-->
117+
PodSecurityPolicy 的根源是[早期关于安全策略的一个拉取请求](https://github.com/kubernetes/kubernetes/pull/7893)
118+
它以 SCC(安全上下文约束)为基础,增加了新的 PSP 对象的设计方案。这是一个长达 9 个月的漫长讨论,
119+
基于 OpenShift 的 SCC 反复讨论,
120+
多次变动,并重命名为 PodSecurityPolicy,最终在 2016 年 2 月进入上游 Kubernetes。
121+
现在 PSP 对象已经创建,下一步是添加一个可以执行这些政策的准入控制器。
122+
第一步是添加[不考虑用户或组](https://github.com/kubernetes/kubernetes/pull/7893#issuecomment-180410539)
123+
的准入控制。
124+
2016 年 5 月,一个特定的[使 PodSecurityPolicy 达到可用状态的问题](https://github.com/kubernetes/kubernetes/issues/23217)被添加进来,
125+
以跟踪进展,并在[名为 PSP 准入的拉取请求](https://github.com/kubernetes/kubernetes/pull/24600)中合并了准入控制器的第一个版本。
126+
然后大约两个月后,发布了 Kubernetes 1.3。
127+
128+
129+
<!--
130+
Here is a timeline that recaps the main pull requests of the birth of the
131+
PodSecurityPolicy and its admission controller with 1.0 and 1.3 releases as
132+
reference points.
133+
-->
134+
下面是一个时间表,它以 1.0 和 1.3 版本作为参考点,回顾了 PodSecurityPolicy 及其准入控制器诞生的主要拉取请求。
135+
136+
{{< figure src="./timeline.svg" alt="Timeline of the PodSecurityPolicy creation pull requests" >}}
137+
138+
<!--
139+
After that, the PSP admission controller was enhanced by adding what was initially
140+
left aside. [The authorization mechanism](https://github.com/kubernetes/kubernetes/pull/33080),
141+
merged in early November 2016 allowed administrators to use multiple policies
142+
in a cluster to grant different levels of access for different types of users.
143+
Later, a [pull request](https://github.com/kubernetes/kubernetes/pull/52849)
144+
merged in October 2017 fixed [a design issue](https://github.com/kubernetes/kubernetes/issues/36184)
145+
on ordering PodSecurityPolicies between mutating and alphabetical order, and continued to
146+
build the PSP admission as we know it. After that, many improvements and fixes
147+
followed to build the PodSecurityPolicy feature of recent Kubernetes releases.
148+
-->
149+
之后,PSP 准入控制器通过添加最初被搁置的内容进行了增强。
150+
在 2016 年 11 月上旬合并[鉴权机制](https://github.com/kubernetes/kubernetes/pull/33080)
151+
允许管理员在集群中使用多个策略,为不同类型的用户授予不同级别的访问权限。
152+
后来,2017 年 10 月合并的一个[拉取请求](https://github.com/kubernetes/kubernetes/pull/52849)
153+
修复了 PodSecurityPolicies 在变更和字母顺序之间冲突的[设计问题](https://github.com/kubernetes/kubernetes/issues/36184)
154+
并继续构建我们所知道的 PSP 准入。之后,进行了许多改进和修复,以构建最近 Kubernetes 版本的 PodSecurityPolicy 功能。
155+
156+
157+
<!--
158+
## The rise of Pod Security Admission
159+
160+
Despite the crucial issue it was trying to solve, PodSecurityPolicy presented
161+
some major flaws:
162+
-->
163+
## Pod 安全准入的兴起
164+
165+
尽管 PodSecurityPolicy 试图解决的是一个关键问题,但它却包含一些重大缺陷:
166+
167+
<!--
168+
- **Flawed authorization model** - users can create a pod if they have the
169+
**use** verb on the PSP that allows that pod or the pod's service account has
170+
the **use** permission on the allowing PSP.
171+
- **Difficult to roll out** - PSP fail-closed. That is, in the absence of a policy,
172+
all pods are denied. It mostly means that it cannot be enabled by default and
173+
that users have to add PSPs for all workloads before enabling the feature,
174+
thus providing no audit mode to discover which pods would not be allowed by
175+
the new policy. The opt-in model also leads to insufficient test coverage and
176+
frequent breakage due to cross-feature incompatibility. And unlike RBAC,
177+
there was no strong culture of shipping PSP manifests with projects.
178+
- **Inconsistent unbounded API** - the API has grown with lots of
179+
inconsistencies notably because of many requests for niche use cases: e.g.
180+
labels, scheduling, fine-grained volume controls, etc. It has poor
181+
composability with a weak prioritization model, leading to unexpected
182+
mutation priority. It made it really difficult to combine PSP with other
183+
third-party admission controllers.
184+
- **Require security knowledge** - effective usage still requires an
185+
understanding of Linux security primitives. e.g. MustRunAsNonRoot +
186+
AllowPrivilegeEscalation.
187+
-->
188+
- **有缺陷的鉴权模式** - 如果用户针对 PSP 具有执行 **use** 动作的权限,而此 PSP 准许该 Pod
189+
或者该 Pod 的服务帐户对 PSP 执行 **use** 操作,则用户可以创建一个 Pod。
190+
- **难以推广** - PSP 失败关闭。也就是说,在没有策略的情况下,所有 Pod 都会被拒绝。
191+
这主要意味着默认情况下无法启用它,并且用户必须在启用该功能之前为所有工作负载添加 PSP,
192+
因此没有提供审计模式来发现哪些 Pod 会不被新策略所允许。
193+
这种采纳模式还导致测试覆盖率不足,并因跨特性不兼容而经常出现故障。
194+
而且与 RBAC 不同的是,还不存在在项目中交付 PSP 清单的强大文化。
195+
- **不一致的无边界 API** - API 的发展有很多不一致的地方,特别是由于许多小众场景的请求:
196+
如标签、调度、细粒度的卷控制等。它的可组合性很差,优先级模型较弱,会导致意外的变更优先级。
197+
这使得 PSP 与其他第三方准入控制器的结合真的很困难。
198+
- **需要安全知识** - 有效使用 PSP 仍然需要了解 Linux 的安全原语。
199+
例如:MustRunAsNonRoot + AllowPrivilegeEscalation。
200+
201+
<!--
202+
The experience with PodSecurityPolicy concluded that most users care for two or three
203+
policies, which led to the creation of the [Pod Security Standards](/docs/concepts/security/pod-security-standards/),
204+
that define three policies:
205+
- **Privileged** - unrestricted policy.
206+
- **Baseline** - minimally restrictive policy, allowing the default pod
207+
configuration.
208+
- **Restricted** - security best practice policy.
209+
-->
210+
PodSecurityPolicy 的经验得出的结论是,大多数用户关心两个或三个策略,这导致了
211+
[Pod 安全标准](/zh-cn/docs/concepts/security/pod-security-standards/)的创建,它定义了三个策略:
212+
- **Privileged(特权的)** - 策略不受限制。
213+
- **Baseline(基线的)** - 策略限制很少,允许默认 Pod 配置。
214+
- **Restricted(受限的)** - 安全最佳实践策略。
215+
216+
<!--
217+
The replacement for PSP, the new [Pod Security Admission](/docs/concepts/security/pod-security-admission/)
218+
is an in-tree, stable for Kubernetes v1.25, admission plugin to enforce these
219+
standards at the namespace level. It makes it easier to enforce basic pod
220+
security without deep security knowledge. For more sophisticated use cases, you
221+
might need a third-party solution that can be easily combined with Pod Security
222+
Admission.
223+
-->
224+
作为 PSP 的替代品,新的 [Pod 安全准入](/zh-cn/docs/concepts/security/pod-security-admission/)
225+
Kubernetes v1.25 的树内稳定的准入插件,用于在命名空间级别强制执行这些标准。
226+
无需深入的安全知识,就可以更轻松地实施基本的 Pod 安全性。
227+
对于更复杂的用例,你可能需要一个可以轻松与 Pod 安全准入结合的第三方解决方案。
228+
229+
<!--
230+
## What's next
231+
232+
For further details on the SIG Auth processes, covering PodSecurityPolicy removal and
233+
creation of Pod Security admission, the
234+
[SIG auth update at KubeCon NA 2019](https://www.youtube.com/watch?v=SFtHRmPuhEw)
235+
and the [PodSecurityPolicy Replacement: Past, Present, and Future](https://www.youtube.com/watch?v=HsRRmlTJpls)
236+
presentation at KubeCon NA 2021 records are available.
237+
-->
238+
## 下一步是什么
239+
240+
有关 SIG Auth 流程的更多详细信息,包括 PodSecurityPolicy 删除和 Pod 安全准入的创建,
241+
请参阅在 KubeCon NA 2021 的
242+
[SIG auth update at KubeCon NA 2019](https://www.youtube.com/watch?v=SFtHRmPuhEw)
243+
[PodSecurityPolicy Replacement: Past, Present, and Future](https://www.youtube.com/watch?v=HsRRmlTJpls)
244+
演示录像。
245+
246+
<!--
247+
Particularly on the PSP removal, the
248+
[PodSecurityPolicy Deprecation: Past, Present, and Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/)
249+
blog post is still accurate.
250+
-->
251+
特别是在 PSP 移除方面,[PodSecurityPolicy 弃用:过去、现在和未来](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/)博客文章仍然是准确的。
252+
253+
<!--
254+
And for the new Pod Security admission,
255+
[documentation is available](/docs/concepts/security/pod-security-admission/).
256+
In addition, the blog post
257+
[Kubernetes 1.23: Pod Security Graduates to Beta](/blog/2021/12/09/pod-security-admission-beta/)
258+
along with the KubeCon EU 2022 presentation
259+
[The Hitchhiker's Guide to Pod Security](https://www.youtube.com/watch?v=gcz5VsvOYmI)
260+
give great hands-on tutorials to learn.
261+
-->
262+
对于新的 Pod 安全许可,[可以访问文档](/zh-cn/docs/concepts/security/pod-security-admission/)
263+
此外,博文 [Kubernetes 1.23: Pod Security Graduers to Beta](/blog/2021/12/09/pod-security-admission-beta/)
264+
以及 KubeCon EU 2022 演示文稿 [the Hitchhicker’s Guide to Pod Security](https://www.youtube.com/watch?v=gcz5VsvOYmI)
265+
提供了很好的实践教程来学习。

0 commit comments

Comments
 (0)