Skip to content

Commit b1ab30d

Browse files
committed
Tweak line wrappings in /configure-service-account.md
1 parent ef18ad6 commit b1ab30d

File tree

1 file changed

+66
-43
lines changed

1 file changed

+66
-43
lines changed

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

Lines changed: 66 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ If you do not specify a ServiceAccount when you create a Pod, Kubernetes
4141
automatically assigns the ServiceAccount named `default` in that namespace.
4242

4343
You can fetch the details for a Pod you have created. For example:
44+
4445
```shell
4546
kubectl get pods/<podname> -o yaml
4647
```
@@ -75,6 +76,7 @@ automountServiceAccountToken: false
7576
```
7677

7778
You can also opt out of automounting API credentials for a particular Pod:
79+
7880
```yaml
7981
apiVersion: v1
8082
kind: Pod
@@ -92,8 +94,7 @@ If both the ServiceAccount and the Pod's `.spec` specify a value for
9294
## Use more than one ServiceAccount {#use-multiple-service-accounts}
9395

9496
Every namespace has at least one ServiceAccount: the default ServiceAccount
95-
resource, called `default`.
96-
You can list all ServiceAccount resources in your
97+
resource, called `default`. You can list all ServiceAccount resources in your
9798
[current namespace](/docs/concepts/overview/working-with-objects/namespaces/#setting-the-namespace-preference)
9899
with:
99100

@@ -157,7 +158,6 @@ If you want to remove the fields from a workload resource, set both fields to em
157158
on the [pod template](/docs/concepts/workloads/pods#pod-templates).
158159
{{< /note >}}
159160

160-
161161
### Cleanup {#cleanup-use-multiple-service-accounts}
162162

163163
If you tried creating `build-robot` ServiceAccount from the example above,
@@ -185,15 +185,17 @@ token might be shorter, or could even be longer).
185185
{{< note >}}
186186
Versions of Kubernetes before v1.22 automatically created long term credentials for
187187
accessing the Kubernetes API. This older mechanism was based on creating token Secrets
188-
that could then be mounted into running Pods.
189-
In more recent versions, including Kubernetes v{{< skew currentVersion >}}, API credentials
190-
are obtained directly by using the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) API,
191-
and are mounted into Pods using a [projected volume](/docs/reference/access-authn-authz/service-accounts-admin/#bound-service-account-token-volume).
188+
that could then be mounted into running Pods. In more recent versions, including
189+
Kubernetes v{{< skew currentVersion >}}, API credentials are obtained directly by using the
190+
[TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) API,
191+
and are mounted into Pods using a
192+
[projected volume](/docs/reference/access-authn-authz/service-accounts-admin/#bound-service-account-token-volume).
192193
The tokens obtained using this method have bounded lifetimes, and are automatically
193194
invalidated when the Pod they are mounted into is deleted.
194195

195-
You can still manually create a service account token Secret; for example, if you need a token that never expires.
196-
However, using the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
196+
You can still manually create a service account token Secret; for example,
197+
if you need a token that never expires. However, using the
198+
[TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
197199
subresource to obtain a token to access the API is recommended instead.
198200
{{< /note >}}
199201

@@ -215,6 +217,7 @@ EOF
215217
```
216218

217219
If you view the Secret using:
220+
218221
```shell
219222
kubectl get secret/build-robot-secret -o yaml
220223
```
@@ -251,8 +254,7 @@ token: ...
251254
The content of `token` is elided here.
252255

253256
Take care not to display the contents of a `kubernetes.io/service-account-token`
254-
Secret somewhere that your terminal / computer screen could be seen by an
255-
onlooker.
257+
Secret somewhere that your terminal / computer screen could be seen by an onlooker.
256258
{{< /note >}}
257259

258260
When you delete a ServiceAccount that has an associated Secret, the Kubernetes
@@ -263,31 +265,32 @@ control plane automatically cleans up the long-lived token from that Secret.
263265
First, [create an imagePullSecret](/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod).
264266
Next, verify it has been created. For example:
265267

266-
- Create an imagePullSecret, as described in [Specifying ImagePullSecrets on a Pod](/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod).
268+
- Create an imagePullSecret, as described in
269+
[Specifying ImagePullSecrets on a Pod](/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod).
267270

268-
```shell
269-
kubectl create secret docker-registry myregistrykey --docker-server=DUMMY_SERVER \
270-
--docker-username=DUMMY_USERNAME --docker-password=DUMMY_DOCKER_PASSWORD \
271-
--docker-email=DUMMY_DOCKER_EMAIL
272-
```
271+
```shell
272+
kubectl create secret docker-registry myregistrykey --docker-server=DUMMY_SERVER \
273+
--docker-username=DUMMY_USERNAME --docker-password=DUMMY_DOCKER_PASSWORD \
274+
--docker-email=DUMMY_DOCKER_EMAIL
275+
```
273276

274277
- Verify it has been created.
275-
```shell
276-
kubectl get secrets myregistrykey
277-
```
278278

279-
The output is similar to this:
279+
```shell
280+
kubectl get secrets myregistrykey
281+
```
282+
283+
The output is similar to this:
280284

281-
```
282-
NAME TYPE DATA AGE
283-
myregistrykey   kubernetes.io/.dockerconfigjson   1       1d
284-
```
285+
```
286+
NAME TYPE DATA AGE
287+
myregistrykey   kubernetes.io/.dockerconfigjson   1       1d
288+
```
285289
286290
### Add image pull secret to service account
287291
288292
Next, modify the default service account for the namespace to use this Secret as an imagePullSecret.
289293
290-
291294
```shell
292295
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "myregistrykey"}]}'
293296
```
@@ -313,8 +316,8 @@ metadata:
313316
uid: 052fb0f4-3d50-11e5-b066-42010af0d7b6
314317
```
315318
316-
Using your editor, delete the line with key `resourceVersion`, add lines for `imagePullSecrets:` and save it.
317-
Leave the `uid` value set the same as you found it.
319+
Using your editor, delete the line with key `resourceVersion`, add lines for
320+
`imagePullSecrets:` and save it. Leave the `uid` value set the same as you found it.
318321

319322
After you made those changes, the edited ServiceAccount looks something like this:
320323

@@ -327,12 +330,13 @@ metadata:
327330
namespace: default
328331
uid: 052fb0f4-3d50-11e5-b066-42010af0d7b6
329332
imagePullSecrets:
330-
- name: myregistrykey
333+
- name: myregistrykey
331334
```
332335

333336
### Verify that imagePullSecrets are set for new Pods
334337

335-
Now, when a new Pod is created in the current namespace and using the default ServiceAccount, the new Pod has its `spec.imagePullSecrets` field set automatically:
338+
Now, when a new Pod is created in the current namespace and using the default
339+
ServiceAccount, the new Pod has its `spec.imagePullSecrets` field set automatically:
336340

337341
```shell
338342
kubectl run nginx --image=nginx --restart=Never
@@ -354,13 +358,31 @@ To enable and use token request projection, you must specify each of the followi
354358
command line arguments to `kube-apiserver`:
355359

356360
`--service-account-issuer`
357-
: defines 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.
361+
: defines the Identifier of the service account token issuer. You can specify the
362+
`--service-account-issuer` argument multiple times, this can be useful to enable
363+
a non-disruptive change of the issuer. When this flag is specified multiple times,
364+
the first is used to generate tokens and all are used to determine which issuers
365+
are accepted. You must be running Kubernetes v1.22 or later to be able to specify
366+
`--service-account-issuer` multiple times.
367+
358368
`--service-account-key-file`
359-
: specifies the path to a file containing PEM-encoded X.509 private or public keys (RSA or ECDSA), 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.
369+
: specifies the path to a file containing PEM-encoded X.509 private or public keys
370+
(RSA or ECDSA), used to verify ServiceAccount tokens. The specified file can contain
371+
multiple keys, and the flag can be specified multiple times with different files.
372+
If specified multiple times, tokens signed by any of the specified keys are considered
373+
valid by the Kubernetes API server.
374+
360375
`--service-account-signing-key-file`
361-
: specifies the path to a file that contains the current private key of the service account token issuer. The issuer signs issued ID tokens with this private key.
376+
: specifies the path to a file that contains the current private key of the service
377+
account token issuer. The issuer signs issued ID tokens with this private key.
378+
362379
`--api-audiences` (can be omitted)
363-
: defines audiences for ServiceAccount tokens. 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 you specify the `--service-account-issuer` command line argument but you don't set `--api-audiences`, the control plane defaults to a single element audience list that contains only the issuer URL.
380+
: defines audiences for ServiceAccount tokens. The service account token authenticator
381+
validates that tokens used against the API are bound to at least one of these audiences.
382+
If `api-audiences` is specified multiple times, tokens for any of the specified audiences
383+
are considered valid by the Kubernetes API server. If you specify the `--service-account-issuer`
384+
command line argument but you don't set `--api-audiences`, the control plane defaults to
385+
a single element audience list that contains only the issuer URL.
364386

365387
{{< /note >}}
366388

@@ -452,18 +474,19 @@ to the public endpoint, rather than the API server's address, by passing the
452474
`--service-account-jwks-uri` flag to the API server. Like the issuer URL, the
453475
JWKS URI is required to use the `https` scheme.
454476

455-
456477
## {{% heading "whatsnext" %}}
457478

458479
See also:
459480

460-
* Read the [Cluster Admin Guide to Service Accounts](/docs/reference/access-authn-authz/service-accounts-admin/)
461-
* Read about [Authorization in Kubernetes](/docs/reference/access-authn-authz/authorization/)
462-
* Read about [Secrets](/docs/concepts/configuration/secret/)
463-
* or learn to [distribute credentials securely using Secrets](/docs/tasks/inject-data-application/distribute-credentials-secure/)
464-
* but also bear in mind that using Secrets for authenticating as a ServiceAccount
481+
- Read the [Cluster Admin Guide to Service Accounts](/docs/reference/access-authn-authz/service-accounts-admin/)
482+
- Read about [Authorization in Kubernetes](/docs/reference/access-authn-authz/authorization/)
483+
- Read about [Secrets](/docs/concepts/configuration/secret/)
484+
- or learn to [distribute credentials securely using Secrets](/docs/tasks/inject-data-application/distribute-credentials-secure/)
485+
- but also bear in mind that using Secrets for authenticating as a ServiceAccount
465486
is deprecated. The recommended alternative is
466487
[ServiceAccount token volume projection](#service-account-token-volume-projection).
467-
* Read about [projected volumes](/docs/tasks/configure-pod-container/configure-projected-volume-storage/).
468-
* For background on OIDC discovery, read the [ServiceAccount signing key retrieval](https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/1393-oidc-discovery) Kubernetes Enhancement Proposal
469-
* Read the [OIDC Discovery Spec](https://openid.net/specs/openid-connect-discovery-1_0.html)
488+
- Read about [projected volumes](/docs/tasks/configure-pod-container/configure-projected-volume-storage/).
489+
- For background on OIDC discovery, read the
490+
[ServiceAccount signing key retrieval](https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/1393-oidc-discovery)
491+
Kubernetes Enhancement Proposal
492+
- Read the [OIDC Discovery Spec](https://openid.net/specs/openid-connect-discovery-1_0.html)

0 commit comments

Comments
 (0)