Skip to content

Commit ee00c0c

Browse files
authored
Merge pull request #44364 from windsonsea/conacc
[zh] Add translations to configure-service-account.md
2 parents 60f4e0a + e6c8b04 commit ee00c0c

File tree

1 file changed

+94
-7
lines changed

1 file changed

+94
-7
lines changed

content/zh-cn/docs/tasks/configure-pod-container/configure-service-account.md

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 120
55
---
66
<!--
77
reviewers:
8-
- bprashanth
8+
- enj
99
- liggitt
1010
- thockin
1111
title: Configure Service Accounts for Pods
@@ -72,8 +72,8 @@ You can fetch the details for a Pod you have created. For example:
7272
ServiceAccount。
7373

7474
每个 Kubernetes 名字空间至少包含一个 ServiceAccount:也就是该名字空间的默认服务账号,
75-
名为 `default`。如果你在创建 Pod 时没有指定 ServiceAccount,Kubernetes 会自动将该名字空间中
76-
名为 `default` 的 ServiceAccount 分配给该 Pod。
75+
名为 `default`。如果你在创建 Pod 时没有指定 ServiceAccount,Kubernetes 会自动将该名字空间中名为
76+
`default` 的 ServiceAccount 分配给该 Pod。
7777

7878
你可以检视你刚刚创建的 Pod 的细节。例如:
7979

@@ -132,6 +132,7 @@ metadata:
132132
automountServiceAccountToken: false
133133
...
134134
```
135+
135136
<!--
136137
You can also opt out of automounting API credentials for a particular Pod:
137138
-->
@@ -202,7 +203,7 @@ The name of a ServiceAccount object must be a valid
202203
[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
203204
-->
204205
ServiceAccount 对象的名字必须是一个有效的
205-
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
206+
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)
206207

207208
<!--
208209
If you get a complete dump of the service account object, like this:
@@ -284,7 +285,7 @@ You can get a time-limited API token for that ServiceAccount using `kubectl`:
284285
## 手动为 ServiceAccount 创建 API 令牌 {#manually-create-an-api-token-for-a-serviceaccount}
285286

286287
假设你已经有了一个前文所提到的名为 "build-robot" 的服务账号。
287-
你可以使用 `kubectl` 为该 ServiceAccount 获得一个时间上受限的 API 令牌:
288+
你可以使用 `kubectl` 为该 ServiceAccount 获得一个有时限的 API 令牌:
288289

289290
```shell
290291
kubectl create token build-robot
@@ -300,6 +301,24 @@ token might be shorter, or could even be longer).
300301
你可以使用 `kubectl create token` 命令的 `--duration` 参数来请求特定的令牌有效期
301302
(实际签发的令牌的有效期可能会稍短一些,也可能会稍长一些)。
302303

