-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use yq and helmfile build to dynamically deploy helm charts based on …
…release name. (#300)
- Loading branch information
Showing
1 changed file
with
10 additions
and
6 deletions.
There are no files selected for viewing
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
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 |