@@ -57,6 +57,16 @@ Install the following on your workstation:
5757- [ KinD] ( https://kind.sigs.k8s.io/docs/user/quick-start/#installation )
5858- [ kubectl] ( /zh-cn/docs/tasks/tools/ )
5959
60+ <!--
61+ This tutorial demonstrates what you can configure for a Kubernetes cluster that you fully
62+ control. If you are learning how to configure Pod Security Admission for a managed cluster
63+ where you are not able to configure the control plane, read
64+ [Apply Pod Security Standards at the namespace level](/docs/tutorials/security/ns-level-pss).
65+ -->
66+ 本教程演示了你可以对完全由你控制的 Kubernetes 集群所配置的内容。
67+ 如果你正在学习如何为一个无法配置控制平面的托管集群配置 Pod 安全准入,
68+ 请参阅[ 在名字空间级别应用 Pod 安全标准] ( /zh-cn/docs/tutorials/security/ns-level-pss ) 。
69+
6070<!--
6171## Choose the right Pod Security Standard to apply
6272
@@ -82,13 +92,17 @@ that are most appropriate for your configuration, do the following:
82921 . 创建一个没有应用 Pod 安全标准的集群:
8393
8494 ``` shell
85- kind create cluster --name psa-wo-cluster-pss --image kindest/node:v1.24.0
95+ kind create cluster --name psa-wo-cluster-pss
8696 ```
87- <!-- The output is similar to this: -->
97+ <!--
98+ The output is similar to:
99+ -->
100+
88101 输出类似于:
102+
89103 ```
90104 Creating cluster "psa-wo-cluster-pss" ...
91- ✓ Ensuring node image (kindest/node:v1.24 .0) 🖼
105+ ✓ Ensuring node image (kindest/node:v{{< skew currentVersion >}} .0) 🖼
92106 ✓ Preparing nodes 📦
93107 ✓ Writing configuration 📜
94108 ✓ Starting control-plane 🕹️
@@ -110,8 +124,12 @@ that are most appropriate for your configuration, do the following:
110124 ``` shell
111125 kubectl cluster-info --context kind-psa-wo-cluster-pss
112126 ```
113- <!-- The output is similar to this: -->
127+ <!--
128+ The output is similar to this:
129+ -->
130+
114131 输出类似于:
132+
115133 ```
116134 Kubernetes control plane is running at https://127.0.0.1:61350
117135
@@ -128,8 +146,12 @@ that are most appropriate for your configuration, do the following:
128146 ``` shell
129147 kubectl get ns
130148 ```
131- <!-- The output is similar to this: -->
149+ <!--
150+ The output is similar to this:
151+ -->
152+
132153 输出类似于:
154+
133155 ```
134156 NAME STATUS AGE
135157 default Active 9m30s
@@ -150,8 +172,13 @@ that are most appropriate for your configuration, do the following:
150172 kubectl label --dry-run=server --overwrite ns --all \
151173 pod-security.kubernetes.io/enforce=privileged
152174 ```
153- < ! -- The output is similar to this: -->
175+
176+ < ! --
177+ The output is similar to:
178+ -->
179+
154180 输出类似于:
181+
155182 ```
156183 namespace/default labeled
157184 namespace/kube-node-lease labeled
@@ -164,8 +191,13 @@ that are most appropriate for your configuration, do the following:
164191 kubectl label --dry-run=server --overwrite ns --all \
165192 pod-security.kubernetes.io/enforce=baseline
166193 ` ` `
167- < ! -- The output is similar to this: -->
194+
195+ < ! --
196+ The output is similar to:
197+ -->
198+
168199 输出类似于:
200+
169201 ```
170202 namespace/default labeled
171203 namespace/kube-node-lease labeled
@@ -183,8 +215,13 @@ that are most appropriate for your configuration, do the following:
183215 kubectl label --dry-run=server --overwrite ns --all \
184216 pod-security.kubernetes.io/enforce=restricted
185217 ` ` `
186- < ! -- The output is similar to this: -->
218+
219+ < ! --
220+ The output is similar to:
221+ -->
222+
187223 输出类似于:
224+
188225 ```
189226 namespace/default labeled
190227 namespace/kube-node-lease labeled
@@ -351,13 +388,17 @@ following:
3513885. 创建一个使用 Pod 安全准入的集群来应用这些 Pod 安全标准:
352389
353390 ```shell
354- kind create cluster --name psa-with-cluster-pss --image kindest/node:v1.24.0 -- config /tmp/pss/cluster-config.yaml
391+ kind create cluster --name psa-with-cluster-pss --config /tmp/pss/cluster-config.yaml
355392 ```
356- <!-- The output is similar to this: -->
393+ <!--
394+ The output is similar to this:
395+ -->
396+
357397 输出类似于:
398+
358399 ```
359400 Creating cluster "psa-with-cluster-pss" ...
360- ✓ Ensuring node image (kindest/node:v1.24 .0) 🖼
401+ ✓ Ensuring node image (kindest/node:v{{< skew currentVersion >}} .0) 🖼
361402 ✓ Preparing nodes 📦
362403 ✓ Writing configuration 📜
363404 ✓ Starting control-plane 🕹️
@@ -379,18 +420,23 @@ following:
379420 ``` shell
380421 kubectl cluster-info --context kind-psa-with-cluster-pss
381422 ```
382- <!-- The output is similar to this: -->
423+ <!--
424+ The output is similar to this:
425+ -->
426+
383427 输出类似于:
428+
384429 ```
385430 Kubernetes control plane is running at https://127.0.0.1:63855
386431 CoreDNS is running at https://127.0.0.1:63855/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
387432
388433 To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
389434 ```
435+
390436<!--
391- 1. Create the following Pod specification for a minimal configuration in the default namespace:
437+ 1. Create a Pod in the default namespace:
392438-->
393- 7 . 创建以下 Pod 规约作为在 default 名字空间中的一个最小配置 :
439+ 7 . 在 default 名字空间下创建一个 Pod :
394440
395441 ```
396442 cat <<EOF > /tmp/pss/nginx-pod.yaml
@@ -412,12 +458,15 @@ following:
4124588 . 在集群中创建 Pod:
413459
414460 ``` shell
415- kubectl apply -f /tmp/pss/nginx -pod.yaml
461+ kubectl apply -f https://k8s.io/examples/security/example-baseline -pod.yaml
416462 ```
417- <!-- The output is similar to this: -->
418- 输出类似于:
463+
464+ <!--
465+ The pod is started normally, but the output includes a warning:
466+ -->
467+ 这个 Pod 正常启动,但输出包含警告:
419468 ```
420- Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "nginx" must set securityContext allowPrivilegeEscalation=false), unrestricted capabilities (container "nginx" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "nginx" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "nginx" must set securityContext seccompProfile.type to "RuntimeDefault" or "Localhost")
469+ Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "nginx" must set securityContext. allowPrivilegeEscalation=false), unrestricted capabilities (container "nginx" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "nginx" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "nginx" must set securityContext. seccompProfile.type to "RuntimeDefault" or "Localhost")
421470 pod/nginx created
422471 ```
423472
0 commit comments