From 1cf774a05e21cbc7dfdd18ecaafa2c1ec2408729 Mon Sep 17 00:00:00 2001 From: "wei.wang" Date: Tue, 24 May 2022 02:26:02 +0800 Subject: [PATCH] [zh]Update content/zh/docs/reference/access-authn-authz/admission-controllers.md --- .../admission-controllers.md | 2 +- .../admission-controllers.md | 200 ++++++++++-------- 2 files changed, 113 insertions(+), 89 deletions(-) diff --git a/content/en/docs/reference/access-authn-authz/admission-controllers.md b/content/en/docs/reference/access-authn-authz/admission-controllers.md index e2a3d63e62..1e9f1a3298 100644 --- a/content/en/docs/reference/access-authn-authz/admission-controllers.md +++ b/content/en/docs/reference/access-authn-authz/admission-controllers.md @@ -766,7 +766,7 @@ We strongly recommend using this admission controller if you intend to make use The `StorageObjectInUseProtection` plugin adds the `kubernetes.io/pvc-protection` or `kubernetes.io/pv-protection` finalizers to newly created Persistent Volume Claims (PVCs) or Persistent Volumes (PV). In case a user deletes a PVC or PV the PVC or PV is not removed until the finalizer is removed -from the PVC or PV by PVC or PV Protection Controller. +from the PVC or PV by PVC or PV Protection Controller. Refer to the [Storage Object in Use Protection](/docs/concepts/storage/persistent-volumes/#storage-object-in-use-protection) for more detailed information. diff --git a/content/zh/docs/reference/access-authn-authz/admission-controllers.md b/content/zh/docs/reference/access-authn-authz/admission-controllers.md index 7b2457eb00..b9b584b3c1 100644 --- a/content/zh/docs/reference/access-authn-authz/admission-controllers.md +++ b/content/zh/docs/reference/access-authn-authz/admission-controllers.md @@ -38,8 +38,8 @@ is authenticated and authorized. The controllers consist of the `kube-apiserver` binary, and may only be configured by the cluster administrator. In that list, there are two special controllers: MutatingAdmissionWebhook and ValidatingAdmissionWebhook. These execute the -mutating and validating (respectively) [admission control -webhooks](/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks) +mutating and validating (respectively) +[admission control webhooks](/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks) which are configured in the API. --> 准入控制器是一段代码,它会在请求通过认证和授权之后、对象被持久化之前拦截到达 API @@ -172,17 +172,16 @@ CertificateApproval, CertificateSigning, CertificateSubjectRestriction, DefaultI ## 每个准入控制器的作用是什么? -### AlwaysAdmit {#alwaysadmit} +### AlwaysAdmit {#alwaysadmit} {{< feature-state for_k8s_version="v1.13" state="deprecated" >}} + 该准入控制器会允许所有的 pod 接入集群。已废弃,因为它的行为根本就和没有准入控制器一样。 ### AlwaysDeny {#alwaysdeny} @@ -214,17 +213,17 @@ required. ### CertificateApproval 此准入控制器获取“审批” CertificateSigningRequest 资源的请求并执行额外的授权检查, 以确保审批请求的用户有权限审批 `spec.signerName` 请求 CertificateSigningRequest 资源的证书请求。 有关对证书签名请求资源执行不同操作所需权限的详细信息, @@ -233,26 +232,26 @@ to perform different actions on CertificateSigningRequest resources. ### CertificateSigning 此准入控制器获取 CertificateSigningRequest 资源的 `status.certificate` 字段更新请求并执行额外的授权检查, 以确保签发证书的用户有权限为 `spec.signerName` 请求 CertificateSigningRequest 资源的证书请求`签发`证书。 有关对证书签名请求资源执行不同操作所需权限的详细信息, 请参阅[证书签名请求](/zh/docs/reference/access-authn-authz/certificate-signing-requests/) -### CertificateSubjectRestrictions +### CertificateSubjectRestrictions {#certificatesubjectrestrictions} 此准入控制器获取具有 `kubernetes.io/kube-apiserver-client` 的 `spec.signerName` 的 CertificateSigningRequest 资源创建请求, @@ -324,7 +323,7 @@ storage classes and how to mark a storage class as default. * 启用 `EventRateLimit` 准入控制器; * 从文件中引用 `EventRateLimit` 配置文件,并提供给 API 服务器命令的 @@ -585,7 +584,8 @@ ImagePolicyWebhook 的配置文件必须引用 要求后端使用 TLS 进行通信。 kubeconfig 文件的 `cluster` 字段需要指向远端服务,user 字段需要包含已返回的授权者。 @@ -632,12 +632,15 @@ For additional HTTP configuration, refer to the 文档。 #### 请求载荷 当面对一个准入决策时,API 服务器发送一个描述操作的 JSON 序列化的 `imagepolicy.k8s.io/v1alpha1` `ImageReview` 对象。 @@ -645,13 +648,20 @@ When faced with an admission decision, the API Server POSTs a JSON serialized `i Pod 注解。 +{{ note }} 注意,Webhook API 对象与其他 Kubernetes API 对象一样受制于相同的版本控制兼容性规则。 实现者应该知道对 alpha 对象的更宽松的兼容性,并检查请求的 "apiVersion" 字段, 以确保正确的反序列化。 此外,API 服务器必须启用 `imagepolicy.k8s.io/v1alpha1` API 扩展组 (`--runtime-config=imagepolicy.k8s.io/v1alpha1=true`)。 +{{ /note }} 远程服务将填充请求的 `ImageReviewStatus` 字段,并返回允许或不允许访问的响应。 响应体的 `spec` 字段会被忽略,并且可以省略。一个允许访问应答会返回: @@ -712,10 +724,10 @@ To disallow access, the service would return: ``` -更多的文档,请参阅 `imagepolicy.v1alpha1` API 对象和 -`plugin/pkg/admission/imagepolicy/admission.go`。 +更多的文档,请参阅 [`imagepolicy.v1alpha1` API](/zh/docs/reference/config-api/imagepolicy.v1alpha1/)。 一个 Pod 中匹配 `*.image-policy.k8s.io/*` 的注解都会被发送给 Webhook。 这样做使得了解后端镜像策略的用户可以向它发送额外的信息,并为不同的后端实现 @@ -735,9 +750,9 @@ Examples of information you might put here are: 你可以在这里输入的信息有: * 在紧急情况下,请求 "break glass" 覆盖一个策略。 * 从一个记录了 break-glass 的请求的 ticket 系统得到的一个 ticket 号码。 @@ -786,7 +801,7 @@ for more details. 和 [LimitRange 例子](/zh/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/) 以了解更多细节。 -### MutatingAdmissionWebhook {#mutatingadmissionwebhook} +### MutatingAdmissionWebhook {#mutatingadmissionwebhook} 如果你禁用了 MutatingAdmissionWebhook,那么还必须使用 `--runtime-config` 标志禁止 -`admissionregistration.k8s.io/v1` 组/版本中的 `MutatingWebhookConfiguration` -对象(版本 >=1.9 时,这两个对象都是默认启用的)。 +`admissionregistration.k8s.io/v1` 组/版本中的 `MutatingWebhookConfiguration`, +这两个对象都是默认启用的。 * 当用户尝试创建的对象与返回的对象不同时,用户可能会感到困惑。 * 当它们回读的对象与尝试创建的对象不同,内建的控制环可能会出问题。 @@ -909,8 +923,8 @@ and enforces kubelet modification of labels under the `kubernetes.io/` or `k8s.i * **防止** kubelet 添加/删除/更新带有 `node-restriction.kubernetes.io/` 前缀的标签。 @@ -932,7 +946,8 @@ and kubelets will not be allowed to modify labels with that prefix. kubelet 保留 `kubernetes.io` 或 `k8s.io` 前缀的所有标签,并且将来可能会被 `NodeRestriction` 准入插件允许或禁止。 @@ -959,12 +974,14 @@ subresource of the referenced *owner* can change it. {{< feature-state for_k8s_version="v1.24" state="stable" >}} 该准入控制器检查传入的 `PersistentVolumeClaim` 调整大小请求,对其执行额外的验证操作。 该准入控制器会自动将区(region)或区域(zone)标签附加到由云提供商(如 GCE、AWS) @@ -1014,7 +1031,7 @@ Starting from 1.11, this admission controller is disabled by default. 如果准入控制器不支持为 PersistentVolumes 自动添加标签,那你可能需要手动添加标签, 以防止 Pod 挂载其他区域的卷。 PersistentVolumeLabel 已被废弃,标记持久卷已由 -[云管理控制器](/zh/docs/tasks/administer-cluster/running-cloud-controller/)接管。 +{{< glossary_tooltip text="云管理控制器" term_id="cloud-controller-manager" >}}接管。 从 1.11 开始,默认情况下禁用此准入控制器。 ### PodNodeSelector {#podnodeselector} @@ -1022,13 +1039,14 @@ PersistentVolumeLabel 已被废弃,标记持久卷已由 {{< feature-state for_k8s_version="v1.5" state="alpha" >}} 该准入控制器通过读取名字空间注解和全局配置,来为名字空间中可以使用的节点选择器 设置默认值并实施限制。 基于提供给 API 服务器命令行标志 `--admission-control-config-file` 的文件名, 从文件中引用 `PodNodeSelector` 配置文件: @@ -1065,7 +1084,8 @@ plugins: #### 配置注解格式 @@ -1090,13 +1110,14 @@ This admission controller has the following behavior: 该准入控制器行为如下: 1. 如果 `Namespace` 的注解带有键 `scheduler.alpha.kubernetes.io/node-selector`, 则将其值用作节点选择算符。 @@ -1158,7 +1179,8 @@ for more information. {{< feature-state for_k8s_version="v1.7" state="alpha" >}} ### 优先级 {#priority} @@ -1212,9 +1236,10 @@ The priority admission controller uses the `priorityClassName` field and populat ### ResourceQuota {#resourcequota} 该准入控制器会监测传入的请求,并确保它不违反任何一个 `Namespace` 中的 `ResourceQuota` 对象中枚举出来的约束。 @@ -1243,10 +1268,6 @@ For Pods that have a RuntimeClass configured and selected in their `.spec`, this admission controller sets `.spec.overhead` in the Pod based on the value defined in the corresponding RuntimeClass. -{{< note >}} -The `.spec.overhead` field for Pod and the `.overhead` field for RuntimeClass are both in beta. If you do not enable the `PodOverhead` feature gate, all Pods are treated as if `.spec.overhead` is unset. -{{< /note >}} - See also [Pod Overhead](/docs/concepts/scheduling-eviction/pod-overhead/) for more information. --> @@ -1260,11 +1281,6 @@ for more information. 对于配置了 RuntimeClass 并在其 `.spec` 中选定 RuntimeClass 的 Pod, 此准入控制器会根据相应 RuntimeClass 中定义的值为 Pod 设置 `.spec.overhead`。 -{{< note >}} -Pod 的 `.spec.overhead` 字段和 RuntimeClass 的 `.overhead` 字段均为处于 beta 版本。 -如果你未启用 `PodOverhead` 特性门控,则所有 Pod 均被视为未设置 `.spec.overhead`。 -{{< /note >}} - 详情请参见 [Pod 开销](/zh/docs/concepts/scheduling-eviction/pod-overhead/)。 ### SecurityContextDeny {#securitycontextdeny} @@ -1299,7 +1315,8 @@ pod privileges. 此准入控制器实现了 [ServiceAccount](/zh/docs/tasks/configure-pod-container/configure-service-account/) @@ -1325,12 +1342,15 @@ PVC/PV 不会被删除。 有关更多详细信息,请参考 [保护使用中的存储对象](/zh/docs/concepts/storage/persistent-volumes/#storage-object-in-use-protection)。 -### TaintNodesByCondition {#taintnodesbycondition} +### TaintNodesByCondition {#taintnodesbycondition} {{< feature-state for_k8s_version="v1.17" state="stable" >}} 该准入控制器为新创建的节点添加 `NotReady` 和 `NoSchedule` {{< glossary_tooltip text="污点" term_id="taint" >}}。 @@ -1372,7 +1392,11 @@ versions 1.9 and later). ## 有推荐的准入控制器吗?