Skip to content

Commit

Permalink
Add chaos monkey script
Browse files Browse the repository at this point in the history
  • Loading branch information
GillisWerrebrouck committed Jan 18, 2020
1 parent aaf6332 commit 55d58a1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions chaos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Randomly delete pods in a Kubernetes namespace.
# Pods with label 'chaos=immune' will be spared.
set -ex

: ${DELAY:=30}
: ${NAMESPACE:=default}

while true; do
kubectl \
--namespace "${NAMESPACE}" \
-o 'jsonpath={.items[*].metadata.name}' \
-l 'chaos!=immune' \
get pods | \
tr " " "\n" | \
shuf | \
head -n 1 |
xargs -t --no-run-if-empty \
kubectl --namespace "${NAMESPACE}" delete pod
sleep "${DELAY}"
done

0 comments on commit 55d58a1

Please sign in to comment.