Skip to content

Commit 2d9287c

Browse files
authored
Merge pull request #35418 from yanrongshi/zh-cn-uodate-configure-service-account.md
[zh-cn]Update configure-service-account.md
2 parents 445b113 + a9ce4b8 commit 2d9287c

File tree

1 file changed

+35
-42
lines changed

1 file changed

+35
-42
lines changed

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

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ not apply.
3333
<!--
3434
When you (a human) access the cluster (for example, using `kubectl`), you are
3535
authenticated by the apiserver as a particular User Account (currently this is
36-
usually `admin`, unless your cluster administrator has customized your
37-
cluster). Processes in containers inside pods can also contact the apiserver.
38-
When they do, they are authenticated as a particular Service Account (for example,
39-
`default`).
36+
usually `admin`, unless your cluster administrator has customized your cluster). Processes in containers inside pods can also contact the apiserver.
37+
When they do, they are authenticated as a particular Service Account (for example, `default`).
4038
-->
4139
当你(自然人)访问集群时(例如,使用 `kubectl`),API 服务器将你的身份验证为
4240
特定的用户帐户(当前这通常是 `admin`,除非你的集群管理员已经定制了你的集群配置)。
@@ -50,29 +48,30 @@ Pod 内的容器中的进程也可以与 api 服务器接触。
5048
<!-- steps -->
5149

5250
<!--
53-
## Use the Default Service Account to access the API server.
51+
## Use the Default Service Account to access the API server
5452
5553
When you create a pod, if you do not specify a service account, it is
5654
automatically assigned the `default` service account in the same namespace.
57-
If you get the raw json or yaml for a pod you have created (for example, `kubectl get pods/podname -o yaml`),
55+
If you get the raw json or yaml for a pod you have created (for example, `kubectl get pods/<podname> -o yaml`),
5856
you can see the `spec.serviceAccountName` field has been
59-
[automatically set](/docs/user-guide/working-with-resources/#resources-are-automatically-modified).
57+
[automatically set](/docs/concepts/overview/working-with-objects/object-management/).
6058
-->
6159
## 使用默认的服务账户访问 API 服务器
6260

6361
当你创建 Pod 时,如果没有指定服务账户,Pod 会被指定给命名空间中的 `default` 服务账户。
64-
如果你查看 Pod 的原始 JSON 或 YAML(例如:`kubectl get pods/podname -o yaml`),
65-
你可以看到 `spec.serviceAccountName` 字段已经被自动设置了
62+
如果你查看 Pod 的原始 JSON 或 YAML(例如:`kubectl get pods/<podname> -o yaml`),
63+
你可以看到 `spec.serviceAccountName` 字段已经被[自动设置](/zh-cn/docs/concepts/overview/working-with-objects/object-management/)
6664

6765
<!--
68-
You can access the API from inside a pod using automatically mounted service account credentials,
69-
as described in [Accessing the Cluster](/docs/tasks/accessing-application-cluster/access-cluster/).
70-
The API permissions of the service account depend on the [authorization plugin and policy](/docs/reference/access-authn-authz/authorization/#authorization-modules) in use.
66+
You can access the API from inside a pod using automatically mounted service account credentials, as described in
67+
[Accessing the Cluster](/docs/tasks/access-application-cluster/access-cluster).
68+
The API permissions of the service account depend on the
69+
[authorization plugin and policy](/docs/reference/access-authn-authz/authorization/#authorization-modules) in use.
7170
7271
You can opt out of automounting API credentials on `/var/run/secrets/kubernetes.io/serviceaccount/token` for a service account by setting `automountServiceAccountToken: false` on the ServiceAccount:
7372
-->
7473
你可以使用自动挂载给 Pod 的服务账户凭据访问 API,
75-
[访问集群](/zh-cn/docs/tasks/access-application-cluster/access-cluster/)页面中有相关描述。
74+
[访问集群](/zh-cn/docs/tasks/access-application-cluster/access-cluster)页面中有相关描述。
7675
服务账户的 API 许可取决于你所使用的
7776
[鉴权插件和策略](/zh-cn/docs/reference/access-authn-authz/authorization/#authorization-modules)
7877

@@ -111,7 +110,7 @@ The pod spec takes precedence over the service account if both specify a `automo
111110
如果 Pod 和服务账户都指定了 `automountServiceAccountToken` 值,则 Pod 的 spec 优先于服务帐户。
112111

113112
<!--
114-
## Use Multiple Service Accounts.
113+
## Use Multiple Service Accounts
115114
116115
Every namespace has a default service account resource called `default`.
117116
You can list this and any other serviceAccount resources in the namespace with this command:
@@ -122,7 +121,7 @@ You can list this and any other serviceAccount resources in the namespace with t
122121
你可以用下面的命令查询这个服务账户以及命名空间中的其他 ServiceAccount 资源:
123122

124123
```shell
125-
kubectl get serviceAccounts
124+
kubectl get serviceaccounts
126125
```
127126

128127
<!--
@@ -141,7 +140,7 @@ You can create additional ServiceAccount objects like this:
141140
你可以像这样来创建额外的 ServiceAccount 对象:
142141

143142
```shell
144-
kubectl create -f - <<EOF
143+
kubectl apply -f - <<EOF
145144
apiVersion: v1
146145
kind: ServiceAccount
147146
metadata:
@@ -170,7 +169,7 @@ The output is similar to this:
170169
-->
171170
输出类似于:
172171

173-
```none
172+
```yaml
174173
apiVersion: v1
175174
kind: ServiceAccount
176175
metadata:
@@ -215,7 +214,7 @@ kubectl delete serviceaccount/build-robot
215214
```
216215

217216
<!--
218-
## Manually create a service account API token.
217+
## Manually create a service account API token
219218

220219
Suppose we have an existing service account named "build-robot" as mentioned above, and we create
221220
a new secret manually.
@@ -225,7 +224,7 @@ a new secret manually.
225224
假设我们有一个上面提到的名为 "build-robot" 的服务账户,现在我们手动创建一个新的 Secret。
226225

227226
```shell
228-
kubectl create -f - <<EOF
227+
kubectl apply -f - <<EOF
229228
apiVersion: v1
230229
kind: Secret
231230
metadata:
@@ -281,13 +280,13 @@ The content of `token` is elided here.
281280
282281
### Create an imagePullSecret
283282
284-
- Create an imagePullSecret, as described in [Specifying ImagePullSecret on a Pod](/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod).
283+
- Create an imagePullSecret, as described in [Specifying ImagePullSecrets on a Pod](/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod).
285284
-->
286285
## 为服务账户添加 ImagePullSecrets {#add-imagepullsecrets-to-a-service-account}
287286
288287
### 创建 ImagePullSecret
289288
290-
- 创建一个 ImagePullSecret,如[为 Pod 设置 ImagePullSecret](/zh-cn/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod)所述。
289+
- 创建一个 ImagePullSecret,如[为 Pod 设置 ImagePullSecret](/zh-cn/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) 所述。
291290
292291
```shell
293292
kubectl create secret docker-registry myregistrykey --docker-server=DUMMY_SERVER \
@@ -382,7 +381,7 @@ imagePullSecrets:
382381
<!--
383382
Finally replace the serviceaccount with the new updated `sa.yaml` file
384383
-->
385-
最后,用新的更新的 `sa.yaml` 文件替换服务账户。
384+
最后,使用新更新的 `sa.yaml` 文件替换服务账户。
386385

387386
```shell
388387
kubectl replace serviceaccount default -f ./sa.yaml
@@ -427,11 +426,8 @@ command line arguments to `kube-apiserver`:
427426
428427
<!--
429428
* `--service-account-issuer`
430-
It can be used as the Identifier of the service account token issuer. You can specify the
431-
`--service-account-issuer` argument multiple times, this can be useful to enable a non-disruptive
432-
change of the issuer. When this flag is specified multiple times, the first is used to generate
433-
tokens and all are used to determine which issuers are accepted. You must be running Kubernetes
434-
v1.22 or later to be able to specify `--service-account-issuer` multiple times.
429+
430+
It can be used as the Identifier of the service account token issuer. You can specify the `--service-account-issuer` argument multiple times, this can be useful to enable a non-disruptive change of the issuer. When this flag is specified multiple times, the first is used to generate tokens and all are used to determine which issuers are accepted. You must be running Kubernetes v1.22 or later to be able to specify `--service-account-issuer` multiple times.
435431
-->
436432
* `--service-account-issuer`
437433
@@ -440,40 +436,32 @@ command line arguments to `kube-apiserver`:
440436
这样做是有用的。如果这个参数被多次指定,则第一个参数值会被用来生成令牌,
441437
而所有参数值都会被用来确定哪些发放者是可接受的。你所运行的 Kubernetes
442438
集群必须是 v1.22 或更高版本,才能多次指定 `--service-account-issuer`。
443-
444439
<!--
445440
* `--service-account-key-file`
446-
File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify
447-
ServiceAccount tokens. The specified file can contain multiple keys, and the flag can be specified
448-
multiple times with different files. If specified multiple times, tokens signed by any of the
449-
specified keys are considered valid by the Kubernetes API server.
441+
442+
File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens. The specified file can contain multiple keys, and the flag can be specified multiple times with different files. If specified multiple times, tokens signed by any of the specified keys are considered valid by the Kubernetes API server.
450443
-->
451444
* `--service-account-key-file`
452445
453446
包含 PEM 编码的 x509 RSA 或 ECDSA 私钥或公钥,用来检查 ServiceAccount
454447
的令牌。所指定的文件中可以包含多个秘钥,并且你可以多次使用此参数,
455448
每次参数值为不同的文件。多次使用此参数时,由所给的秘钥之一签名的令牌会被
456449
Kubernetes API 服务器认为是合法令牌。
457-
458450
<!--
459451
* `--service-account-signing-key-file`
460-
Path to the file that contains the current private key of the service account token issuer. The
461-
issuer signs issued ID tokens with this private key.
452+
453+
Path to the file that contains the current private key of the service account token issuer. The issuer signs issued ID tokens with this private key.
462454
-->
463455
* `--service-account-signing-key-file`
464456
465457
指向包含当前服务账户令牌发放者的私钥的文件路径。
466458
此发放者使用此私钥来签署所发放的 ID 令牌。
467-
468459
<!--
469460
* `--api-audiences` (can be omitted)
470-
The service account token authenticator validates that tokens used against the API are bound to
471-
at least one of these audiences. If `api-audiences` is specified multiple times, tokens for any of
472-
the specified audiences are considered valid by the Kubernetes API server. If the
473-
`--service-account-issuer` flag is configured and this flag is not, this field defaults to a
474-
single element list containing the issuer URL.
461+
462+
The service account token authenticator validates that tokens used against the API are bound to at least one of these audiences. If `api-audiences` is specified multiple times, tokens for any of the specified audiences are considered valid by the Kubernetes API server. If the `--service-account-issuer` flag is configured and this flag is not, this field defaults to a single element list containing the issuer URL.
475463
-->
476-
* `--api-audiences` (can be omitted)
464+
* `--api-audiences` (可以省略)
477465
478466
服务账户令牌身份检查组件会检查针对 API 访问所使用的令牌,
479467
确认令牌至少是被绑定到这里所给的受众(audiences)之一。
@@ -555,6 +543,7 @@ provider configuration at `{service-account-issuer}/.well-known/openid-configura
555543
If the URL does not comply, the `ServiceAccountIssuerDiscovery` endpoints will
556544
not be registered, even if the feature is enabled.
557545
-->
546+
{{< note >}}
558547
分发者的 URL 必须遵从
559548
[OIDC 发现规范](https://openid.net/specs/openid-connect-discovery-1_0.html)
560549
这意味着 URL 必须使用 `https` 模式,并且必须在
@@ -563,6 +552,7 @@ not be registered, even if the feature is enabled.
563552

564553
如果 URL 没有遵从这一规范,`ServiceAccountIssuerDiscovery` 末端就不会被注册,
565554
即使该特性已经被启用。
555+
{{< /note >}}
566556

567557
<!--
568558
The Service Account Issuer Discovery feature enables federation of Kubernetes
@@ -606,9 +596,11 @@ The responses served at `/.well-known/openid-configuration` and
606596
compliant. Those documents contain only the parameters necessary to perform
607597
validation of Kubernetes service account tokens.
608598
-->
599+
{{< note >}}
609600
`/.well-known/openid-configuration``/openid/v1/jwks` 路径请求的响应被设计为与
610601
OIDC 兼容,但不是与其完全一致。
611602
返回的文档仅包含对 Kubernetes 服务账户令牌进行验证所必须的参数。
603+
{{< /note >}}
612604

613605
<!--
614606
The JWKS response contains public keys that a relying party can use to validate
@@ -635,6 +627,7 @@ JWKS URI is required to use the `https` scheme.
635627
这时需要向 API 服务器传递 `--service-account-jwks-uri` 参数。
636628
与分发者 URL 类似,此 JWKS URI 也需要使用 `https` 模式。
637629

630+
638631
## {{% heading "whatsnext" %}}
639632

640633
<!--

0 commit comments

Comments
 (0)