Last active
December 13, 2018 09:13
-
-
Save wshino/e0473c3c390d7aee27e9c5912fcdc1c6 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
#!/bin/bash | |
function usage { | |
echo " Description" | |
echo " this shell script uses for when updating lots of images." | |
echo "" | |
echo " Usage:" | |
echo " $ ./set-image.sh SEARCH_NAME SEARCH_VERSION TARGET_VERSION" | |
echo " * SEARCH_NAME: query for container image name" | |
echo " * SEARCH_VERSION: query for container image tag" | |
echo " * TARGET_VERSION: target tag for set image command" | |
exit 1 | |
} | |
[ -z $1 ] && { usage; } | |
SEARCH_NAME=$1 | |
SEARCH_VERSION=$2 | |
TARGET_VERSION=$3 | |
TARGETS=`kubectl get deployment --output=json | jq ".items[] | select(.spec.template.spec.containers[].image | test(\"${SEARCH_NAME}:${SEARCH_VERSION}\")) | .metadata.name" -r` | |
for target in ${TARGETS[@]}; do | |
"kubectl set image deployment.v1.apps/$target ${SEARCH_NAME}=${SEARCH_NAME}:${TARGET_VERSION} --record" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment