Skip to content

Commit 79f26d5

Browse files
committed
Update service account token documentation
* Make example service account output match 1.24+ output with auto-generated tokens omitted * Prefer `kubectl create token` as token creation mechanism
1 parent a65b1a3 commit 79f26d5

File tree

3 files changed

+14
-47
lines changed

3 files changed

+14
-47
lines changed

content/en/docs/concepts/services-networking/connect-applications-service.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ kubectl get secrets
244244
```
245245
```
246246
NAME TYPE DATA AGE
247-
default-token-il9rc kubernetes.io/service-account-token 1 1d
248247
nginxsecret kubernetes.io/tls 2 1m
249248
```
250249
And also the configmap:
@@ -291,7 +290,6 @@ kubectl get secrets
291290
```
292291
```
293292
NAME TYPE DATA AGE
294-
default-token-il9rc kubernetes.io/service-account-token 1 1d
295293
nginxsecret kubernetes.io/tls 2 1m
296294
```
297295

content/en/docs/reference/access-authn-authz/authentication.md

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -210,65 +210,42 @@ Service account bearer tokens are perfectly valid to use outside the cluster and
210210
can be used to create identities for long standing jobs that wish to talk to the
211211
Kubernetes API. To manually create a service account, use the `kubectl create
212212
serviceaccount (NAME)` command. This creates a service account in the current
213-
namespace and an associated secret.
213+
namespace.
214214

215215
```bash
216216
kubectl create serviceaccount jenkins
217217
```
218218

219219
```none
220-
serviceaccount "jenkins" created
220+
serviceaccount/jenkins created
221221
```
222222

223-
Check an associated secret:
223+
Create an associated token:
224224

225225
```bash
226-
kubectl get serviceaccounts jenkins -o yaml
226+
kubectl create token jenkins
227227
```
228228

229-
```yaml
230-
apiVersion: v1
231-
kind: ServiceAccount
232-
metadata:
233-
# ...
234-
secrets:
235-
- name: jenkins-token-1yvwg
236-
```
237-
238-
The created secret holds the public CA of the API server and a signed JSON Web
239-
Token (JWT).
240-
241-
```bash
242-
kubectl get secret jenkins-token-1yvwg -o yaml
243-
```
244-
245-
```yaml
246-
apiVersion: v1
247-
data:
248-
ca.crt: (APISERVER'S CA BASE64 ENCODED)
249-
namespace: ZGVmYXVsdA==
250-
token: (BEARER TOKEN BASE64 ENCODED)
251-
kind: Secret
252-
metadata:
253-
# ...
254-
type: kubernetes.io/service-account-token
229+
```none
230+
eyJhbGciOiJSUzI1NiIsImtp...
255231
```
256232

257-
{{< note >}}
258-
Values are base64 encoded because secrets are always base64 encoded.
259-
{{< /note >}}
233+
The created token is a signed JSON Web Token (JWT).
260234

261235
The signed JWT can be used as a bearer token to authenticate as the given service
262236
account. See [above](#putting-a-bearer-token-in-a-request) for how the token is included
263-
in a request. Normally these secrets are mounted into pods for in-cluster access to
237+
in a request. Normally these tokens are mounted into pods for in-cluster access to
264238
the API server, but can be used from outside the cluster as well.
265239

266240
Service accounts authenticate with the username `system:serviceaccount:(NAMESPACE):(SERVICEACCOUNT)`,
267241
and are assigned to the groups `system:serviceaccounts` and `system:serviceaccounts:(NAMESPACE)`.
268242

269-
WARNING: Because service account tokens are stored in secrets, any user with
270-
read access to those secrets can authenticate as the service account. Be cautious
271-
when granting permissions to service accounts and read capabilities for secrets.
243+
{{< warning >}}
244+
Because service account tokens can also be stored in Secret API objects, any user with
245+
write access to Secrets can request a token, and any user with read access to those
246+
Secrets can authenticate as the service account. Be cautious when granting permissions
247+
to service accounts and read or write capabilities for Secrets.
248+
{{< /warning >}}
272249

273250
### OpenID Connect Tokens
274251

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,8 @@ metadata:
115115
namespace: default
116116
resourceVersion: "272500"
117117
uid: 721ab723-13bc-11e5-aec2-42010af0021e
118-
secrets:
119-
- name: build-robot-token-bvbk5
120118
```
121119
122-
then you will see that a token has automatically been created and is referenced by the service account.
123-
124120
You may use authorization plugins to [set permissions on service accounts](/docs/reference/access-authn-authz/rbac/#service-account-permissions).
125121
126122
To use a non-default service account, set the `spec.serviceAccountName`
@@ -233,8 +229,6 @@ metadata:
233229
namespace: default
234230
resourceVersion: "243024"
235231
uid: 052fb0f4-3d50-11e5-b066-42010af0d7b6
236-
secrets:
237-
- name: default-token-uudge
238232
```
239233

240234
Using your editor of choice (for example `vi`), open the `sa.yaml` file, delete line with key `resourceVersion`, add lines with `imagePullSecrets:` and save.
@@ -249,8 +243,6 @@ metadata:
249243
name: default
250244
namespace: default
251245
uid: 052fb0f4-3d50-11e5-b066-42010af0d7b6
252-
secrets:
253-
- name: default-token-uudge
254246
imagePullSecrets:
255247
- name: myregistrykey
256248
```

0 commit comments

Comments
 (0)