Kubernetes¶
Quick Reference¶
| Alias | Action |
|---|---|
k |
kubectl |
kx |
Switch context (kubectx) |
kns |
Switch namespace (kubens) |
kt |
Tail pod logs (kubetail) |
kgpa |
Get all pods, all namespaces |
kgp |
Get pods |
kgs |
Get services |
kgd |
Get deployments |
kgn |
Get nodes |
Debugging¶
Debug Pod¶
Launch an ephemeral pod for debugging:
kdebug # busybox in default namespace
kdebug -n kube-system # in specific namespace
kdebug -i nicolaka/netshoot # with custom image
kdebug -- curl http://my-svc # run a specific command
Admin Pod (Network Debugging)¶
Launch a netshoot pod with full networking tools:
kadmin # in default namespace
kadmin -n kube-system # in specific namespace
kadmin -- dig kubernetes.default # DNS lookup
kadmin -- tcpdump -i eth0 # Packet capture
Cluster Operations¶
Clean Up Pods¶
Or via task:
Drain Cordoned Nodes¶
Finds all cordoned (unschedulable) nodes and drains them.
Delete Namespaces¶
# By prefix
kdelete_namespaces_with_prefix dev-
# Empty namespaces
kdelete_empty_namespaces
kdelete_empty_namespaces --yes # Skip confirmation
kdelete_empty_namespaces --prefix test- # Only matching prefix
Remove Stuck Finalizers¶
When a resource won't delete because of finalizers:
Inspection¶
Pods by Node¶
Pods by Label¶
K9s¶
K9s is a terminal UI for Kubernetes.
Theme¶
Uses Catppuccin Mocha with multiple variants available:
catppuccin-mocha(default)catppuccin-macchiatocatppuccin-frappecatppuccin-latte- Transparent variants
- Nord
Custom Aliases¶
| Shortcut | Resource |
|---|---|
dp |
Deployments |
sec |
Secrets |
jo |
Jobs |
cr |
ClusterRoles |
crb |
ClusterRoleBindings |
ro |
Roles |
rb |
RoleBindings |
np |
NetworkPolicies |
Resource Thresholds¶
- CPU: Warning at 70%, Critical at 90%
- Memory: Warning at 70%, Critical at 90%
Shell Pod¶
K9s shell pods use busybox:1.35.0 with:
- CPU: 100m
- Memory: 100Mi
- Namespace: default
Inline Resource Editor¶
Create or apply Kubernetes manifests inline:
Opens an inline editor for quick YAML editing without creating files.