abiosoft / abiosoft/colima

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

Aperta
#1,627 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
30.8k
Fork
613
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 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=:`), 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:

- 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-kubeconfig` does not help on the host

**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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.