Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Deploy missing deployment to clusters
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
You can’t perform that action at this time.