Skip to content

Instantly share code, notes, and snippets.

@converge
Created October 5, 2023 17:19
Show Gist options
  • Save converge/09d43bbfa010374dff61fa1d97999213 to your computer and use it in GitHub Desktop.
Save converge/09d43bbfa010374dff61fa1d97999213 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Replace 'your-namespace' with the actual namespace
namespace="keda"
# List of pods to check
pod_list=("keda-admission-9c44fd597-wtkcm")
while true; do
all_running=true # Flag to track if all pods are running
for pod_name in "${pod_list[@]}"; do
# Get the pod status using kubectl
pod_status=$(kubectl get pod "$pod_name" -n "$namespace" --no-headers=true | awk '{print $3}')
# Check if the pod is in the "Running" state
if [ "$pod_status" != "Running" ]; then
all_running=false
echo "Pod $pod_name is not running yet. Current status: $pod_status"
fi
done
if $all_running; then
echo "All pods are now running."
break # Exit the loop when all pods are running
fi
sleep 5 # Adjust the sleep interval as needed
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment