Apply with prune kubectl
Apply manifests and remove stale objects matching the label selector
kubectl apply -f ./dir/ --prune -l app=<label> -n <ns>
more kubectl
all 73 commands →
Diff live vs local
kubectl diff -f file.yaml
Exec command in all pods
kubectl get pods -n <ns> -l app=<label> -o name | xargs -I{} kubectl exec {} -n <ns> -- <cmd>
Watch pod status changes
kubectl get pods -n <ns> -w
Top pods by CPU
kubectl top pods -A --sort-by=cpu
Create ServiceAccount token
kubectl create token <sa-name> -n <ns> --duration=1h