Skip to content

Instantly share code, notes, and snippets.

@ikuwow
Created October 7, 2016 10:38
Show Gist options
  • Save ikuwow/5e8b180b89aba320dca657d9d0602dcd to your computer and use it in GitHub Desktop.
Save ikuwow/5e8b180b89aba320dca657d9d0602dcd to your computer and use it in GitHub Desktop.
#!/bin/bash
# Randomly choose pods, and kubectl exec
# usage ./kubeexec.sh hostname
pod_count=$(kubectl get pods -o name | wc -l)
pod_index=`echo "scale=0; $pod_count * $RANDOM / 32767 + 1" | bc`
pod=$(kubectl get pods -o name | awk "NR==$pod_index" | sed -e 's/pod\///g')
/usr/local/bin/kubectl exec $pod $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment