Created
March 10, 2019 20:03
-
-
Save hasantayyar/e84714d3ed44ae2301472f1d24aef82d to your computer and use it in GitHub Desktop.
Deploy missing deployment to clusters
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
PROJECT="your-project-name" | |
SEARCH=$1 | |
FILE=$2 | |
CLUSTER_FILTER=$3 | |
if [ -z $SEARCH ]; then | |
echo "Missing param. 1st param is the search phrase" | |
exit 1 | |
fi | |
if [ -z $FILE ]; then | |
echo "Missing param. 2nd param is the config path" | |
exit 1 | |
fi | |
if [ -z $CLUSTER_FILTER ]; then | |
echo "Missing param. 3nd param is the search term for clusters to be updated" | |
exit 1 | |
fi | |
set -ex | |
for STR in $(gcloud container clusters list --filter="name:${CLUSTER_FILTER}" |awk '{print $1","$2}'); do | |
CLUSTER=$(echo $STR | cut -f1 -d,) | |
ZONE=$(echo $STR | cut -f2 -d,) | |
gcloud container clusters get-credentials $CLUSTER --zone $ZONE --project $PROJECT > /dev/null | |
CHECK=$(kubectl get pods |grep $SEARCH) | |
if [ -z $CHECK ]; | |
then | |
echo ">>> Deploy $FILE to $CLUSTER" | |
kubectl apply $FILE | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment