Skip to content

Commit 18107b5

Browse files
author
zhuzhenghao
committed
[zh] sync page ns-level-pss
1 parent 4b409b6 commit 18107b5

File tree

1 file changed

+52
-56
lines changed

1 file changed

+52
-56
lines changed

content/zh-cn/docs/tutorials/security/ns-level-pss.md

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ weight: 20
1111
-->
1212

1313
{{% alert title="Note" %}}
14-
<!-- This tutorial applies only for new clusters. -->
14+
<!--
15+
This tutorial applies only for new clusters.
16+
-->
1517
本教程仅适用于新集群。
1618
{{% /alert %}}
1719

@@ -24,7 +26,7 @@ when pods are created. In this tutorial, you will enforce the `baseline` Pod Sec
2426
one namespace at a time.
2527
2628
You can also apply Pod Security Standards to multiple namespaces at once at the cluster
27-
level. For instructions, refer to
29+
level. For instructions, refer to
2830
[Apply Pod Security Standards at the cluster level](/docs/tutorials/security/cluster-level-pss/).
2931
-->
3032
Pod 安全准入(PSA)在 v1.23 及更高版本默认启用,
@@ -59,42 +61,48 @@ Install the following on your workstation:
5961
2. 按照如下方式创建一个 `KinD` 集群:
6062

6163
```shell
62-
kind create cluster --name psa-ns-level --image kindest/node:v1.23.0
64+
kind create cluster --name psa-ns-level
6365
```
6466

65-
<!-- The output is similar to this: -->
67+
<!--
68+
The output is similar to this:
69+
-->
6670
输出类似于:
6771

6872
```
6973
Creating cluster "psa-ns-level" ...
70-
✓ Ensuring node image (kindest/node:v1.23.0) 🖼
74+
✓ Ensuring node image (kindest/node:v{{< skew currentVersion >}}.0) 🖼
7175
✓ Preparing nodes 📦
7276
✓ Writing configuration 📜
7377
✓ Starting control-plane 🕹️
7478
✓ Installing CNI 🔌
7579
✓ Installing StorageClass 💾
7680
Set kubectl context to "kind-psa-ns-level"
7781
You can now use your cluster with:
78-
82+
7983
kubectl cluster-info --context kind-psa-ns-level
80-
84+
8185
Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/quick-start/
8286
```
8387

84-
<!-- 1. Set the kubectl context to the new cluster: -->
88+
<!--
89+
1. Set the kubectl context to the new cluster:
90+
-->
8591
1. 将 kubectl 上下文设置为新集群:
8692

8793
```shell
8894
kubectl cluster-info --context kind-psa-ns-level
8995
```
9096

91-
<!-- The output is similar to this: -->
97+
<!--
98+
The output is similar to this:
99+
-->
92100
输出类似于:
93101

94102
```
95103
Kubernetes control plane is running at https://127.0.0.1:50996
96104
CoreDNS is running at https://127.0.0.1:50996/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
97-
105+
98106
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
99107
```
100108

@@ -111,42 +119,45 @@ Create a new namespace called `example`:
111119
kubectl create ns example
112120
```
113121

114-
<!-- The output is similar to this: -->
122+
<!--
123+
The output is similar to this:
124+
-->
115125
输出类似于:
116126

117127
```
118128
namespace/example created
119129
```
120130

121131
<!--
122-
## Apply Pod Security Standards
132+
## Enable Pod Security Standards checking for that namespace
123133
124134
1. Enable Pod Security Standards on this namespace using labels supported by
125-
built-in Pod Security Admission. In this step we will warn on baseline pod
126-
security standard as per the latest version (default value)
135+
built-in Pod Security Admission. In this step you will configure a check to
136+
warn on Pods that don't meet the latest version of the _baseline_ pod
137+
security standard.
127138
-->
128-
## 应用 Pod 安全标准 {#apply-pod-security-standards}
139+
## 为该命名空间启用 Pod 安全标准检查 {#enable-pod-security-standards-checking-for-that-namespace}
129140

130141
1. 使用内置 Pod 安全准入所支持的标签在此名字空间上启用 Pod 安全标准。
131142
在这一步中,我们将根据最新版本(默认值)对基线 Pod 安全标准发出警告。
132143

133144
```shell
134145
kubectl label --overwrite ns example \
135-
pod-security.kubernetes.io/warn=baseline \
136-
pod-security.kubernetes.io/warn-version=latest
146+
pod-security.kubernetes.io/warn=baseline \
147+
pod-security.kubernetes.io/warn-version=latest
137148
```
138149

139150
<!--
140-
2. Multiple pod security standards can be enabled on any namespace, using labels.
141-
Following command will `enforce` the `baseline` Pod Security Standard, but
151+
2. You can configure multiple pod security standard checks on any namespace, using labels.
152+
The following command will `enforce` the `baseline` Pod Security Standard, but
142153
`warn` and `audit` for `restricted` Pod Security Standards as per the latest
143154
version (default value)
144155
-->
145-
2. 可以使用标签在任何名字空间上启用多个 Pod 安全标准
156+
1. 你可以使用标签在任何名字空间上配置多个 Pod 安全标准检查
146157
以下命令将强制(`enforce`) 执行基线(`baseline`)Pod 安全标准,
147158
但根据最新版本(默认值)对受限(`restricted`)Pod 安全标准执行警告(`warn`)和审核(`audit`)。
148159

149-
```
160+
```shell
150161
kubectl label --overwrite ns example \
151162
pod-security.kubernetes.io/enforce=baseline \
152163
pod-security.kubernetes.io/enforce-version=latest \
@@ -157,67 +168,51 @@ namespace/example created
157168
```
158169

159170
<!--
160-
## Verify the Pod Security Standards
171+
## Verify the Pod Security Standard enforcement
161172
162-
1. Create a minimal pod in `example` namespace:
173+
1. Create a baseline Pod in the `example` namespace:
163174
-->
164175
## 验证 Pod 安全标准 {#verify-the-pod-security-standards}
165176

166-
1.`example` 名字空间中创建一个最小的 Pod:
167-
168-
```shell
169-
cat <<EOF > /tmp/pss/nginx-pod.yaml
170-
apiVersion: v1
171-
kind: Pod
172-
metadata:
173-
name: nginx
174-
spec:
175-
containers:
176-
- image: nginx
177-
name: nginx
178-
ports:
179-
- containerPort: 80
180-
EOF
181-
```
182-
183-
<!--
184-
2. Apply the pod spec to the cluster in `example` namespace:
185-
-->
186-
1. 将 Pod 规约应用到集群中的 `example` 名字空间中:
177+
1.`example` 名字空间中创建一个基线 Pod:
187178

188179
```shell
189-
kubectl apply -n example -f /tmp/pss/nginx-pod.yaml
180+
kubectl apply -n example -f https://k8s.io/examples/security/example-baseline-pod.yaml
190181
```
191-
192-
<!-- The output is similar to this: -->
193-
输出类似于:
182+
<!--
183+
The Pod does start OK; the output includes a warning. For example:
184+
-->
185+
Pod 确实启动正常;输出包括一条警告信息。例如:
194186

195187
```
196-
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")
188+
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")
197189
pod/nginx created
198190
```
199191

200192
<!--
201-
1. Apply the pod spec to the cluster in `default` namespace:
193+
1. Create a baseline Pod in the `default` namespace:
202194
-->
203-
3. 将 Pod 规约应用到集群中的 `default` 名字空间中
195+
1.`default` 名字空间中创建一个基线 Pod
204196

205197
```shell
206-
kubectl apply -n default -f /tmp/pss/nginx-pod.yaml
198+
kubectl apply -n default -f https://k8s.io/examples/security/example-baseline-pod.yaml
207199
```
208200

209-
<!-- Output is similar to this: -->
201+
<!--
202+
Output is similar to this:
203+
-->
210204
输出类似于:
211205

212206
```
213207
pod/nginx created
214208
```
215209

216210
<!--
217-
The Pod Security Standards were applied only to the `example`
218-
namespace. You could create the same Pod in the `default` namespace
219-
with no warnings.
211+
The Pod Security Standards enforcement and warning settings were applied only
212+
to the `example` namespace. You could create the same Pod in the `default`
213+
namespace with no warnings.
220214
-->
215+
Pod 安全标准实施和警告设置仅被应用到 `example` 名字空间。
221216
以上 Pod 安全标准仅被应用到 `example` 名字空间。
222217
你可以在没有警告的情况下在 `default` 名字空间中创建相同的 Pod。
223218

@@ -246,6 +241,7 @@ kind delete cluster --name psa-ns-level
246241
3. Apply `baseline` Pod Security Standard in `enforce` mode while applying
247242
`restricted` Pod Security Standard also in `warn` and `audit` mode.
248243
4. Create a new pod with the following pod security standards applied
244+
249245
- [Pod Security Admission](/docs/concepts/security/pod-security-admission/)
250246
- [Pod Security Standards](/docs/concepts/security/pod-security-standards/)
251247
- [Apply Pod Security Standards at the cluster level](/docs/tutorials/security/cluster-level-pss/)

0 commit comments

Comments
 (0)