#1627·colima

[Feature Request] Dedicated kubeconfig path (avoid merging into first $KUBECONFIG file)

Author: NoksaCreated Aug 25, 2026Updated Aug 25, 2026

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:

  1. Default dest is ~/.kube/config.
  2. If KUBECONFIG is set, dest is the first file in the list (filepath.SplitList(...)[0]).
  3. Colima merges the new colima context into that dest file (kubectl config view --raw with KUBECONFIG=<dest>:<temp>), then overwrites dest with the merge.
  4. --activate / autoActivate only runs kubectl 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:

bash
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:

Possible enhancements (any one would help)

  1. Explicit dest path, e.g. colima start --kubeconfig ~/.kube/config or kubernetes.kubeconfig: ~/.kube/config in colima.yaml.
  2. Do not merge: write a Colima-only file (or skip host kubeconfig updates entirely).
  3. 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.