@@ -57,6 +57,16 @@ Install the following on your workstation:
57
57
- [ KinD] ( https://kind.sigs.k8s.io/docs/user/quick-start/#installation )
58
58
- [ kubectl] ( /zh-cn/docs/tasks/tools/ )
59
59
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
+
60
70
<!--
61
71
## Choose the right Pod Security Standard to apply
62
72
@@ -82,13 +92,17 @@ that are most appropriate for your configuration, do the following:
82
92
1 . 创建一个没有应用 Pod 安全标准的集群:
83
93
84
94
``` 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
86
96
```
87
- <!-- The output is similar to this: -->
97
+ <!--
98
+ The output is similar to:
99
+ -->
100
+
88
101
输出类似于:
102
+
89
103
```
90
104
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) 🖼
92
106
✓ Preparing nodes 📦
93
107
✓ Writing configuration 📜
94
108
✓ Starting control-plane 🕹️
@@ -110,8 +124,12 @@ that are most appropriate for your configuration, do the following:
110
124
``` shell
111
125
kubectl cluster-info --context kind-psa-wo-cluster-pss
112
126
```
113
- <!-- The output is similar to this: -->
127
+ <!--
128
+ The output is similar to this:
129
+ -->
130
+
114
131
输出类似于:
132
+
115
133
```
116
134
Kubernetes control plane is running at https://127.0.0.1:61350
117
135
@@ -128,8 +146,12 @@ that are most appropriate for your configuration, do the following:
128
146
``` shell
129
147
kubectl get ns
130
148
```
131
- <!-- The output is similar to this: -->
149
+ <!--
150
+ The output is similar to this:
151
+ -->
152
+
132
153
输出类似于:
154
+
133
155
```
134
156
NAME STATUS AGE
135
157
default Active 9m30s
@@ -150,8 +172,13 @@ that are most appropriate for your configuration, do the following:
150
172
kubectl label --dry-run=server --overwrite ns --all \
151
173
pod-security.kubernetes.io/enforce=privileged
152
174
```
153
- < ! -- The output is similar to this: -->
175
+
176
+ < ! --
177
+ The output is similar to:
178
+ -->
179
+
154
180
输出类似于:
181
+
155
182
```
156
183
namespace/default labeled
157
184
namespace/kube-node-lease labeled
@@ -164,8 +191,13 @@ that are most appropriate for your configuration, do the following:
164
191
kubectl label --dry-run=server --overwrite ns --all \
165
192
pod-security.kubernetes.io/enforce=baseline
166
193
` ` `
167
- < ! -- The output is similar to this: -->
194
+
195
+ < ! --
196
+ The output is similar to:
197
+ -->
198
+
168
199
输出类似于:
200
+
169
201
```
170
202
namespace/default labeled
171
203
namespace/kube-node-lease labeled
@@ -183,8 +215,13 @@ that are most appropriate for your configuration, do the following:
183
215
kubectl label --dry-run=server --overwrite ns --all \
184
216
pod-security.kubernetes.io/enforce=restricted
185
217
` ` `
186
- < ! -- The output is similar to this: -->
218
+
219
+ < ! --
220
+ The output is similar to:
221
+ -->
222
+
187
223
输出类似于:
224
+
188
225
```
189
226
namespace/default labeled
190
227
namespace/kube-node-lease labeled
@@ -351,13 +388,17 @@ following:
351
388
5. 创建一个使用 Pod 安全准入的集群来应用这些 Pod 安全标准:
352
389
353
390
```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
355
392
```
356
- <!-- The output is similar to this: -->
393
+ <!--
394
+ The output is similar to this:
395
+ -->
396
+
357
397
输出类似于:
398
+
358
399
```
359
400
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) 🖼
361
402
✓ Preparing nodes 📦
362
403
✓ Writing configuration 📜
363
404
✓ Starting control-plane 🕹️
@@ -379,18 +420,23 @@ following:
379
420
``` shell
380
421
kubectl cluster-info --context kind-psa-with-cluster-pss
381
422
```
382
- <!-- The output is similar to this: -->
423
+ <!--
424
+ The output is similar to this:
425
+ -->
426
+
383
427
输出类似于:
428
+
384
429
```
385
430
Kubernetes control plane is running at https://127.0.0.1:63855
386
431
CoreDNS is running at https://127.0.0.1:63855/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
387
432
388
433
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
389
434
```
435
+
390
436
<!--
391
- 1. Create the following Pod specification for a minimal configuration in the default namespace:
437
+ 1. Create a Pod in the default namespace:
392
438
-->
393
- 7 . 创建以下 Pod 规约作为在 default 名字空间中的一个最小配置 :
439
+ 7 . 在 default 名字空间下创建一个 Pod :
394
440
395
441
```
396
442
cat <<EOF > /tmp/pss/nginx-pod.yaml
@@ -412,12 +458,15 @@ following:
412
458
8 . 在集群中创建 Pod:
413
459
414
460
``` shell
415
- kubectl apply -f /tmp/pss/nginx -pod.yaml
461
+ kubectl apply -f https://k8s.io/examples/security/example-baseline -pod.yaml
416
462
```
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 正常启动,但输出包含警告:
419
468
```
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")
421
470
pod/nginx created
422
471
```
423
472
0 commit comments