abiosoft / abiosoft/colima

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

Abierto
#1,627 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Go
Estrellas
30.8k
Forks
613
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.