Created
November 5, 2021 14:05
-
-
Save redsfyre/81bc2dd2111b5b06460a4503df6fba5e to your computer and use it in GitHub Desktop.
Script that stops (suspends) all running kubernetes cronjobs
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 | |
for ns in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}"); do | |
for cj in $(kubectl get cronjobs -n "$ns" -o name); do | |
kubectl patch "$cj" -n "$ns" -p '{"spec" : {"suspend" : true }}'; | |
done | |
done |
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 | |
for line in $(cat crons.txt); do | |
kubectl patch cronjob.batch/"$line" -p '{"spec" : {"suspend" : false }}'; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment