Apply with prune
Apply manifests and remove stale objects matching the label selector
kubectl apply -f ./dir/ --prune -l app=<label> -n <ns>
More kubectl commands
-
kubectl diff -f file.yamlShow what would change if you applied this manifest now
-
kubectl get pods -n <ns> -l app=<label> -o name | xargs -I{} kubectl exec {} -n <ns> -- <cmd>Run a command in every pod matching a label selector
-
kubectl get pods -n <ns> -wLive-refresh pod list as statuses change
-
kubectl top pods -A --sort-by=cpuCPU-sorted pod usage across all namespaces
-
kubectl create token <sa-name> -n <ns> --duration=1hGenerate a short-lived bound service account token