Advertisement
SimpleCookie

Untitled

Nov 16th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Get a list of pod names with the container "pant-potatis"
  4. pod_names=($(oc get pods --field-selector=status.phase=Running -o jsonpath='{.items[?(@.spec.containers[*].name=="pant-potatis")].metadata.name}'))
  5.  
  6. # Check if there are any pods with the specified container
  7. if [ ${#pod_names[@]} -eq 0 ]; then
  8. echo "No pods with container 'pant-potatis' found."
  9. exit 1
  10. fi
  11.  
  12. # Get a random pod name
  13. random_pod="${pod_names[RANDOM % ${#pod_names[@]}]}"
  14.  
  15. echo "Random Pod Name with 'pant-potatis' container: $random_pod"
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement