Skip to content

Instantly share code, notes, and snippets.

@tossmilestone
Created May 20, 2019 04:33
Show Gist options
  • Save tossmilestone/5a7e2e37d6956923b29aabf73340424d to your computer and use it in GitHub Desktop.
Save tossmilestone/5a7e2e37d6956923b29aabf73340424d to your computer and use it in GitHub Desktop.
Run command for each pod in a workload
#!/bin/bash
PODS=$(kubectl get pods -n alauda-system |grep Running|grep $1|awk '{print $1}')
ARGS=${@:2}
for POD in $PODS
do
echo "Exec $ARGS on pod $POD"
kubectl exec -it -n alauda-system $POD -c $1 -- ${ARGS[@]}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment