Skip to content

Commit da84dd8

Browse files
authored
Merge pull request #39436 from sftim/20230213_tweak_sa_concept
Fix wording, punctuation and Markdown for ServiceAccount concept page
2 parents ee4b88e + 96d4931 commit da84dd8

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

content/en/docs/concepts/security/service-accounts.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Service Accounts
33
description: >
4-
Learn about the Kubernetes ServiceAccount object.
4+
Learn about ServiceAccount objects in Kubernetes.
55
content_type: concept
66
weight: 10
77
---
@@ -40,7 +40,8 @@ accounts have the following properties:
4040
the configurations portable.
4141

4242
Service accounts are different from user accounts, which are authenticated
43-
human users in the cluster. By default, user accounts don't exist in the Kubernetes API server; instead, the API server treats user identities as opaque
43+
human users in the cluster. By default, user accounts don't exist in the Kubernetes
44+
API server; instead, the API server treats user identities as opaque
4445
data. You can authenticate as a user account using multiple methods. Some
4546
Kubernetes distributions might add custom extension APIs to represent user
4647
accounts in the API server.
@@ -61,9 +62,9 @@ When you create a cluster, Kubernetes automatically creates a ServiceAccount
6162
object named `default` for every namespace in your cluster. The `default`
6263
service accounts in each namespace get no permissions by default other than the
6364
[default API discovery permissions](/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings)
64-
that Kubernetes grants to all authenticated principals if role-based access control (RBAC) is enabled. If you delete the
65-
`default` ServiceAccount object in a namespace, the
66-
{{<glossary_tooltip text="control plane" term_id="control-plane">}}
65+
that Kubernetes grants to all authenticated principals if role-based access control (RBAC) is enabled.
66+
If you delete the `default` ServiceAccount object in a namespace, the
67+
{{< glossary_tooltip text="control plane" term_id="control-plane" >}}
6768
replaces it with a new one.
6869

6970
If you deploy a Pod in a namespace, and you don't
@@ -164,11 +165,14 @@ location, or for an audience that isn't the API server, use one of the
164165
following methods:
165166

166167
* [TokenRequest API](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
167-
(recommended): Request a short-lived service account token using your
168-
*application code*. The token expires automatically and can rotate upon
169-
expiration.
168+
(recommended): Request a short-lived service account token from within
169+
your own *application code*. The token expires automatically and can rotate
170+
upon expiration.
171+
If you have a legacy application that is not aware of Kubernetes, you
172+
could use a sidecar container within the same pod to fetch these tokens
173+
and make them available to the application workload.
170174
* [Token Volume Projection](/docs/tasks/configure-pod-container/configure-service-account/#service-account-token-volume-projection)
171-
(recommended): In Kubernetes v1.20 and later, use the Pod specification to
175+
(also recommended): In Kubernetes v1.20 and later, use the Pod specification to
172176
tell the kubelet to add the service account token to the Pod as a
173177
*projected volume*. Projected tokens expire automatically, and the kubelet
174178
rotates the token before it expires.
@@ -179,7 +183,8 @@ following methods:
179183
with static, long-lived credentials. In Kubernetes v1.24 and later, the
180184
[LegacyServiceAccountTokenNoAutoGeneration feature gate](/docs/reference/command-line-tools-reference/feature-gates/#feature-gates-for-graduated-or-deprecated-features)
181185
prevents Kubernetes from automatically creating these tokens for
182-
ServiceAccounts.
186+
ServiceAccounts. `LegacyServiceAccountTokenNoAutoGeneration` is enabled
187+
by default; in other words, Kubernetes does not create these tokens.
183188

184189
## Authenticating service account credentials {#authenticating-credentials}
185190

@@ -189,17 +194,21 @@ to authenticate to the Kubernetes API server, and to any other system where a
189194
trust relationship exists. Depending on how the token was issued
190195
(either time-limited using a `TokenRequest` or using a legacy mechanism with
191196
a Secret), a ServiceAccount token might also have an expiry time, an audience,
192-
and a time after which the token *starts* being valid. When a process running
193-
in a Pod attempts to communicate with the Kubernetes API server, it adds an
194-
`Authorization: Bearer <token>` header to the HTTP request. The API server
195-
checks the validity of the bearer token as follows:
197+
and a time after which the token *starts* being valid. When a client that is
198+
acting as a ServiceAccount tries to communicate with the Kubernetes API server,
199+
the client includes an `Authorization: Bearer <token>` header with the HTTP
200+
request. The API server checks the validity of that bearer token as follows:
196201

197202
1. Check the token signature.
198203
1. Check whether the token has expired.
199-
1. Checks whether object references in the token claims are currently valid
204+
1. Check whether object references in the token claims are currently valid.
200205
1. Check whether the token is currently valid.
201206
1. Check the audience claims.
202207

208+
The TokenRequest API produces _bound tokens_ for a ServiceAccount. This
209+
binding is linked to the lifetime of the client, such as a Pod, that is acting
210+
as that ServiceAccount.
211+
203212
For tokens issued using the `TokenRequest` API, the API server also checks that
204213
the specific object reference that is using the ServiceAccount still exists,
205214
matching by the {{< glossary_tooltip term_id="uid" text="unique ID" >}} of that
@@ -221,14 +230,15 @@ account credentials, you can use the following methods:
221230
The Kubernetes project recommends that you use the TokenReview API, because
222231
this method invalidates tokens that are bound to API objects such as Secrets,
223232
ServiceAccounts, and Pods when those objects are deleted. For example, if you
224-
delete the Pod that contains a projected ServiceAccount token, the TokenReview
225-
API invalidates that token immediately. If you use OIDC validation instead, your clients continue to treat the token as valid until the token reaches its
226-
expiration timestamp.
233+
delete the Pod that contains a projected ServiceAccount token, the cluster
234+
invalidates that token immediately and a TokenReview immediately fails.
235+
If you use OIDC validation instead, your clients continue to treat the token
236+
as valid until the token reaches its expiration timestamp.
227237

228238
Your application should always define the audience that it accepts, and should
229239
check that the token's audiences match the audiences that the application
230240
expects. This helps to minimize the scope of the token so that it can only be
231-
used in your appplication and nowhere else.
241+
used in your application and nowhere else.
232242

233243
## Alternatives
234244

0 commit comments

Comments
 (0)