@@ -91,9 +91,11 @@ Kubernetes 区分用户账号和服务账号的概念,主要基于以下原因
91
91
onboard human users makes it easier for workloads to following the principle of
92
92
least privilege.
93
93
-->
94
- - 通常情况下,集群的用户账号可能会从企业数据库进行同步,创建新用户需要特殊权限,并且涉及到复杂的业务流程。
94
+ - 通常情况下,集群的用户账号可能会从企业数据库进行同步,
95
+ 创建新用户需要特殊权限,并且涉及到复杂的业务流程。
95
96
服务账号创建有意做得更轻量,允许集群用户为了具体的任务按需创建服务账号。
96
- 将 ServiceAccount 的创建与新用户注册的步骤分离开来,使工作负载更易于遵从权限最小化原则。
97
+ 将 ServiceAccount 的创建与新用户注册的步骤分离开来,
98
+ 使工作负载更易于遵从权限最小化原则。
97
99
<!--
98
100
- Auditing considerations for humans and service accounts may differ; the separation
99
101
makes that easier to achieve.
@@ -186,7 +188,8 @@ There is no specific mechanism to invalidate a token issued via TokenRequest. If
186
188
trust a bound service account token for a Pod, you can delete that Pod. Deleting a Pod expires
187
189
its bound service account tokens.
188
190
-->
189
- 没有特定的机制可以使通过 TokenRequest 签发的令牌无效。如果你不再信任为某个 Pod 绑定的服务账号令牌,
191
+ 没有特定的机制可以使通过 TokenRequest 签发的令牌无效。
192
+ 如果你不再信任为某个 Pod 绑定的服务账号令牌,
190
193
你可以删除该 Pod。删除 Pod 将使其绑定的服务账号令牌过期。
191
194
{{< /note >}}
192
195
@@ -211,9 +214,10 @@ The tokens obtained using this method have bounded lifetimes, and are automatica
211
214
invalidated when the Pod they are mounted into is deleted.
212
215
-->
213
216
在包括 Kubernetes v{{< skew currentVersion >}} 在内最近的几个版本中,使用
214
- [TokenRequest](/zh-cn/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) API
215
- [直接获得](#bound-service-account-token-volume) API 凭据,并使用投射卷挂载到 Pod 中。
216
- 使用这种方法获得的令牌具有绑定的生命周期,当挂载的 Pod 被删除时这些令牌将自动失效。
217
+ [TokenRequest](/zh-cn/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
218
+ API [直接获得](#bound-service-account-token-volume) API 凭据,
219
+ 并使用投射卷挂载到 Pod 中。使用这种方法获得的令牌具有绑定的生命周期,
220
+ 当挂载的 Pod 被删除时这些令牌将自动失效。
217
221
218
222
<!--
219
223
You can still [manually create](/docs/tasks/configure-pod-container/configure-service-account/#manually-create-an-api-token-for-a-serviceaccount) a Secret to hold a service account token; for example, if you need a token that never expires.
@@ -223,7 +227,8 @@ Once you manually create a Secret and link it to a ServiceAccount, the Kubernete
223
227
你仍然可以[手动创建](/zh-cn/docs/tasks/configure-pod-container/configure-service-account/#manually-create-an-api-token-for-a-serviceaccount)
224
228
Secret 来保存服务账号令牌;例如在你需要一个永不过期的令牌的时候。
225
229
226
- 一旦你手动创建一个 Secret 并将其关联到 ServiceAccount,Kubernetes 控制平面就会自动将令牌填充到该 Secret 中。
230
+ 一旦你手动创建一个 Secret 并将其关联到 ServiceAccount,
231
+ Kubernetes 控制平面就会自动将令牌填充到该 Secret 中。
227
232
228
233
{{< note >}}
229
234
<!--
@@ -239,6 +244,15 @@ to obtain short-lived API access tokens is recommended instead.
239
244
<!--
240
245
# # Control plane details
241
246
247
+ A ServiceAccount controller manages the ServiceAccounts inside namespaces, and
248
+ ensures a ServiceAccount named "default" exists in every active namespace.
249
+ -->
250
+ # # 控制平面细节 {#control-plane-details}
251
+
252
+ ServiceAccount 控制器管理名字空间内的 ServiceAccount,
253
+ 并确保每个活跃的名字空间中都存在名为 `default` 的 ServiceAccount。
254
+
255
+ <!--
242
256
# ## Token controller
243
257
244
258
The service account token controller runs as part of `kube-controller-manager`.
@@ -251,16 +265,14 @@ This controller acts asynchronously. It:
251
265
- watches for Secret deletion and removes a reference from the corresponding
252
266
ServiceAccount if needed.
253
267
-->
254
- # # 控制平面细节 {#control-plane-details}
255
-
256
268
# ## 令牌控制器 {#token-controller}
257
269
258
270
服务账号令牌控制器作为 `kube-controller-manager` 的一部分运行,以异步的形式工作。
259
271
其职责包括:
260
272
261
273
- 监测 ServiceAccount 的删除并删除所有相应的服务账号令牌 Secret。
262
- - 监测服务账号令牌 Secret 的添加,保证相应的 ServiceAccount 存在,如有需要,
263
- 向 Secret 中添加令牌。
274
+ - 监测服务账号令牌 Secret 的添加,保证相应的 ServiceAccount 存在,
275
+ 如有需要, 向 Secret 中添加令牌。
264
276
- 监测服务账号令牌 Secret 的删除,如有需要,从相应的 ServiceAccount 中移除引用。
265
277
266
278
<!--
@@ -271,9 +283,10 @@ Similarly, you must pass the corresponding public key to the `kube-apiserver`
271
283
using the `--service-account-key-file` flag. The public key will be used to
272
284
verify the tokens during authentication.
273
285
-->
274
- 你必须通过 `--service-account-private-key-file` 标志为 `kube-controller-manager`
275
- 的令牌控制器传入一个服务账号私钥文件。该私钥用于为所生成的服务账号令牌签名。
276
- 同样地,你需要通过 `--service-account-key-file` 标志将对应的公钥通知给
286
+ 你必须通过 `--service-account-private-key-file` 标志为
287
+ ` kube-controller-manager` 的令牌控制器传入一个服务账号私钥文件。
288
+ 该私钥用于为所生成的服务账号令牌签名。同样地,你需要通过
289
+ ` --service-account-key-file` 标志将对应的公钥通知给
277
290
kube-apiserver。公钥用于在身份认证过程中校验令牌。
278
291
279
292
<!--
@@ -345,7 +358,8 @@ If you want to use the TokenRequest API from `kubectl`, see
345
358
你使用 ServiceAccount 的
346
359
[TokenRequest](/zh-cn/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
347
360
子资源为该 ServiceAccount 获取有时间限制的令牌。
348
- 你不需要调用它来获取在容器中使用的 API 令牌,因为 kubelet 使用 **投射卷** 对此进行了设置。
361
+ 你不需要调用它来获取在容器中使用的 API 令牌,
362
+ 因为 kubelet 使用**投射卷**对此进行了设置。
349
363
350
364
如果你想要从 `kubectl` 使用 TokenRequest API,
351
365
请参阅[为 ServiceAccount 手动创建 API 令牌](/zh-cn/docs/tasks/configure-pod-container/configure-service-account/#manually-create-an-api-token-for-a-serviceaccount)。
@@ -441,8 +455,9 @@ updates that Secret with that generated token data.
441
455
Here is a sample manifest for such a Secret :
442
456
-->
443
457
要为 ServiceAccount 创建一个不过期、持久化的 API 令牌,
444
- 请创建一个类型为 `kubernetes.io/service-account-token` 的 Secret,附带引用 ServiceAccount 的注解。
445
- 控制平面随后生成一个长久的令牌,并使用生成的令牌数据更新该 Secret。
458
+ 请创建一个类型为 `kubernetes.io/service-account-token` 的 Secret,
459
+ 附带引用 ServiceAccount 的注解。控制平面随后生成一个长久的令牌,
460
+ 并使用生成的令牌数据更新该 Secret。
446
461
447
462
以下是此类 Secret 的示例清单:
448
463
@@ -491,7 +506,7 @@ token: ...
491
506
If you launch a new Pod into the `examplens` namespace, it can use the `myserviceaccount`
492
507
service-account-token Secret that you just created.
493
508
-->
494
- 如果你在 `examplens` 名字空间中启动新的 Pod,可以使用你刚刚创建的
509
+ 如果你在 `examplens` 名字空间中启动一个新的 Pod,它可以使用你刚刚创建的
495
510
`myserviceaccount` service-account-token Secret。
496
511
497
512
<!--
@@ -588,60 +603,6 @@ If you created a namespace `examplens` to experiment with, you can remove it:
588
603
kubectl delete namespace examplens
589
604
` ` `
590
605
591
- <!--
592
- # # Control plane details
593
-
594
- # ## ServiceAccount controller
595
-
596
- A ServiceAccount controller manages the ServiceAccounts inside namespaces, and
597
- ensures a ServiceAccount named "default" exists in every active namespace.
598
- -->
599
- # # 控制平面细节 {#control-plane-details}
600
-
601
- # ## ServiceAccount 控制器 {#serviceaccount-controller}
602
-
603
- ServiceAccount 控制器管理名字空间内的 ServiceAccount,并确保每个活跃的名字空间中都存在名为
604
- “default” 的 ServiceAccount。
605
-
606
- <!--
607
- # ## Token controller
608
-
609
- The service account token controller runs as part of `kube-controller-manager`.
610
- This controller acts asynchronously. It :
611
-
612
- - watches for ServiceAccount creation and creates a corresponding
613
- ServiceAccount token Secret to allow API access.
614
- - watches for ServiceAccount deletion and deletes all corresponding ServiceAccount
615
- token Secrets.
616
- - watches for ServiceAccount token Secret addition, and ensures the referenced
617
- ServiceAccount exists, and adds a token to the Secret if needed.
618
- - watches for Secret deletion and removes a reference from the corresponding
619
- ServiceAccount if needed.
620
- -->
621
- # ## 令牌控制器
622
-
623
- 服务账号令牌控制器作为 `kube-controller-manager` 的一部分运行,以异步的形式工作。
624
- 其职责包括:
625
-
626
- - 监测 ServiceAccount 的创建并创建相应的服务账号令牌 Secret 以允许 API 访问。
627
- - 监测 ServiceAccount 的删除并删除所有相应的服务账号令牌 Secret。
628
- - 监测服务账号令牌 Secret 的添加,保证相应的 ServiceAccount 存在,如有需要,
629
- 向 Secret 中添加令牌。
630
- - 监测 Secret 的删除,如有需要,从相应的 ServiceAccount 中移除引用。
631
-
632
- <!--
633
- You must pass a service account private key file to the token controller in
634
- the `kube-controller-manager` using the `--service-account-private-key-file`
635
- flag. The private key is used to sign generated service account tokens.
636
- Similarly, you must pass the corresponding public key to the `kube-apiserver`
637
- using the `--service-account-key-file` flag. The public key will be used to
638
- verify the tokens during authentication.
639
- -->
640
- 你必须通过 `--service-account-private-key-file` 标志为 `kube-controller-manager`
641
- 的令牌控制器传入一个服务账号私钥文件。该私钥用于为所生成的服务账号令牌签名。
642
- 同样地,你需要通过 `--service-account-key-file` 标志将对应的公钥通知给
643
- kube-apiserver。公钥用于在身份认证过程中校验令牌。
644
-
645
606
# # {{% heading "whatsnext" %}}
646
607
647
608
<!--
0 commit comments