You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/concepts/security/service-accounts.md
+29-19Lines changed: 29 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Service Accounts
3
3
description: >
4
-
Learn about the Kubernetes ServiceAccount object.
4
+
Learn about ServiceAccount objects in Kubernetes.
5
5
content_type: concept
6
6
weight: 10
7
7
---
@@ -40,7 +40,8 @@ accounts have the following properties:
40
40
the configurations portable.
41
41
42
42
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
44
45
data. You can authenticate as a user account using multiple methods. Some
45
46
Kubernetes distributions might add custom extension APIs to represent user
46
47
accounts in the API server.
@@ -61,9 +62,9 @@ When you create a cluster, Kubernetes automatically creates a ServiceAccount
61
62
object named `default` for every namespace in your cluster. The `default`
62
63
service accounts in each namespace get no permissions by default other than the
63
64
[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
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.
183
188
184
189
## Authenticating service account credentials {#authenticating-credentials}
185
190
@@ -189,17 +194,21 @@ to authenticate to the Kubernetes API server, and to any other system where a
189
194
trust relationship exists. Depending on how the token was issued
190
195
(either time-limited using a `TokenRequest` or using a legacy mechanism with
191
196
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:
196
201
197
202
1. Check the token signature.
198
203
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.
200
205
1. Check whether the token is currently valid.
201
206
1. Check the audience claims.
202
207
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
+
203
212
For tokens issued using the `TokenRequest` API, the API server also checks that
204
213
the specific object reference that is using the ServiceAccount still exists,
205
214
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:
221
230
The Kubernetes project recommends that you use the TokenReview API, because
222
231
this method invalidates tokens that are bound to API objects such as Secrets,
223
232
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.
227
237
228
238
Your application should always define the audience that it accepts, and should
229
239
check that the token's audiences match the audiences that the application
230
240
expects. This helps to minimize the scope of the token so that it can only be
0 commit comments