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

Incorrect cached token fetched with multiple kubeconfigs #592

Closed
sheldonkwok opened this issue Feb 18, 2021 · 7 comments
Closed

Incorrect cached token fetched with multiple kubeconfigs #592

sheldonkwok opened this issue Feb 18, 2021 · 7 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@sheldonkwok
Copy link
Contributor

When using multiple kubeconfig files with the same user.name field, the kubeconfig user that is fetched first for execAuth will be used for all subsequent users that match the same name.

The issue arises here.
https://github.com/kubernetes-client/javascript/blob/master/src/exec_auth.ts#L74

I'm not sure if it's an antipattern to use multiple kubeconfigs but maybe we could document this if we don't want to fix it. Having different user names is easy enough. We could also hash the whole user object to cache instead of the name. I can implement this solution or another proposed solution if we want to address this.

@brendandburns
Copy link
Contributor

Multiple kubeconfigs is really not supported very well in this client. It is definitely an unusual configuration in the wild.

That said, I'd be happy to take PRs to improve the handling of multiple kubeconfig files (or providing more explicit "we don't support this" messages)

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 20, 2021
@sheldonkwok
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 21, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 19, 2021
@sheldonkwok
Copy link
Contributor Author

#658
provides documentation

@mhaddon
Copy link

mhaddon commented Nov 23, 2021

Cant we resolve this by increasing the specificity of the cache?

Such as, instead of const cachedToken = this.tokenCache[user.name];

Then the cache index includes the cluster name + cluster server + username?

@LeoK80
Copy link

LeoK80 commented Dec 8, 2023

As a work around could you perhaps merge multiple kubeconfig files into one?

This still allows you to switch the 'current context' of which there only should be 1 field. The config.ts KubeConfig Class does seem to provide a public method to set the current context to a new value, effectively allowing you to target other clusters without requiring multiple kubeconfig files.

public setCurrentContext(context: string): void {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

7 participants