Created
August 23, 2019 07:30
-
-
Save monsterxx03/9046916fde705e73992a9857a5875ae2 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
: ' | |
Simulate `kubectl rollout restart` commnad in 1.15. | |
' | |
set -o pipefail | |
set -o nounset | |
set -o errexit | |
usage() { | |
cat <<EOF | |
Usage: kubectl restart -d <deployment name> -n <namespace> | |
example: | |
kubectl restart -d nginx -n test-ns | |
EOF | |
exit 0 | |
} | |
[[ $# -eq 0 ]] && usage | |
NAMESPACE="default" | |
DEPLOYMENT="" | |
while getopts ":n:d:h" arg; do | |
case $arg in | |
n) # namespace | |
NAMESPACE=${OPTARG} | |
;; | |
d) # deployment name | |
DEPLOYMENT=${OPTARG} | |
;; | |
h) # Display help | |
usage | |
;; | |
*) | |
;; | |
esac | |
done | |
[[ -z $DEPLOYMENT ]] && echo "missing deployment name" && exit 1 | |
kubectl patch deployment $DEPLOYMENT -n $NAMESPACE -p '{"spec": {"template": {"metadata": {"annotations": {"cliRestartAt": "'$(date +%s)'"}}}}}' | |
kubectl rollout status -n $NAMESPACE deployment/${DEPLOYMENT} -w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment