k9s + microk8s

k9s is an awesome way to manage kubernetes/microk8s over ssh since it offers a text-based UI.

To install:

$ sudo snap install k9s

To make k9s see local microk8s instance:

$ microk8s.kubectl config view --raw > $HOME/.kube/config

Logs

If k9s isn’t working correctly, the details may be in the log. Run k9s info to reveal the location of the log file (in my case /tmp/k9s-root.log), then run

$ tail -f /tmp/k9s-root.log

to reveal the log.

kubectl

Trying to access shell fails with Shell exec failed. Looking into k9s logs it reveals that kubectl command is not in your path error="exec: \"kubectl\": executable file not found in $PATH".

Unfortunately, creating an alias via alias kubectl="microk8s kubectl" is not enough.

The easiest way is to install kubectl client:

$ sudo snap install kubectl --classic
$ kubectl get pod --all-namespaces

Tips

Written on January 10, 2025