Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use yq and helmfile build to dynamically deploy helm charts based on release name. #300

Merged
merged 3 commits into from
Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions conf/patches/gke-helmfile-deployment.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/bash

for filename in ${CONF_PATH_PREFIX}/conf/helmfile.d/*.yaml; do
deployment_name=$(grep "\- name: " ${filename} | grep -m1 -v "\- name: \"stable\"" | awk '{print $3}' | sed 's/^\"\(.\+\)\"$/\1/')
deployment_names=$(helmfile -f $filename build | \
yq r - -- releases[*].name | awk '{print $2}')
for name in $deployment_names; do
# TODO: use retry command instead of for loop.
retries=3
for ((i=0; i<retries; i++)); do
helmfile --selector name=${deployment_name} sync
[[ $? -eq 0 ]] && break
echo "Something went wrong while deploying ${deployment_name}. Retrying in 30 seconds."
helm delete ${deployment_name} --purge
sleep 30
helmfile --selector name=${name} sync
[[ $? -eq 0 ]] && break
echo "Something went wrong while deploying ${name}. Retrying in 30 seconds."
helm delete ${name} --purge
sleep 30
done
done
done