-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop recommending people scrape auto-generated service account tokens #31845
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,21 +146,26 @@ data: | |
extra: YmFyCg== | ||
``` | ||
|
||
When creating a `Pod`, Kubernetes automatically creates a service account Secret | ||
and automatically modifies your Pod to use this Secret. The service account token | ||
Secret contains credentials for accessing the API. | ||
|
||
The automatic creation and use of API credentials can be disabled or | ||
overridden if desired. However, if all you need to do is securely access the | ||
API server, this is the recommended workflow. | ||
|
||
See the [ServiceAccount](/docs/tasks/configure-pod-container/configure-service-account/) | ||
documentation for more information on how service accounts work. | ||
You can also check the `automountServiceAccountToken` field and the | ||
`serviceAccountName` field of the | ||
[`Pod`](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core) | ||
for information on referencing service account from Pods. | ||
|
||
{{< note >}} | ||
Automatic creation of API credentials in secrets to mount into running pods | ||
is no longer used in v1.22 and newer versions. Instead, API credentials are | ||
obtained directly by using the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) API, | ||
and are mounted into Pods using a [projected volume](/docs/reference/access-authn-authz/service-accounts-admin/#bound-service-account-token-volume). | ||
The tokens obtained using this method have bounded lifetimes, and are automatically | ||
invalidated when the Pod they are mounted into is deleted. | ||
|
||
Service account token secrets can still be created manually if you need a token that never expires, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, service account token secrets support revocation, which I don't know that TokenRequest allows in a meaningful way. It's unfortunate that to get revocation, you need to have the contents visible to the client, but I guess it's a useful tradeoff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tokens returned by tokenrequest can be revoked by deleting the associated service account. A secondary object (pod or secret) can also be referenced in the token request, and deletion of that secondary object revokes the token as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there doc that describes how to bind the token request to a secret so it can be revoked? I guess not - I can open an issue to track that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @smarterclayton yes please (to the new issue) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just the field-level API doc. there's a |
||
However, using the [TokenRequest](/docs/reference/kubernetes-api/authentication-resources/token-request-v1/) | ||
API to obtain a token to access the API is recommended instead. | ||
{{< /note >}} | ||
|
||
### Docker config Secrets | ||
|
||
You can use one of the following `type` values to create a Secret to | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are TokenRequests a subresource of ServiceAccount? I think they are, but it's not 100% clear from my understanding of what counts as a subresource.
We should aim to clarify that in the reference for ServiceAccount: https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, they are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, then I recommend using the term subresource to make that more clear.