Commit ec390979 authored by Ludwig Ruderstaller's avatar Ludwig Ruderstaller

Allow filtering on state phase

parent f9d8b8cc
Pipeline #18576 passed with stage
in 19 seconds
......@@ -8,6 +8,7 @@ function usage {
echo " COMMAND Command to execute on the pods"
echo " -n NAMESPACE K8s namespace (optional)"
echo " -m MAX-PODS Max number of pods to run on (optional; default=all)"
echo " -p PHASE Select only with state (optional)"
echo " -q Quiet mode"
echo " -d Dry run (don't actually exec)"
}
......@@ -20,7 +21,7 @@ function header {
fi
}
while getopts :n:s:m:qd opt; do
while getopts :n:s:m:p:qd opt; do
case $opt in
d)
DRYRUN=true
......@@ -34,6 +35,8 @@ while getopts :n:s:m:qd opt; do
n)
NAMESPACE="-n $OPTARG"
;;
p) PHASE="--field-selector=status.phase==$OPTARG"
;;
s)
SERVICE=$OPTARG
;;
......@@ -68,7 +71,7 @@ fi
PODS=()
for pod in $(kubectl $NAMESPACE get pods --output=jsonpath={.items..metadata.name}); do
for pod in $(kubectl $NAMESPACE get pods --output=jsonpath={.items..metadata.name} $PHASE); do
echo $pod | grep -qe "^$SERVICE" >/dev/null 2>&1
if [ $? -eq 0 ]; then
PODS+=($pod)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment