Skip to content

Commit 93e202c

Browse files
committed
[zh] update concept policy
1 parent 383dbc2 commit 93e202c

File tree

3 files changed

+137
-39
lines changed

3 files changed

+137
-39
lines changed

content/zh/docs/concepts/policy/pid-limiting.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ weight: 40
1717
{{< feature-state for_k8s_version="v1.20" state="stable" >}}
1818

1919
<!--
20-
Kubernetes allow you to limit the number of process IDs (PIDs) that a {{< glossary_tooltip term_id="Pod" text="Pod" >}} can use.
20+
Kubernetes allow you to limit the number of process IDs (PIDs) that a
21+
{{< glossary_tooltip term_id="Pod" text="Pod" >}} can use.
2122
You can also reserve a number of allocatable PIDs for each {{< glossary_tooltip term_id="node" text="node" >}}
2223
for use by the operating system and daemons (rather than by Pods).
2324
-->
@@ -155,8 +156,8 @@ gate](/docs/reference/command-line-tools-reference/feature-gates/)
155156
Kubernetes allows you to limit the number of processes running in a Pod. You
156157
specify this limit at the node level, rather than configuring it as a resource
157158
limit for a particular Pod. Each Node can have a different PID limit.
158-
To configure the limit, you can specify the command line parameter
159-
`--pod-max-pids` to the kubelet, or set `PodPidsLimit` in the kubelet
159+
To configure the limit, you can specify the command line parameter `--pod-max-pids`
160+
to the kubelet, or set `PodPidsLimit` in the kubelet
160161
[configuration file](/docs/tasks/administer-cluster/kubelet-config-file/).
161162
-->
162163
## Pod 级别 PID 限制 {#pod-pid-limits}
@@ -183,9 +184,12 @@ the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
183184
## PID based eviction
184185
185186
You can configure kubelet to start terminating a Pod when it is misbehaving and consuming abnormal amount of resources.
186-
This feature is called eviction. You can [Configure Out of Resource Handling](/docs/tasks/administer-cluster/out-of-resource) for various eviction signals.
187+
This feature is called eviction. You can
188+
[Configure Out of Resource Handling](/docs/concepts/scheduling-eviction/node-pressure-eviction/)
189+
for various eviction signals.
187190
Use `pid.available` eviction signal to configure the threshold for number of PIDs used by Pod.
188-
You can set soft and hard eviction policies. However, even with the hard eviction policy, if the number of PIDs growing very fast,
191+
You can set soft and hard eviction policies.
192+
However, even with the hard eviction policy, if the number of PIDs growing very fast,
189193
node can still get into unstable state by hitting the node PIDs limit.
190194
Eviction signal value is calculated periodically and does NOT enforce the limit.
191195
-->
@@ -219,15 +223,16 @@ Pod 行为不正常而没有 PID 可用。
219223

220224
<!--
221225
- Refer to the [PID Limiting enhancement document](https://github.com/kubernetes/enhancements/blob/097b4d8276bc9564e56adf72505d43ce9bc5e9e8/keps/sig-node/20190129-pid-limiting.md) for more information.
222-
- For historical context, read [Process ID Limiting for Stability Improvements in Kubernetes 1.14](/blog/2019/04/15/process-id-limiting-for-stability-improvements-in-kubernetes-1.14/).
226+
- For historical context, read
227+
[Process ID Limiting for Stability Improvements in Kubernetes 1.14](/blog/2019/04/15/process-id-limiting-for-stability-improvements-in-kubernetes-1.14/).
223228
- Read [Managing Resources for Containers](/docs/concepts/configuration/manage-resources-containers/).
224-
- Learn how to [Configure Out of Resource Handling](/docs/tasks/administer-cluster/out-of-resource).
229+
- Learn how to [Configure Out of Resource Handling](/docs/concepts/scheduling-eviction/node-pressure-eviction/).
225230
-->
226231
- 参阅 [PID 约束改进文档](https://github.com/kubernetes/enhancements/blob/097b4d8276bc9564e56adf72505d43ce9bc5e9e8/keps/sig-node/20190129-pid-limiting.md)
227232
以了解更多信息。
228233
- 关于历史背景,请阅读
229234
[Kubernetes 1.14 中限制进程 ID 以提升稳定性](/blog/2019/04/15/process-id-limiting-for-stability-improvements-in-kubernetes-1.14/)
230235
的博文。
231236
- 请阅读[为容器管理资源](/zh/docs/concepts/configuration/manage-resources-containers/)
232-
- 学习如何[配置资源不足情况的处理](/zh/docs/tasks/administer-cluster/out-of-resource)
237+
- 学习如何[配置资源不足情况的处理](/zh/docs/concepts/scheduling-eviction/node-pressure-eviction/)
233238

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

Lines changed: 102 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ weight: 30
1515
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
1616

1717
<!--
18-
PodSecurityPolicy is deprecated as of Kubernetes v1.21, and will be removed in v1.25.
18+
PodSecurityPolicy is deprecated as of Kubernetes v1.21, and will be removed in v1.25. For more information on the deprecation,
19+
see [PodSecurityPolicy Deprecation: Past, Present, and Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/).
1920
-->
2021
PodSecurityPolicy 在 Kubernetes v1.21 版本中被弃用,将在 v1.25 中删除。
22+
关于弃用的更多信息,请查阅 [PodSecurityPolicy Deprecation: Past, Present, and Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/)
2123

2224
<!--
2325
Pod Security Policies enable fine-grained authorization of pod creation and
@@ -92,17 +94,16 @@ _Pod 安全策略_ 由设置和策略组成,它们能够控制 Pod 访问的
9294
<!--
9395
## Enabling Pod Security Policies
9496
95-
Pod security policy control is implemented as an optional (but recommended)
96-
[admission
97-
controller](/docs/reference/access-authn-authz/admission-controllers/#podsecuritypolicy). PodSecurityPolicies
98-
are enforced by [enabling the admission
97+
Pod security policy control is implemented as an optional [admission
98+
controller](/docs/reference/access-authn-authz/admission-controllers/#podsecuritypolicy).
99+
PodSecurityPolicies are enforced by [enabling the admission
99100
controller](/docs/reference/access-authn-authz/admission-controllers/#how-do-i-turn-on-an-admission-control-plug-in),
100-
but doing so without authorizing any policies **will prevent any pods from being
101-
created** in the cluster.
101+
but doing so without authorizing any policies **will prevent any pods from being created** in the
102+
cluster.
102103
-->
103104
## 启用 Pod 安全策略
104105

105-
Pod 安全策略实现为一种可选(但是建议启用)的
106+
Pod 安全策略实现为一种可选的
106107
[准入控制器](/zh/docs/reference/access-authn-authz/admission-controllers/#podsecuritypolicy)
107108
[启用了准入控制器](/zh/docs/reference/access-authn-authz/admission-controllers/#how-do-i-turn-on-an-admission-control-plug-in)
108109
即可强制实施 Pod 安全策略,不过如果没有授权认可策略之前即启用
@@ -206,7 +207,11 @@ roleRef:
206207
name: <role name>
207208
apiGroup: rbac.authorization.k8s.io
208209
subjects:
209-
# Authorize specific service accounts:
210+
# Authorize all service accounts in a namespace (recommended):
211+
- kind: Group
212+
apiGroup: rbac.authorization.k8s.io
213+
name: system:serviceaccounts:<authorized namespace>
214+
# Authorize specific service accounts (not recommended):
210215
- kind: ServiceAccount
211216
name: <authorized service account name>
212217
namespace: <authorized pod namespace>
@@ -222,20 +227,24 @@ subjects:
222227
apiVersion: rbac.authorization.k8s.io/v1
223228
kind: ClusterRoleBinding
224229
metadata:
225-
name: <绑定名称>
230+
name: <binding name>
226231
roleRef:
227232
kind: ClusterRole
228-
name: <角色名称>
233+
name: <role name>
229234
apiGroup: rbac.authorization.k8s.io
230235
subjects:
231-
# 授权特定的服务账号
236+
# 授权命名空间下的所有服务账号(推荐):
237+
- kind: Group
238+
apiGroup: rbac.authorization.k8s.io
239+
name: system:serviceaccounts:<authorized namespace>
240+
# 授权特定的服务账号(不建议这样操作):
232241
- kind: ServiceAccount
233-
name: <要授权的服务账号名称>
242+
name: <authorized service account name>
234243
namespace: <authorized pod namespace>
235-
# 授权特定的用户(不建议这样操作)
244+
# 授权特定的用户(不建议这样操作)
236245
- kind: User
237246
apiGroup: rbac.authorization.k8s.io
238-
name: <要授权的用户名>
247+
name: <authorized user name>
239248
```
240249

241250
<!--
@@ -279,6 +288,77 @@ For a complete example of authorizing a PodSecurityPolicy, see
279288
参阅[下文](#example),查看对 PodSecurityPolicy 进行授权的完整示例。
280289

281290
<!--
291+
### Recommended Practice
292+
293+
PodSecurityPolicy is being replaced by a new, simplified `PodSecurity` {{< glossary_tooltip
294+
text="admission controller" term_id="admission-controller" >}}. For more details on this change, see
295+
[PodSecurityPolicy Deprecation: Past, Present, and
296+
Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/). Follow these
297+
guidelines to simplify migration from PodSecurityPolicy to the new admission controller:
298+
-->
299+
## 推荐实践 {#recommended-practice}
300+
301+
PodSecurityPolicy 正在被一个新的、简化的 `PodSecurity` {{< glossary_tooltip
302+
text="准入控制器" term_id="admission-controller" >}}替代。
303+
有关此变更的更多详细信息,请参阅 [PodSecurityPolicy Deprecation: Past, Present, and
304+
Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/)。
305+
参照下述指导,简化从 PodSecurityPolicy 迁移到新的准入控制器步骤:
306+
307+
<!--
308+
1. Limit your PodSecurityPolicies to the policies defined by the [Pod Security Standards](/docs/concepts/security/pod-security-standards):
309+
- {{< example file="policy/privileged-psp.yaml" >}}Privileged{{< /example >}}
310+
- {{< example file="policy/baseline-psp.yaml" >}}Baseline{{< /example >}}
311+
- {{< example file="policy/restricted-psp.yaml" >}}Restricted{{< /example >}}
312+
313+
2. Only bind PSPs to entire namespaces, by using the `system:serviceaccounts:<namespace>` group
314+
(where `<namespace>` is the target namespace). For example:
315+
316+
```yaml
317+
apiVersion: rbac.authorization.k8s.io/v1
318+
# This cluster role binding allows all pods in the "development" namespace to use the baseline PSP.
319+
kind: ClusterRoleBinding
320+
metadata:
321+
name: psp-baseline-namespaces
322+
roleRef:
323+
kind: ClusterRole
324+
name: psp-baseline
325+
apiGroup: rbac.authorization.k8s.io
326+
subjects:
327+
- kind: Group
328+
name: system:serviceaccounts:development
329+
apiGroup: rbac.authorization.k8s.io
330+
- kind: Group
331+
name: system:serviceaccounts:canary
332+
apiGroup: rbac.authorization.k8s.io
333+
```
334+
-->
335+
1. 将 PodSecurityPolicies 限制为 [Pod 安全性标准](/zh/docs/concepts/security/pod-security-standards)所定义的策略:
336+
- {{< example file="policy/privileged-psp.yaml" >}}Privileged{{< /example >}}
337+
- {{< example file="policy/baseline-psp.yaml" >}}Baseline{{< /example >}}
338+
- {{< example file="policy/restricted-psp.yaml" >}}Restricted{{< /example >}}
339+
2. 通过配置 `system:serviceaccounts:<namespace>` 组(`<namespace>` 是目标命名空间),仅将 PSP 绑定到整个命名空间。示例:
340+
341+
```yaml
342+
apiVersion: rbac.authorization.k8s.io/v1
343+
# This cluster role binding allows all pods in the "development" namespace to use the baseline PSP.
344+
kind: ClusterRoleBinding
345+
metadata:
346+
name: psp-baseline-namespaces
347+
roleRef:
348+
kind: ClusterRole
349+
name: psp-baseline
350+
apiGroup: rbac.authorization.k8s.io
351+
subjects:
352+
- kind: Group
353+
name: system:serviceaccounts:development
354+
apiGroup: rbac.authorization.k8s.io
355+
- kind: Group
356+
name: system:serviceaccounts:canary
357+
apiGroup: rbac.authorization.k8s.io
358+
```
359+
<!--
360+
361+
282362
### Troubleshooting
283363

284364
- The [Controller Manager](/docs/reference/command-line-tools-reference/kube-controller-manager/) must be run
@@ -1230,10 +1310,17 @@ By default, all safe sysctls are allowed.
12301310
## {{% heading "whatsnext" %}}
12311311

12321312
<!--
1313+
- See [PodSecurityPolicy Deprecation: Past, Present, and
1314+
Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/) to learn about
1315+
the future of pod security policy.
1316+
12331317
- See [Pod Security Standards](/docs/concepts/security/pod-security-standards/) for policy recommendations.
12341318

12351319
- Refer to [Pod Security Policy Reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritypolicy-v1beta1-policy) for the api details.
12361320
-->
1321+
- 参阅 [PodSecurityPolicy Deprecation: Past, Present, and
1322+
Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/),了解 Pod 安全策略的未来。
1323+
12371324
- 参阅[Pod 安全标准](/zh/docs/concepts/security/pod-security-standards/)
12381325
了解策略建议。
12391326
- 阅读 [Pod 安全策略参考](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritypolicy-v1beta1-policy)了解 API 细节。

content/zh/docs/concepts/policy/resource-quotas.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ Neither contention nor changes to quota will affect already created resources.
102102
<!--
103103
## Enabling Resource Quota
104104
105-
Resource Quota support is enabled by default for many Kubernetes distributions. It is
106-
enabled when the {{< glossary_tooltip text="API server" term_id="kube-apiserver" >}} `--enable-admission-plugins=` flag has `ResourceQuota` as
105+
Resource Quota support is enabled by default for many Kubernetes distributions. It is
106+
enabled when the {{< glossary_tooltip text="API server" term_id="kube-apiserver" >}}
107+
`--enable-admission-plugins=` flag has `ResourceQuota` as
107108
one of its arguments.
108109
-->
109110
## 启用资源配额
@@ -122,7 +123,9 @@ ResourceQuota in that namespace.
122123
<!--
123124
## Compute Resource Quota
124125
125-
You can limit the total sum of [compute resources](/docs/concepts/configuration/manage-resources-containers/) that can be requested in a given namespace.
126+
You can limit the total sum of
127+
[compute resources](/docs/concepts/configuration/manage-resources-containers/)
128+
that can be requested in a given namespace.
126129
-->
127130
## 计算资源配额
128131

@@ -249,7 +252,9 @@ In release 1.8, quota support for local ephemeral storage is added as an alpha f
249252

250253
{{< note >}}
251254
<!--
252-
When using a CRI container runtime, container logs will count against the ephemeral storage quota. This can result in the unexpected eviction of pods that have exhausted their storage quotas. Refer to [Logging Architecture](/docs/concepts/cluster-administration/logging/) for details.
255+
When using a CRI container runtime, container logs will count against the ephemeral storage quota.
256+
This can result in the unexpected eviction of pods that have exhausted their storage quotas.
257+
Refer to [Logging Architecture](/docs/concepts/cluster-administration/logging/) for details.
253258
-->
254259
如果所使用的是 CRI 容器运行时,容器日志会被计入临时存储配额。
255260
这可能会导致存储配额耗尽的 Pods 被意外地驱逐出节点。
@@ -382,7 +387,7 @@ Resources specified on the quota outside of the allowed set results in a validat
382387
| `NotTerminating` | Match pods where `.spec.activeDeadlineSeconds is nil` |
383388
| `BestEffort` | Match pods that have best effort quality of service. |
384389
| `NotBestEffort` | Match pods that do not have best effort quality of service. |
385-
| `PriorityClass` | Match pods that references the specified [priority class](/docs/concepts/configuration/pod-priority-preemption). |
390+
| `PriorityClass` | Match pods that references the specified [priority class](/docs/concepts/scheduling-eviction/pod-priority-preemption). |
386391
| `CrossNamespacePodAffinity` | Match pods that have cross-namespace pod [(anti)affinity terms](/docs/concepts/scheduling-eviction/assign-pod-node). |
387392
-->
388393
| 作用域 | 描述 |
@@ -391,7 +396,7 @@ Resources specified on the quota outside of the allowed set results in a validat
391396
| `NotTerminating` | 匹配所有 `spec.activeDeadlineSeconds` 是 nil 的 Pod。 |
392397
| `BestEffort` | 匹配所有 Qos 是 BestEffort 的 Pod。 |
393398
| `NotBestEffort` | 匹配所有 Qos 不是 BestEffort 的 Pod。 |
394-
| `PriorityClass` | 匹配所有引用了所指定的[优先级类](/zh/docs/concepts/configuration/pod-priority-preemption)的 Pods。 |
399+
| `PriorityClass` | 匹配所有引用了所指定的[优先级类](/zh/docs/concepts/scheduling-eviction/pod-priority-preemption)的 Pods。 |
395400
| `CrossNamespacePodAffinity` | 匹配那些设置了跨名字空间 [(反)亲和性条件](/zh/docs/concepts/scheduling-eviction/assign-pod-node)的 Pod。 |
396401

397402
<!--
@@ -476,11 +481,11 @@ specified.
476481
{{< feature-state for_k8s_version="v1.17" state="stable" >}}
477482

478483
<!--
479-
Pods can be created at a specific [priority](/docs/concepts/configuration/pod-priority-preemption/#pod-priority).
484+
Pods can be created at a specific [priority](/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority).
480485
You can control a pod's consumption of system resources based on a pod's priority, by using the `scopeSelector`
481486
field in the quota spec.
482487
-->
483-
Pod 可以创建为特定的[优先级](/zh/docs/concepts/configuration/pod-priority-preemption/#pod-priority)。
488+
Pod 可以创建为特定的[优先级](/zh/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority)。
484489
通过使用配额规约中的 `scopeSelector` 字段,用户可以根据 Pod 的优先级控制其系统资源消耗。
485490

486491
<!--
@@ -489,7 +494,8 @@ A quota is matched and consumed only if `scopeSelector` in the quota spec select
489494
仅当配额规范中的 `scopeSelector` 字段选择到某 Pod 时,配额机制才会匹配和计量 Pod 的资源消耗。
490495

491496
<!--
492-
When quota is scoped for priority class using `scopeSelector` field, quota object is restricted to track only following resources:
497+
When quota is scoped for priority class using `scopeSelector` field, quota object
498+
is restricted to track only following resources:
493499
-->
494500
如果配额对象通过 `scopeSelector` 字段设置其作用域为优先级类,则配额对象只能
495501
跟踪以下资源:
@@ -702,7 +708,7 @@ pods 0 10
702708
-->
703709
### 跨名字空间的 Pod 亲和性配额 {#cross-namespace-pod-affinity-quota}
704710
705-
{{< feature-state for_k8s_version="v1.21" state="alpha" >}}
711+
{{< feature-state for_k8s_version="v1.22" state="beta" >}}
706712
707713
<!--
708714
Operators can use `CrossNamespacePodAffinity` quota scope to limit which namespaces are allowed to
@@ -781,11 +787,11 @@ if the namespace where they are created have a resource quota object with
781787
或 `namespaceSelector` 的新 Pod。
782788

783789
<!--
784-
This feature is alpha and disabled by default. You can enable it by setting the
790+
This feature is beta and enabled by default. You can disable it using the
785791
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
786792
`PodAffinityNamespaceSelector` in both kube-apiserver and kube-scheduler.
787793
-->
788-
此功能特性处于 Alpha 阶段,默认被禁用。你可以通过为 kube-apiserver 和
794+
此功能特性处于 Beta 阶段,默认被禁用。你可以通过为 kube-apiserver 和
789795
kube-scheduler 设置
790796
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
791797
`PodAffinityNamespaceSelector` 来启用此特性。
@@ -868,7 +874,7 @@ kubectl create -f ./object-counts.yaml --namespace=myspace
868874
kubectl get quota --namespace=myspace
869875
```
870876

871-
```
877+
```none
872878
NAME AGE
873879
compute-resources 30s
874880
object-counts 32s
@@ -878,7 +884,7 @@ object-counts 32s
878884
kubectl describe quota compute-resources --namespace=myspace
879885
```
880886

881-
```
887+
```none
882888
Name: compute-resources
883889
Namespace: myspace
884890
Resource Used Hard
@@ -894,7 +900,7 @@ requests.nvidia.com/gpu 0 4
894900
kubectl describe quota object-counts --namespace=myspace
895901
```
896902

897-
```
903+
```none
898904
Name: object-counts
899905
Namespace: myspace
900906
Resource Used Hard
@@ -1034,7 +1040,7 @@ Then, create a resource quota object in the `kube-system` namespace:
10341040
kubectl apply -f https://k8s.io/examples/policy/priority-class-resourcequota.yaml -n kube-system
10351041
```
10361042

1037-
```
1043+
```none
10381044
resourcequota/pods-cluster-services created
10391045
```
10401046

0 commit comments

Comments
 (0)