Skip to content

Commit

Permalink
Write kubeconfig to KUBECONFIG defined file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sumoa authored and Christof Huber committed Apr 3, 2024
1 parent 281757a commit 5caaa6d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions environment/container/kubernetes/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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, ":")[0]
}
tmpkubeconfFile := filepath.Join(hostKubeDir, "."+profile, "colima-temp")

// manipulate in VM and save to host
Expand Down

0 comments on commit 5caaa6d

Please sign in to comment.