-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
Write kubeconfig to KUBECONFIG defined file #978
base: main
Are you sure you want to change the base?
Conversation
@Sumoa can you kindly rebase? I fixed the broken CI. |
aec4111
to
0c03784
Compare
Currently when starting a vm + k8s cluster the kubeconfig is always written to "~/.kube/config" which is the default path. By defining the env variable "KUBECONFIG" it is possible to override the default path. This does currently not apply to colima. As it is possible to configure multiple locations with "KUBECONFIG" I opted to always use the first configured one as the location to save the config.
@@ -42,6 +43,10 @@ func (c kubernetesRuntime) provisionKubeconfig(ctx context.Context) error { | |||
}) | |||
|
|||
kubeconfFile := filepath.Join(hostKubeDir, "config") | |||
envKubeConfFile := c.host.Env("KUBECONFIG") | |||
if envKubeConfFile != "" { | |||
kubeconfFile = strings.Split(envKubeConfFile, string(os.PathListSeparator))[0] |
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.
Actually there is an in-built function for this filepath.SplitList
https://pkg.go.dev/path/[email protected]#SplitList.
i would prefer a command to show me the kubeconfig so i can redirect to a file as i like, in addition to a config option to NOT alter my kubeconfig. I need to work with quite many clusters, which are also changing quite often. So i started to use separate readonly files (~/.kube/config.d/) and load them all as Respecting the KUBECONFIG would at least allow me to workaround the problem. Thanks @Sumoa. |
Currently when starting a vm + k8s cluster the kubeconfig is always written to "~/.kube/config" which is the default path. By defining the env variable "KUBECONFIG" it is possible to override the default path. This does currently not apply to colima.
As it is possible to configure multiple locations with "KUBECONFIG" I opted to always use the first configured one as the location to save the config.