Installing K9s for K3s Kubernetes Cluster
Posted December 10, 2024
If you are looking for those fancy yet great CLIEs to manage your K3s Cluster, this guide is for you. K9s is expressly created as a terminal-based Kubernetes UI. It lets you interact with Kubernetes (K3s) and navigate through clusters without kubectl.
K9s work with any Kubernetes distributions. That’s why this guide is here: to teach you how to install K9s and configure them to manage a K3s cluster. Come along with this tutorial and learn configuring K9s for K3s Kubernetes Cluster.
A Little About K9s
K9s is intuitive and fast. Its UI is a great monitor and manipulate Kubernetes resources to your liking. (See image below: K9s access to pods)
To use K9s, you must have configured the Kubernetes cluster. Here, I will use K9s to connect a K3s installed on Ubuntu.
Installing K9s
K9s work with all sorts of environments and operating systems. Check this guide to get the installation instructions.
Because I’m on Ubuntu, I will use the following command:
sudo wget https://github.com/derailed/k9s/releases/download/v0.32.7/k9s_linux_amd64.deb && apt install ./k9s_linux_amd64.deb && rm k9s_linux_amd64.deb
Once installed, use the following command to check if K9s is ready:
k9s info
You should expect the following output:
Adding K3s to K9s
At the moment K9s doesn’t have access to any cluster. You can confirm so by launching the K9s UI:
k9s
At this moment, K9s only need access to K3s ~/.kube/config
. K9s may automatically use your existing kubeconfig. However, for K3s, you will need to point K9s to the K3s KUBECONFIG environment variable.
K9s must leverage K3s KUBECONFIG environment variable at etc/rancher/k3s/k3s.yaml
. You will use the following command:
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
Launch K9s again and you should have access to K3s as such:
k9s
And yes It’s working. Check these details:
Context: default … ____ __.________
Cluster: default | |/ _/ __ \______
User: default | < \____ / ___/
K9s Rev: v0.32.7 | | \ / /\___ \
K8s Rev: v1.30.6+k3s1 |____|__ \ /____//____ >
CPU: 18% \/ \/
MEM: 61%
If you have pods running on the default namespace, they will be listed as such.
K9s K3s Cheat Sheet
You gotta have some quick command to manage K3s. K9s will easily access resources like pods, namespaces, and ingress with shortcut operations like :
to navigate to the command prompt in K9s. For example:
:ns
: Switch namespaces.:pod
: List all pods.:ing
: List all ingresses.:deploy
: List all deployments.:svc
: List all services.
For example, you will just need to press :
Then type deploy
and enter to list deployments:
You have other K9s management Shortcuts like:
q
- Quit the current screen./
- Search within the current resource list.Ctrl+c
- Exit K9s.Esc
- Return to the previous screen.e
- Edit the resource (like a Pod or Deployment).d
- Delete a resource (e.g., Pod, Deployment).l
- View logs of a resource.
Check k9s docs for more customizations.
If you need help with K9s or K3s, let me know!