Skip to content

Commit 003d920

Browse files
authored
Merge pull request #35348 from yanrongshi/zu]Sync-pod-security-policy.md
[zh-cn]sync pod-security-policy.md
2 parents a9af4bb + f09e8b1 commit 003d920

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

content/zh-cn/docs/concepts/security/pod-security-policy.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,19 @@ controller selects policies according to the following criteria:
402402
PodSecurityPolicies doesn't matter.
403403
2. If the pod must be defaulted or mutated, the first PodSecurityPolicy
404404
(ordered by name) to allow the pod is selected.
405+
406+
When a Pod is validated against a PodSecurityPolicy, [a `kubernetes.io/psp` annotation](/docs/reference/labels-annotations-taints/#kubernetes-io-psp)
407+
is added to the Pod, with the name of the PodSecurityPolicy as the annotation value.
405408
-->
406409
1. 优先考虑允许 Pod 保持原样,不会更改 Pod 字段默认值或其他配置的 PodSecurityPolicy。
407410
这类非更改性质的 PodSecurityPolicy 对象之间的顺序无关紧要。
408411
2. 如果必须要为 Pod 设置默认值或者其他配置,(按名称顺序)选择第一个允许
409412
Pod 操作的 PodSecurityPolicy 对象。
410413

414+
当根据 PodSecurityPolicy 对一个 Pod 进行验证时,会为 Pod 添加
415+
[一个 `kubernetes.io/psp` 注释](/zh-cn/docs/reference/labels-annotations-taints/#kubernetes-io-psp)会被添加到 Pod 中,
416+
注解的值为 PodSecurityPolicy 的名称。
417+
411418
{{< note >}}
412419
<!--
413420
During update operations (during which mutations to pod specs are disallowed)
@@ -457,15 +464,15 @@ alias kubectl-user='kubectl --as=system:serviceaccount:psp-example:fake-user -n
457464
<!--
458465
### Create a policy and a pod
459466

460-
Define the example PodSecurityPolicy object in a file. This is a policy that
461-
prevents the creation of privileged pods.
467+
This is a policy that prevents the creation of privileged pods.
468+
462469
The name of a PodSecurityPolicy object must be a valid
463470
[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
464471
-->
465472
### 创建一个策略和一个 Pod {#create-a-policy-and-a-pod}
466473

467-
在一个文件中定义一个示例的 PodSecurityPolicy 对象
468-
这里的策略只是用来禁止创建有特权要求的 Pods。
474+
下面是一个防止创建特权 Pod 的策略
475+
469476
PodSecurityPolicy 对象的名称必须是合法的
470477
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)。
471478

@@ -477,7 +484,7 @@ And create it with kubectl:
477484
使用 kubectl 执行创建操作:
478485

479486
```shell
480-
kubectl-admin create -f example-psp.yaml
487+
kubectl-admin create -f https://k8s.io/examples/policy/example-psp.yaml
481488
```
482489

483490
<!--
@@ -517,6 +524,11 @@ pod's service account nor `fake-user` have permission to use the new policy:
517524
kubectl-user auth can-i use podsecuritypolicy/example
518525
```
519526

527+
<!--
528+
The output is similar to this:
529+
-->
530+
输出类似于:
531+
520532
```
521533
no
522534
```
@@ -597,11 +609,29 @@ pod "pause" created
597609
```
598610

599611
<!--
600-
It works as expected! But any attempts to create a privileged pod should still
601-
be denied:
612+
It works as expected! You can verify that the pod was validated against the
613+
newly created PodSecurityPolicy:
602614
-->
603615
此次尝试不出所料地成功了!
604-
不过任何创建特权 Pod 的尝试还是会被拒绝:
616+
你可以验证 Pod 是根据新创建的 PodSecurityPolicy 验证的。
617+
618+
```shell
619+
kubectl-user get pod pause -o yaml | grep kubernetes.io/psp
620+
```
621+
622+
<!--
623+
The output is similar to this:
624+
-->
625+
输出类似于:
626+
627+
```
628+
kubernetes.io/psp: example
629+
```
630+
<!--
631+
But any attempts to create a privileged pod should still
632+
be denied:
633+
-->
634+
但任何试图创建特权 Pod 的请求仍然会被拒绝。
605635

606636
```shell
607637
kubectl-user create -f- <<EOF

0 commit comments

Comments
 (0)