k9s
k9s copied to clipboard
Support kubectl alias if command is not in your path

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.
@cawoodm in the short term you could make a small wrapper and put it in your path aka
!# /bin/sh
microk8s kubectl $@
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
@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=...
.
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