304+
<!--
305+
When the `ServiceAccountTokenNodeBinding` and `ServiceAccountTokenNodeBindingValidation`
306+
features are enabled and the `KUBECTL_NODE_BOUND_TOKENS` enviroment variable is set to `true`,
307+
it is possible to create a service account token that is directly bound to a `Node`:
308+
-->
309+
当启用了 `ServiceAccountTokenNodeBinding` 和 `ServiceAccountTokenNodeBindingValidation`
310+
特性,并将 `KUBECTL_NODE_BOUND_TOKENS` 环境变量设置为 `true` 时,
311+
可以创建一个直接绑定到 `Node` 的服务账号令牌:
312+
313+
```shell
314+
KUBECTL_NODE_BOUND_TOKENS=true kubectl create token build-robot --bound-object-kind Node --bound-object-name node-001 --bound-object-uid 123...456
315+
```
316+
317+
<!--
318+
The token will be valid until it expires or either the assocaited `Node` or service account are deleted.
319+
-->
320+
此令牌将有效直至其过期或关联的 `Node` 或服务账户被删除。
321+
303322
{{< note >}}
304323
<!--
305324
Versions of Kubernetes before v1.22 automatically created long term credentials for
@@ -660,8 +679,76 @@ You can configure this behavior for the `spec` of a Pod using a
660679
[projected volume](/docs/concepts/storage/volumes/#projected) type called
661680
`ServiceAccountToken`.
662681
-->
663-
你可以使用类型为 `ServiceAccountToken` 的[投射卷](/zh-cn/docs/concepts/storage/volumes/#projected)
664-
来为 Pod 的 `spec` 配置此行为。
682+
你可以使用类型为 `ServiceAccountToken` 的[投射卷](/zh-cn/docs/concepts/storage/volumes/#projected)来为
683+
Pod 的 `spec` 配置此行为。
684+
685+
<!--
686+
The token from this projected volume is a {{<glossary_tooltip term_id="jwt" text="JSON Web Token">}} (JWT).
687+
The JSON payload of this token follows a well defined schema - an example payload for a pod bound token:
688+
-->
689+
来自此投射卷的令牌是一个 {{<glossary_tooltip term_id="jwt" text="JSON Web Token">}} (JWT)。
690+
此令牌的 JSON 载荷遵循明确定义的模式,绑定到 Pod 的令牌的示例载荷如下:
691+
692+
<!--
693+
```yaml
694+
{
695+
"aud": [ # matches the requested audiences, or the API server's default audiences when none are explicitly requested
696+
"https://kubernetes.default.svc"
697+
],
698+
"exp": 1731613413,
699+
"iat": 1700077413,
700+
"iss": "https://kubernetes.default.svc", # matches the first value passed to the --service-account-issuer flag
701+
"jti": "ea28ed49-2e11-4280-9ec5-bc3d1d84661a", # ServiceAccountTokenJTI feature must be enabled for the claim to be present
702+
"kubernetes.io": {
703+
"namespace": "kube-system",
704+
"node": { # ServiceAccountTokenPodNodeInfo feature must be enabled for the API server to add this node reference claim
705+
"name": "127.0.0.1",
706+
"uid": "58456cb0-dd00-45ed-b797-5578fdceaced"
707+
},
708+
"pod": {
709+
"name": "coredns-69cbfb9798-jv9gn",
710+
"uid": "778a530c-b3f4-47c0-9cd5-ab018fb64f33"
711+
},
712+
"serviceaccount": {
713+
"name": "coredns",
714+
"uid": "a087d5a0-e1dd-43ec-93ac-f13d89cd13af"
715+
},
716+
"warnafter": 1700081020
717+
},
718+
"nbf": 1700077413,
719+
"sub": "system:serviceaccount:kube-system:coredns"
720+
}
721+
```
722+
-->
723+
```yaml
724+
{
725+
"aud": [ # 匹配请求的受众,或当没有明确请求时匹配 API 服务器的默认受众
726+
"https://kubernetes.default.svc"
727+
],
728+
"exp": 1731613413,
729+
"iat": 1700077413,
730+
"iss": "https://kubernetes.default.svc", # 匹配传递到 --service-account-issuer 标志的第一个值
731+
"jti": "ea28ed49-2e11-4280-9ec5-bc3d1d84661a", # ServiceAccountTokenJTI 特性必须被启用才能出现此申领
732+
"kubernetes.io": {
733+
"namespace": "kube-system",
734+
"node": { # ServiceAccountTokenPodNodeInfo 特性必须被启用,API 服务器才会添加此节点引用申领
735+
"name": "127.0.0.1",
736+
"uid": "58456cb0-dd00-45ed-b797-5578fdceaced"
737+
},
738+
"pod": {
739+
"name": "coredns-69cbfb9798-jv9gn",
740+
"uid": "778a530c-b3f4-47c0-9cd5-ab018fb64f33"
741+
},
742+
"serviceaccount": {
743+
"name": "coredns",
744+
"uid": "a087d5a0-e1dd-43ec-93ac-f13d89cd13af"
745+
},
746+
"warnafter": 1700081020
747+
},
748+
"nbf": 1700077413,
749+
"sub": "system:serviceaccount:kube-system:coredns"
750+
}
751+
```
665752

666753
<!--
667754
### Launch a Pod using service account token projection

0 commit comments

Comments
 (0)