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
in your Pod manifest. Kubernetes creates the token and mounts it in the Pod.
231
+
The token is automatically invalidated when the Pod that it's mounted in is
232
+
deleted. For details, see
233
+
[Launch a Pod using service account token projection](/docs/tasks/configure-pod-container/configure-service-account/#launch-a-pod-using-service-account-token-projection).
216
234
217
235
{{< note >}}
218
-
Versions of Kubernetes before v1.22 automatically created credentials for
219
-
accessing the Kubernetes API. This older mechanism was based on creating token
220
-
Secrets that could then be mounted into running Pods.
221
-
In more recent versions, including Kubernetes v{{< skew currentVersion >}}, API
command to obtain a token from the `TokenRequest` API.
238
-
{{< /note >}}
239
-
240
-
You should only create a service account token Secret object
236
+
You should only create a ServiceAccount token Secret
241
237
if you can't use the `TokenRequest` API to obtain a token,
242
238
and the security exposure of persisting a non-expiring token credential
243
-
in a readable API object is acceptable to you.
239
+
in a readable API object is acceptable to you. For instructions, see
240
+
[Manually create a long-lived API token for a ServiceAccount](/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-service-account-api-token).
241
+
{{< /note >}}
244
242
245
243
When using this Secret type, you need to ensure that the
246
244
`kubernetes.io/service-account.name`annotation is set to an existing
247
-
service account name. If you are creating both the ServiceAccount and
245
+
ServiceAccount name. If you are creating both the ServiceAccount and
248
246
the Secret objects, you should create the ServiceAccount object first.
249
247
250
248
After the Secret is created, a Kubernetes {{< glossary_tooltip text="controller" term_id="controller" >}}
251
249
fills in some other fields such as the `kubernetes.io/service-account.uid` annotation, and the
252
250
`token`key in the `data` field, which is populated with an authentication token.
253
251
254
-
The following example configuration declares a service account token Secret:
252
+
The following example configuration declares a ServiceAccount token Secret:
255
253
256
254
```yaml
257
255
apiVersion: v1
@@ -268,33 +266,27 @@ data:
268
266
269
267
After creating the Secret, wait for Kubernetes to populate the `token` key in the `data` field.
270
268
271
-
See the [ServiceAccount](/docs/tasks/configure-pod-container/configure-service-account/)
272
-
documentation for more information on how service accounts work.
269
+
See the [ServiceAccount](/docs/concepts/security/service-accounts/)
270
+
documentation for more information on how ServiceAccounts work.
273
271
You can also check the `automountServiceAccountToken` field and the
That command creates a Secret of type `kubernetes.io/dockerconfigjson`.
334
-
If you dump the `.data.dockerconfigjson` field from that new Secret and then
335
-
decode it from base64:
325
+
This command creates a Secret of type `kubernetes.io/dockerconfigjson`.
326
+
327
+
Retrieve the `.data.dockerconfigjson` field from that new Secret and decode the
328
+
data:
336
329
337
330
```shell
338
331
kubectl get secret secret-tiger-docker -o jsonpath='{.data.*}' | base64 -d
339
332
```
340
333
341
-
then the output is equivalent to this JSON document (which is also a valid
334
+
The output is equivalent to the following JSON document (which is also a valid
342
335
Docker configuration file):
343
336
344
337
```json
@@ -370,9 +363,9 @@ Secret must contain one of the following two keys:
370
363
- `username`: the user name for authentication
371
364
- `password`: the password or token for authentication
372
365
373
-
Both values for the above two keys are base64 encoded strings. You can, of
374
-
course, provide the clear text content using the `stringData` for Secret
375
-
creation.
366
+
Both values for the above two keys are base64 encoded strings. You can
367
+
alternatively provide the clear text content using the `stringData` field in the
368
+
Secret manifest.
376
369
377
370
The following manifest is an example of a basic authentication Secret:
378
371
@@ -394,7 +387,7 @@ people to understand the purpose of your Secret, and sets a convention for what
394
387
to expect.
395
388
The Kubernetes API verifies that the required keys are set for a Secret of this type.
396
389
397
-
### SSH authentication secrets
390
+
### SSH authentication Secrets
398
391
399
392
The builtin type `kubernetes.io/ssh-auth` is provided for storing data used in
400
393
SSH authentication. When using this Secret type, you will have to specify a
@@ -416,32 +409,34 @@ data:
416
409
MIIEpQIBAAKCAQEAulqb/Y ...
417
410
```
418
411
419
-
The SSH authentication Secret type is provided only for user's convenience.
420
-
You could instead create an `Opaque` type Secret for credentials used for SSH authentication.
412
+
The SSH authentication Secret type is provided only for convenience.
413
+
You can create an `Opaque` type for credentials used for SSH authentication.
421
414
However, using the defined and public Secret type (`kubernetes.io/ssh-auth`) helps other
422
415
people to understand the purpose of your Secret, and sets a convention for what key names
423
416
to expect.
424
-
and the API server does verify if the required keys are provided in a Secret configuration.
417
+
The Kubernetes API verifies that the required keys are set for a Secret of this type.
425
418
426
419
{{< caution >}}
427
420
SSH private keys do not establish trusted communication between an SSH client and
428
421
host server on their own. A secondary means of establishing trust is needed to
429
422
mitigate "man in the middle" attacks, such as a `known_hosts` file added to a ConfigMap.
430
423
{{< /caution >}}
431
424
432
-
### TLS secrets
425
+
### TLS Secrets
433
426
434
-
Kubernetes provides a builtin Secret type `kubernetes.io/tls` for storing
427
+
The `kubernetes.io/tls` Secret type is for storing
435
428
a certificate and its associated key that are typically used for TLS.
436
429
437
-
One common use for TLS secrets is to configure encryption in transit for
430
+
One common use for TLS Secrets is to configure encryption in transit for
438
431
an [Ingress](/docs/concepts/services-networking/ingress/), but you can also use it
439
432
with other resources or directly in your workload.
440
433
When using this type of Secret, the `tls.key` and the `tls.crt` key must be provided
441
434
in the `data` (or `stringData`) field of the Secret configuration, although the API
442
435
server doesn't actually validate the values for each key.
443
436
444
-
As an alternative to using `stringData`, you can use the `data` field to provide the base64 encoded certificate and private key. Refer to [Constraints on Secret names and data](#restriction-names-data) for more on this.
437
+
As an alternative to using `stringData`, you can use the `data` field to provide
438
+
the base64 encoded certificate and private key. For details, see
439
+
[Constraints on Secret names and data](#restriction-names-data).
445
440
446
441
The following YAML contains an example config for a TLS Secret:
447
442
@@ -461,13 +456,13 @@ stringData:
461
456
MIIEpgIBAAKCAQEA7yn3bRHQ5FHMQ ...
462
457
```
463
458
464
-
The TLS Secret type is provided for user's convenience. You can create an `Opaque`
465
-
for credentials used for TLS server and/or client. However, using the builtin Secret
466
-
type helps ensure the consistency of Secret format in your project; the API server
467
-
does verify if the required keys are provided in a Secret configuration.
459
+
The TLS Secret type is provided only for convenience.
460
+
You can create an `Opaque` type for credentials used for TLS authentication.
461
+
However, using the defined and public Secret type (`kubernetes.io/ssh-auth`)
462
+
helps ensure the consistency of Secret format in your project. The API server
463
+
verifies if the required keys are set for a Secret of this type.
468
464
469
-
When creating a TLS Secret using `kubectl`, you can use the `tls` subcommand
470
-
as shown in the following example:
465
+
To create a TLS Secret using `kubectl`, use the `tls` subcommand:
471
466
472
467
```shell
473
468
kubectl create secret tls my-tls-secret \
@@ -480,8 +475,7 @@ and must match the given private key for `--key`.
480
475
481
476
### Bootstrap token Secrets
482
477
483
-
A bootstrap token Secret can be created by explicitly specifying the Secret
484
-
`type`to `bootstrap.kubernetes.io/token`. This type of Secret is designed for
478
+
The `bootstrap.kubernetes.io/token` Secret type is for
485
479
tokens used during the node bootstrap process. It stores tokens used to sign
486
480
well-known ConfigMaps.
487
481
@@ -508,7 +502,7 @@ data:
508
502
usage-bootstrap-signing: dHJ1ZQ==
509
503
```
510
504
511
-
A bootstrap type Secret has the following keys specified under `data`:
505
+
A bootstrap token Secret has the following keys specified under `data`:
512
506
513
507
- `token-id`: A random 6 character string as the token identifier. Required.
514
508
- `token-secret`: A random 16 character string as the actual token secret. Required.
@@ -521,8 +515,8 @@ A bootstrap type Secret has the following keys specified under `data`:
521
515
- `auth-extra-groups`: A comma-separated list of group names that will be
522
516
authenticated as in addition to the `system:bootstrappers` group.
523
517
524
-
The above YAML may look confusing because the values are all in base64 encoded
525
-
strings. In fact, you can create an identical Secret using the following YAML:
518
+
You can alternatively provide the values in the `stringData` field of the Secret
0 commit comments