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

Write kubeconfig to KUBECONFIG defined file #978

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

Conversation

Sumoa
Copy link

@Sumoa Sumoa commented Feb 6, 2024

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.

@abiosoft
Copy link
Owner

@Sumoa can you kindly rebase? I fixed the broken CI.

@Sumoa Sumoa force-pushed the main branch 4 times, most recently from aec4111 to 0c03784 Compare April 3, 2024 10:07
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]
Copy link
Owner

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.

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.

3 participants