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

Templatable contextname #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lalyos
Copy link

@lalyos lalyos commented Sep 26, 2022

Use-case

when I create multiple users and save the kubeconfig as documented

kubectl get kubeconfig darren -o json | jq .spec > kubeconfig-darren
kubectl get kubeconfig lalyos -o json | jq .spec > kubeconfig-lalyos

Usually its easier to switch between context, than switching between KUBECONFIGs,
so usuallymerge the together as:

export KUBECONFIG=$KUBECONFIG:./kubeconfig-darren:./kubeconfig-lalyos

but if KLUM has a fixed contextName it doesn't work.

Proposed solution

Instead of a fixed string context-name let's make it a golang template. For example:

CONTEXT_NAME=workshop-{{ .UserName }}

with the above KUBECONFIG merge it has distinct contexts:

k config get-contexts 
CURRENT   NAME              CLUSTER           AUTHINFO          NAMESPACE
*         boss              singli            singli            klum
          workshop-darren   workshop-darren   workshop-darren     
          workshop-lalyos   workshop-lalyos   workshop-lalyos

why send the PR

I've seen at dockerhub that the image was updated "4 months ago" and it has 8k pulls, so why not?

@jadolg
Copy link
Contributor

jadolg commented Feb 9, 2024

I just made a change in my fork that solves this issue differently if you're still interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants