Last active
December 6, 2017 08:28
-
-
Save notxcain/ac29f5526a89ab6348ec9c0d3c30ec38 to your computer and use it in GitHub Desktop.
Continuously kill all pods except one randomly chosen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| app=$1 | |
| chosen_one=$(kubectl get pods -l app=$app | tail -1 | awk '{print $1}') | |
| echo "Keeping alive $chosen_one" | |
| while true; do | |
| pods=$(kubectl get pods -l app=$app | tail -n +2 | awk '{print $1}') | |
| for pod in $pods; do | |
| if [[ $pod != $chosen_one ]]; then | |
| echo "Killing $pod" | |
| kubectl delete po $pod | |
| fi | |
| done | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment