abiosoft / abiosoft/colima

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

Đang mở
#1,627 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
30.8k
Fork
613
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.