Skip to content

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?

@lalyos lalyos force-pushed the templatable-contextname branch from 6fc02d8 to da953c2 Compare September 26, 2022 16:16
@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