Skip to content
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

Support scoped serviceAccount #12567

Open
lahabana opened this issue Jan 16, 2025 · 4 comments
Open

Support scoped serviceAccount #12567

lahabana opened this issue Jan 16, 2025 · 4 comments
Labels
kind/feature New feature triage/pending This issue will be looked at on the next triage meeting
Milestone

Comments

@lahabana
Copy link
Contributor

lahabana commented Jan 16, 2025

Description

  • Prior to 1.30.6, When OIDC issued service token with --service-account-extend-token-expiration set to true . With this, the service account tokens injected into pods were given an extended lifetime so they remain valid even after a new refreshed token is provided. Prior to upgrading to 1.30, the metric serviceaccount_stale_tokens_total and the audit annotation authentication.k8s.io/stale-token can be used to monitor for workloads that depend on the extended lifetime and are continuing to use tokens even after a refreshed token is provided to the container. If no action is taken, workloads depending on the extended lifetime will break once the cluster is upgraded to 1.30. See reference README.md for details.

After upgrading to 1.30.6 , It is no longer supported to change “service-account-extend-token-expiration” setting back to “True” for 1.30 OIDC enabled cluster thus this is the reason Kong Mesh CNI and egress pod were not able to renew the token and broke down with Unathorized.

We should support bounded serviceAccount as it seems to be an important security new feature in 1.30.

Docs:

https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-long-lived-api-token-for-a-serviceaccount
https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/1205-bound-service-account-tokens/README.md

Is this only for CNI or more generally for other components?

@lahabana lahabana added triage/pending This issue will be looked at on the next triage meeting kind/feature New feature labels Jan 16, 2025
@lahabana lahabana added this to the 2.10.x milestone Jan 16, 2025
@jijiechen
Copy link
Member

Correction: the bound service account feature was introduced in Kubernetes 1.22. They allow the switch service-account-extend-token-expiration to play a "deprecation period" support duing v1.22 to v1.30 and this switch was eventually removed in 1.30.

Fortunately, from my study of Kuma code base, only Kuma-CNI is being impacted by this issue.

In other components, we are either not interacting with the API server directly or not copying the token to somewhere else before we use it. The client-go will read the token file from disk every minute (link to source) and the content of the token file is maintained by Kubernetes automatically. So this is NOT an issue for components using the offical Go SDK without storing somewhere else or caching the token.

Note: If having trouble in finding places using in-cluster config completely, cluster operators can specify flag --service-account-extend-token-expiration=true to kube apiserver to allow tokens have longer expiration temporarily during the migration. Any usage of legacy token will be recorded in both metrics and audit logs. After fixing all the potentially broken workloads, turn off the flag so that the original expiration settings are honored. Note the --service-account-extend-token-expiration mitigation defaults to true, and that cluster administrators can set it to --service-account-extend-token-expiration=false to turn off the mitigation if desired.

Source: https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/1205-bound-service-account-tokens/README.md#serviceaccount-admission-controller-migration

@michaelbeaumont
Copy link
Contributor

I think #11399 solved this for kuma-dp

@jijiechen
Copy link
Member

We are using the token to authenticate DPs and this is not fixed in older versions. So our DPs, including the ingress and egress are also impacted

@bartsmykla
Copy link
Contributor

bartsmykla commented Jan 17, 2025

We are using the token to authenticate DPs and this is not fixed in older versions. So our DPs, including the ingress and egress are also impacted

Backporting done:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature triage/pending This issue will be looked at on the next triage meeting
Projects
None yet
Development

No branches or pull requests

4 participants