Skip to content

Commit a11b8cb

Browse files
authored
Merge pull request #39501 from shannonxtreme/using-secret-as-files
Clean up using secrets as files section
2 parents bc7d7d4 + 0dee0cf commit a11b8cb

File tree

1 file changed

+23
-25
lines changed
  • content/en/docs/concepts/configuration

1 file changed

+23
-25
lines changed

content/en/docs/concepts/configuration/secret.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,8 @@ If you want to access data from a Secret in a Pod, one way to do that is to
201201
have Kubernetes make the value of that Secret be available as a file inside
202202
the filesystem of one or more of the Pod's containers.
203203
204-
{{< note >}}
205-
Versions of Kubernetes before v1.22 automatically created credentials for accessing
206-
the Kubernetes API. This older mechanism was based on creating token Secrets that
207-
could then be mounted into running Pods.
208-
In more recent versions, including Kubernetes v{{< skew currentVersion >}}, API credentials
209-
are obtained directly by using the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) API,
210-
and are mounted into Pods using a [projected volume](/docs/reference/access-authn-authz/service-accounts-admin/#bound-service-account-token-volume).
211-
The tokens obtained using this method have bounded lifetimes, and are automatically
212-
invalidated when the Pod they are mounted into is deleted.
213-
214-
You can still [manually create](/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-service-account-api-token)
215-
a service account token Secret; for example, if you need a token that never expires.
216-
However, using the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
217-
subresource to obtain a token to access the API is recommended instead.
218-
You can use the [`kubectl create token`](/docs/reference/generated/kubectl/kubectl-commands#-em-token-em-)
219-
command to obtain a token from the `TokenRequest` API.
220-
{{< /note >}}
221-
222-
#### Mounted Secrets are updated automatically
204+
For instructions, refer to
205+
[Distribute credentials securely using Secrets](/docs/tasks/inject-data-application/distribute-credentials-secure/#create-a-pod-that-has-access-to-the-secret-data-through-a-volume).
223206
224207
When a volume contains data from a Secret, and that Secret is updated, Kubernetes tracks
225208
this and updates the data in the volume, using an eventually-consistent approach.
@@ -638,13 +621,28 @@ A `kubernetes.io/service-account-token` type of Secret is used to store a
638621
token credential that identifies a
639622
{{< glossary_tooltip text="service account" term_id="service-account" >}}.
640623

641-
Since 1.22, this type of Secret is no longer used to mount credentials into Pods,
642-
and obtaining tokens via the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
643-
API is recommended instead of using service account token Secret objects.
644-
Tokens obtained from the `TokenRequest` API are more secure than ones stored in Secret objects,
645-
because they have a bounded lifetime and are not readable by other API clients.
646-
You can use the [`kubectl create token`](/docs/reference/generated/kubectl/kubectl-commands#-em-token-em-)
624+
{{< note >}}
625+
Versions of Kubernetes before v1.22 automatically created credentials for
626+
accessing the Kubernetes API. This older mechanism was based on creating token
627+
Secrets that could then be mounted into running Pods.
628+
In more recent versions, including Kubernetes v{{< skew currentVersion >}}, API
629+
credentials are obtained directly by using the
630+
[TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
631+
API, and are mounted into Pods using a
632+
[projected volume](/docs/reference/access-authn-authz/service-accounts-admin/#bound-service-account-token-volume).
633+
The tokens obtained using this method have bounded lifetimes, and are
634+
automatically invalidated when the Pod they are mounted into is deleted.
635+
636+
You can still
637+
[manually create](/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-service-account-api-token)
638+
a service account token Secret; for example, if you need a token that never
639+
expires. However, using the
640+
[TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/)
641+
subresource to obtain a token to access the API is recommended instead.
642+
You can use the
643+
[`kubectl create token`](/docs/reference/generated/kubectl/kubectl-commands#-em-token-em-)
647644
command to obtain a token from the `TokenRequest` API.
645+
{{< /note >}}
648646

649647
You should only create a service account token Secret object
650648
if you can't use the `TokenRequest` API to obtain a token,

0 commit comments

Comments
 (0)