@@ -24,7 +24,7 @@ This page describes how to build, configure, use, and monitor admission webhooks
24
24
<!--
25
25
## What are admission webhooks?
26
26
-->
27
- ## 什么是准入 Webhook?
27
+ ## 什么是准入 Webhook? {#what-are-admission-webhooks}
28
28
29
29
<!--
30
30
Admission webhooks are HTTP callbacks that receive admission requests and do
@@ -65,7 +65,7 @@ guides](/docs/reference/access-authn-authz/extensible-admission-controllers/#wri
65
65
instructions if you intend to write/deploy production-grade admission webhooks.
66
66
In the following, we describe how to quickly experiment with admission webhooks.
67
67
-->
68
- ### 尝试准入 Webhook
68
+ ### 尝试准入 Webhook {#experimenting-with-admission-webhooks}
69
69
70
70
准入 Webhook 本质上是集群控制平面的一部分。你应该非常谨慎地编写和部署它们。
71
71
如果你打算编写或者部署生产级准入 webhook,请阅读[ 用户指南] ( /zh-cn/docs/reference/access-authn-authz/extensible-admission-controllers/#write-an-admission-webhook-server ) 以获取相关说明。
@@ -92,7 +92,7 @@ In the following, we describe how to quickly experiment with admission webhooks.
92
92
<!--
93
93
### Write an admission webhook server
94
94
-->
95
- ### 编写一个准入 Webhook 服务器
95
+ ### 编写一个准入 Webhook 服务器 {#write-an-admission-webhook-server}
96
96
97
97
<!--
98
98
Please refer to the implementation of the [admission webhook server](https://github.com/kubernetes/kubernetes/blob/release-1.21/test/images/agnhost/webhook/main.go)
@@ -132,7 +132,7 @@ how to [authenticate API servers](#authenticate-apiservers).
132
132
<!--
133
133
### Deploy the admission webhook service
134
134
-->
135
- ### 部署准入 Webhook 服务
135
+ ### 部署准入 Webhook 服务 {#deploy-the-admission-webhook-service}
136
136
137
137
<!--
138
138
The webhook server in the e2e test is deployed in the Kubernetes cluster, via
@@ -157,7 +157,7 @@ your webhook configurations accordingly.
157
157
<!--
158
158
### Configure admission webhooks on the fly
159
159
-->
160
- ### 即时配置准入 Webhook
160
+ ### 即时配置准入 Webhook {#configure-admission-webhooks-on-the-fly}
161
161
162
162
<!--
163
163
You can dynamically configure what resources are subject to what admission
@@ -380,6 +380,9 @@ Of course you need to set up the webhook server to handle these authentication r
380
380
-->
381
381
当然,你需要设置 Webhook 服务器来处理这些身份验证请求。
382
382
383
+ <!-- ## Webhook request and response -->
384
+ ## Webhook 请求与响应 {#webhook-request-and-response}
385
+
383
386
<!--
384
387
### Request
385
388
@@ -1058,7 +1061,7 @@ The `matchPolicy` for an admission webhooks defaults to `Equivalent`.
1058
1061
<!--
1059
1062
# ## Contacting the webhook
1060
1063
-->
1061
- # ## 调用 Webhook
1064
+ # ## 调用 Webhook {#contacting-the-webhook}
1062
1065
1063
1066
<!--
1064
1067
Once the API server has determined a request should be sent to a webhook,
@@ -1423,7 +1426,7 @@ API 服务器提供了监视准入 Webhook 行为的方法。这些监视机制
1423
1426
<!--
1424
1427
# ## Mutating webhook auditing annotations
1425
1428
-->
1426
- # ## Mutating Webhook 审计注解
1429
+ # ## Mutating Webhook 审计注解 {#mutating-webhook-auditing-annotations}
1427
1430
1428
1431
<!--
1429
1432
Sometimes it's useful to know which mutating webhook mutated the object in a API request, and what change did the
@@ -1574,7 +1577,7 @@ The audit level of a event determines which annotations get recorded:
1574
1577
<!--
1575
1578
# ## Admission webhook metrics
1576
1579
-->
1577
- # ## 准入 Webhook 度量值
1580
+ # ## 准入 Webhook 度量值 {#admission-webhook-metrics}
1578
1581
1579
1582
<!--
1580
1583
The API server exposes Prometheus metrics from the `/metrics` endpoint, which can be used for monitoring and
@@ -1586,7 +1589,7 @@ API 服务器从 `/metrics` 端点公开 Prometheus 指标,这些指标可用
1586
1589
<!--
1587
1590
# ### API server admission webhook rejection count
1588
1591
-->
1589
- # ### apiserver 准入 Webhook 拒绝次数
1592
+ # ### apiserver 准入 Webhook 拒绝次数 {#api-server-admission-webhook-rejection-count}
1590
1593
1591
1594
<!--
1592
1595
Sometimes it's useful to know which admission webhooks are frequently rejecting API requests, and the
@@ -1645,7 +1648,7 @@ apiserver_admission_webhook_rejection_count{error_type="no_error",name="deny-unw
1645
1648
1646
1649
### Idempotence
1647
1650
-->
1648
- ## 最佳实践和警告
1651
+ ## 最佳实践和警告 {#best-practices-and-warnings}
1649
1652
1650
1653
### 幂等性 {#idempotence}
1651
1654
@@ -1670,7 +1673,7 @@ the initial application.
1670
1673
1671
1674
In the cases above, the webhook can be safely reinvoked, or admit an object that already has the fields set.
1672
1675
-->
1673
- #### 幂等 mutating admission Webhook 的示例:
1676
+ #### 幂等 mutating admission Webhook 的示例: {#example-of-idempotent-mutating-admission-webhooks}
1674
1677
1675
1678
1. 对于 `CREATE` Pod 请求,将 Pod 的字段 `.spec.securityContext.runAsNonRoot`
1676
1679
设置为 true,以实施安全最佳实践。
@@ -1684,7 +1687,7 @@ In the cases above, the webhook can be safely reinvoked, or admit an object that
1684
1687
<!--
1685
1688
#### Example of non-idempotent mutating admission webhooks:
1686
1689
-->
1687
- #### 非幂等 mutating admission Webhook 的示例:
1690
+ #### 非幂等 mutating admission Webhook 的示例: {#example-of-non-idempotent-mutating-admission-webhooks}
1688
1691
1689
1692
<!--
1690
1693
1. For a `CREATE` pod request, inject a sidecar container with name `foo-sidecar`
@@ -1731,7 +1734,7 @@ to `Equivalent`. It is also recommended that admission webhooks should prefer re
1731
1734
Failure to intercept all versions of an object can result in admission policies not being enforced for requests in certain
1732
1735
versions. See [Matching requests: matchPolicy](#matching-requests-matchpolicy) for examples.
1733
1736
-->
1734
- ### 拦截对象的所有版本
1737
+ ### 拦截对象的所有版本 {#intercepting-all-versions-of-an-object}
1735
1738
1736
1739
建议通过将 `.webhooks[].matchPolicy` 设置为 `Equivalent`,
1737
1740
以确保准入 Webhooks 始终拦截对象的所有版本。
@@ -1768,7 +1771,7 @@ For example, a mutating admission webhook is configured to inject a sidecar cont
1768
1771
that a container with name "foo-sidecar" with the expected configuration exists in the to-be-created object.
1769
1772
-->
1770
1773
1771
- ### 确保看到对象的最终状态
1774
+ ### 确保看到对象的最终状态 {#guaranteeing-the-final-state-of-the-object-is-seen}
1772
1775
1773
1776
如果某准入 Webhook 需要保证自己能够看到对象的最终状态以实施策略,
1774
1777
则应该使用一个验证性质的 webhook,
@@ -1795,7 +1798,7 @@ get rejected by the existing webhook server since the `"env"` label is unset, an
1795
1798
1796
1799
It is recommended to exclude the namespace where your webhook is running with a [namespaceSelector](#matching-requests-namespaceselector).
1797
1800
-->
1798
- ### 避免自托管的 Webhooks 中出现死锁
1801
+ ### 避免自托管的 Webhooks 中出现死锁 {#avoiding-deadlocks-in-self-hosted-webhooks}
1799
1802
1800
1803
如果集群内的 Webhook 配置能够拦截启动其自己的 Pod 所需的资源,
1801
1804
则该 Webhook 可能导致其自身部署时发生死锁。
@@ -1834,7 +1837,7 @@ set to `NoneOnDryRun`. See [Side effects](#side-effects) for more detail.
1834
1837
<!--
1835
1838
### Avoiding operating on the kube-system namespace
1836
1839
-->
1837
- ### 避免对 kube-system 名字空间进行操作
1840
+ ### 避免对 kube-system 名字空间进行操作 {#avoiding-operating-on-the-kube-system-namespace}
1838
1841
1839
1842
<!--
1840
1843
The `kube-system` namespace contains objects created by the Kubernetes system,
0 commit comments