[Feature Request] Dedicated kubeconfig path (avoid merging into first $KUBECONFIG file)
Description
This is a suggestion/enhancement, not a bug report. Current behaviour is intentional after #978.
Current behaviour
On Kubernetes start, Colima writes host kubeconfig in environment/container/kubernetes/kubeconfig.go:
- Default dest is
~/.kube/config. - If
KUBECONFIGis set, dest is the first file in the list (filepath.SplitList(...)[0]). - Colima merges the new
colimacontext into that dest file (kubectl config view --rawwithKUBECONFIG=<dest>:<temp>), then overwrites dest with the merge. --activate/autoActivateonly runskubectl config use-context; it does not change the write path.
That matches #978 ("always use the first configured one as the location to save the config").
Why this is painful
Some of us keep one kubeconfig file per cluster and compose them:
export KUBECONFIG=~/.kube/config:~/.kube/alex-danilin:~/.kube/rodman:...(or a glob of ~/.kube/*). In that layout, dest must be a Colima-only file. If KUBECONFIG is built alphabetically and ~/.kube/config is missing, Colima merges colima into whatever happens to be first (another cluster's file), and sets current-context there.
There is no flag or colima.yaml key for the dest path. --k3s-arg=--write-kubeconfig=... only affects the VM; Colima still copies /etc/rancher/k3s/k3s.yaml onto the host itself.
Related comments already on #978:
- https://github.com/abiosoft/colima/pull/978#issuecomment-2697503576 — split/readonly kubeconfigs; want a dump command and an option not to alter host kubeconfig
- https://github.com/abiosoft/colima/pull/978#issuecomment-2833417681 — direnv
$KUBECONFIG; k3s--write-kubeconfigdoes not help on the host
Possible enhancements (any one would help)
- Explicit dest path, e.g.
colima start --kubeconfig ~/.kube/configorkubernetes.kubeconfig: ~/.kube/configincolima.yaml. - Do not merge: write a Colima-only file (or skip host kubeconfig updates entirely).
- Dump command:
colima kubernetes kubeconfig(print the rewritten k3s kubeconfig to stdout) so users can redirect it themselves.
Happy to keep using "put a Colima-only ~/.kube/config first in $KUBECONFIG" as the workaround. Opening this so contributors can consider a first-class option for split-kubeconfig workflows.
Source: abiosoft/colima