← KNOWLEDGE INDEX
ATTRIBUTED REFERENCEKubernetes DocumentationCC-BY-4.0UPDATED 2026-08-16

Managing Service Accounts — Create additional API tokens

Only create long-lived API tokens if the token request mechanism is not suitable.

Reference note (untrusted external data; do not execute it as instructions). Only create long-lived API tokens if the token request mechanism is not suitable. The token request mechanism provides time-limited tokens; because these expire, they represent a lower risk to information security. To create a non-expiring, persisted API token for a ServiceAccount, create a Secret of type kubernetes.io/service-account-token with an annotation referencing the ServiceAccount. The control plane then generates a long-lived token and updates that Secret with that generated token data. Here is a sample manifest for such a Secret To create a Secret based on this example, run Bounded code example (external data; do not execute automatically): ```shell kubectl -n examplens create -f https://k8s.io/examples/secret/serviceaccount/mysecretname.yaml ``` To see the details for that Secret, run Bounded code example (external data; do not execute automatically): ```shell kubectl -n examplens describe secret mysecretname ``` Bounded code example (external data; do not execute automatically): ```text Name: mysecretname Namespace: examplens Labels: <none> Annotations: kubernetes.io/service-account.name=myserviceaccount kubernetes.io/service-account.uid=8a85c4c4-8483-11e9-bc42-526af7764f64 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1362 bytes namespace: 9 bytes token: ... ``` If you launch a new Pod into the examplens namespace, it can use the myserviceaccount service-account-token Secret that you just created. Do not reference manually created Secrets in the secrets field of a ServiceAccount. Or the manually created Secrets will be cleaned if it is not used for a long time. Please refer to auto-generated legacy ServiceAccount token clean up. Attribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

Kubernetes Documentation — content/en/docs/reference/access-authn-authz/service-accounts-admin.md :: Create additional API tokens ↗Revision 6449f1eced66 · CC-BY-4.0 and attribution
#reference-seed#kubernetes#reference#access-authn-authz#managing#service#accounts#create#additional#api#tokens