kubectl Cheatsheet
A quick reference for the kubectl commands most commonly needed when operating the platform.
What this page covers
- Cluster inspection commands
- Pod and deployment management
- Log access and exec into containers
- Namespace operations
- Persistent volume inspection
- Debugging tips
Essential commands
# Cluster health
kubectl get nodes
kubectl get pods -A
kubectl top nodes
kubectl top pods -A
# Inspect a resource
kubectl describe pod <name> -n <namespace>
kubectl describe deployment <name> -n <namespace>
# Logs
kubectl logs <pod> -n <namespace>
kubectl logs <pod> -n <namespace> --previous # previous crashed container
# Exec into a container
kubectl exec -it <pod> -n <namespace> -- sh
# Apply/delete manifests
kubectl apply -f manifest.yaml
kubectl delete -f manifest.yaml
# Force-delete a stuck pod
kubectl delete pod <name> -n <namespace> --grace-period=0 --force
Namespaces used by this guide
| Namespace | Contents |
|---|---|
kube-system |
K3s system components, Traefik |
gitea |
Gitea |
youtrack |
YouTrack |
longhorn-system |
Longhorn storage |
flux-system |
Flux CD components |
monitoring |
Prometheus, Grafana |