k9s icon indicating copy to clipboard operation
k9s copied to clipboard

Support kubectl alias if command is not in your path

Open cawoodm opened this issue 2 years ago • 4 comments




Is your feature request related to a problem? Please describe. It would be nice if K9S would pick op on a kubectl alias where the actual kubectl executable is not installed but available via an alias.

Describe the solution you'd like When using K3S or MicroK8S there is no kubectl executable anywhere but rather microk8s kubectl is used. Most users define an alias kubectl='microk8s kubectl' which lets ordinary users work with the kubectl alias. K9S does not recognise this but is searching for a file called kubectl on the PATH.

Describe alternatives you've considered No ideas.

Additional context Add any other context or screenshots about the feature request here.

image

image

cawoodm avatar Mar 28 '22 11:03 cawoodm

@cawoodm in the short term you could make a small wrapper and put it in your path aka

!# /bin/sh

microk8s kubectl $@

JefeDavis avatar Apr 23 '22 06:04 JefeDavis

I am actually curious why the kubectl binary is needed at all since several of the cli-runtimes for kubectl are already being imported, it should be possible to use the exposed go modules for everything and only require the binary if a plugin needs it

JefeDavis avatar Apr 23 '22 06:04 JefeDavis

@cawoodm in the short term you could make a small wrapper and put it in your path aka

!# /bin/sh

microk8s kubectl $@

This doesn't work, as k9s appears to rely on $KUBECONFIG (e.g. ~/.kube/config). microk8s kubectl and friends are sandboxed elsewhere by snap. mkdir -p ~/.kube && microk8s config > ~/.kube/config (once per microk8s (re)install) before running the wrapper script would work though, unless k9s itself is installed via snap, which requires explicit k9s --kubeconfig=....

vicaya avatar May 05 '22 20:05 vicaya

It’s actually a pain to rely on kubectl too much since some versions (like k3s) do weird things like ignore ~/.kube/config preferring /etc/rancher/k3s/k3s.yaml

cawoodm avatar May 06 '22 05:05 cawoodm