π₯ K9s Cheat Sheet β The Ultimate Guide
Posted February 11, 2025

Are using K9s terminal UI for managing Kubernetes clusters? Dive and master a K9s Cheat Sheet.
If you wanna navigate faster, troubleshoot, and control your cluster like a pro, this guideβs Cheat Sheet got you covered.
π 1. Starting k9s
Command | Description |
---|---|
k9s |
Launch k9s using the default kubeconfig |
k9s -n <namespace> |
Start k9s in a specific namespace |
k9s --context <context> |
Start k9s with a specific cluster context |
k9s --kubeconfig <path> |
Use a different kubeconfig file |
k9s --readonly |
Run k9s in read-only mode (no changes allowed) |
π― 2. Navigation Shortcuts
Key | Action |
---|---|
: |
Enter command mode |
/ |
Filter resources (by name or label) |
Esc |
Clear filters or exit a view |
Ctrl + A |
Toggle between current namespace & all namespaces |
Tab |
Switch between views (YAML, logs, etc.) |
Ctrl + C |
Exit k9s |
π 3. Switching Namespaces & Clusters
Command | Description |
---|---|
:ns |
Show and switch namespaces |
0 |
List available cluster contexts and switch |
:ctx |
Show current cluster contexts |
:context <name> |
Switch to a different cluster context |
kubectl config use-context <context> |
Change cluster before launching k9s |
Related: K9s for K3s Kubernetes Cluster
π 4. Viewing & Managing Kubernetes Resources
Command | Description |
---|---|
:pods |
Show all Pods |
:deploy |
Show all Deployments |
:svc |
List all Services |
:ing |
Show all Ingresses |
:nodes |
Show all Nodes |
:cm |
Show ConfigMaps |
:sec |
Show Secrets |
:jobs |
Show Jobs |
πΉ Sorting & Filtering
Key | Action |
---|---|
Shift + i |
Sort by CPU usage |
Shift + o |
Sort by Memory usage |
Shift + p |
Sort by Pod restarts |
π 5. Debugging & Logs
Key | Action |
---|---|
l |
View logs of selected Pod |
Shift + l |
View logs of a specific container inside a Pod |
Ctrl + f |
Search logs |
Shift + f |
Toggle log auto-scroll |
Ctrl + s |
Save logs to a file |
πΉ Follow logs in real-time (CLI)
kubectl logs -f <pod-name>
π οΈ 6. Executing Commands in a Pod
Key | Description |
---|---|
Shift + x |
Open a shell inside a running Pod |
πΉ Manually via CLI
kubectl exec -it <pod-name> -- /bin/sh
For Debian/Ubuntu:
kubectl exec -it <pod-name> -- /bin/bash
For Alpine-based containers:
kubectl exec -it <pod-name> -- /bin/ash
For Debian/Ubuntu:
kubectl exec -it <pod-name> -- /bin/bash
π 7. Restarting & Scaling Pod Resources
Key | Description |
---|---|
r |
Restart a Pod |
Shift + r |
Restart multiple selected Pods |
:scale <deployment> <replicas> |
Scale a Deployment up/down |
Example:
:scale my-app-deployment 5
π 8. Port Forwarding
Key | Description |
---|---|
Shift + f |
Port-forward a Pod |
πΉ Manually via CLI
kubectl port-forward <pod-name> 8080:80
For a Service:
kubectl port-forward svc/<service-name> 9090:80
π 9. Managing Secrets & ConfigMaps
Command | Description |
---|---|
:sec |
Show all Secrets |
:cm |
Show all ConfigMaps |
πΉ Decode a Secret (CLI)
kubectl get secret <secret-name> -o jsonpath="{.data.<key-name>}" | base64 --decode
π 10. Checking Node Health Status & Metrics
Key | Description |
---|---|
:nodes |
Show all Nodes |
Shift + m |
Show node metrics (CPU, memory) |
πΉManually via CLI
kubectl get nodes -o wide
kubectl describe node <node-name>
π¨ 11. Switching k9s UI Themes
Change k9s theme by editing the config:
nano ~/.k9s/config.yaml
Add or update:
k9s:
ui:
skin: <dark|light|custom>
π 12. Running k9s in Safe Mode
Wanna make sure nothing gets messed up? Run in read-only mode to prevent accidental changes:
k9s --readonly
π 13. Handling Multiple Kubeconfig File
If youβre juggling multiple kubeconfig files, merge them:
KUBECONFIG=/path1/config:/path2/config kubectl config view --merge --flatten > ~/.kube/config
β 14. Quitting k9s
Key | Description |
---|---|
Ctrl + C |
Quit k9s |
:q or :quit |
Quit k9s |
π― Wrapping up!
And thatβs it! Now youβre a k9s ninja with a complete K9s Cheat Sheet! If you need more details, hit me up! ππ