Run a command in all pods
Runs the command in every pod that matches the label selector
kubectl get pods -n <ns> -l app=<label> -o name | xargs -I{} kubectl exec {} -n <ns> -- <cmd>
- tool
- kubectl73 commands
More kubectl commands
-
kubectl get pods -n <ns> -wKeeps the pod list on screen and updates it when a status changes
-
kubectl top pods -A --sort-by=cpuPod resource usage in all namespaces, sorted by CPU
-
kubectl create token <sa-name> -n <ns> --duration=1hGenerates a short-lived bound token, here valid for 1 hour
-
kubectl auth can-i --list -n <ns>Shows everything the current user can do in the namespace
-
kubectl delete pods --all -n <ns>Forces all pods to be recreated; handy after a ConfigMap change