From c8fc3f2da351bca9116b1447bceacb02da5f8483 Mon Sep 17 00:00:00 2001 From: William Graf <7930703+willgraf@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:28:47 -0700 Subject: [PATCH 1/3] use yq and retry to make the helmfile deployment script more flexible. --- conf/patches/gke-helmfile-deployment.sh | 3 ++- conf/tasks/Makefile.helmfile | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conf/patches/gke-helmfile-deployment.sh b/conf/patches/gke-helmfile-deployment.sh index b512fc97..be7afcfc 100755 --- a/conf/patches/gke-helmfile-deployment.sh +++ b/conf/patches/gke-helmfile-deployment.sh @@ -1,7 +1,8 @@ #!/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_name=$(yq r $filename releases[*].name | awk '{print $2}') + # deployment_name=$(grep "\- name: " ${filename} | grep -m1 -v "\- name: \"stable\"" | awk '{print $3}' | sed 's/^\"\(.\+\)\"$/\1/') retries=3 for ((i=0; i Date: Mon, 23 Mar 2020 14:12:29 -0700 Subject: [PATCH 2/3] leave the logic in the script --- conf/tasks/Makefile.helmfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/conf/tasks/Makefile.helmfile b/conf/tasks/Makefile.helmfile index dac22e5d..c13799e2 100644 --- a/conf/tasks/Makefile.helmfile +++ b/conf/tasks/Makefile.helmfile @@ -8,13 +8,7 @@ helmfile/create/all: @if [ -n "${ELK_DEPLOYMENT_TOGGLE}" ]; then\ cp ${CONF_PATH_PREFIX}/conf/ELK_helmfiles/* ${CONF_PATH_PREFIX}/conf/helmfile.d;\ fi - @for filename in ${CONF_PATH_PREFIX}/conf/helmfile.d/*.yaml; do - deployment_names=$(yq r $filename releases[*].name | awk '{print $2}') - for name in $deployment_names; do - retry -limit=3 -backoff=lin:10s -- /bin/sh -c \ - 'helmfile --selector name=${name} sync || - helm delete $name --purge; exit 1' - done + ${CONF_PATH_PREFIX}/conf/patches/gke-helmfile-deployment.sh @echo "Helmfile deployment finished." @echo " " @echo " " From 6984102b3d79d2ba18d364c3dcf05a2f5896bde1 Mon Sep 17 00:00:00 2001 From: William Graf <7930703+willgraf@users.noreply.github.com> Date: Mon, 23 Mar 2020 14:18:29 -0700 Subject: [PATCH 3/3] use yq and helmfile build to get names of all releases in each helmfile. --- conf/patches/gke-helmfile-deployment.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/conf/patches/gke-helmfile-deployment.sh b/conf/patches/gke-helmfile-deployment.sh index be7afcfc..dd501c9e 100755 --- a/conf/patches/gke-helmfile-deployment.sh +++ b/conf/patches/gke-helmfile-deployment.sh @@ -1,14 +1,17 @@ #!/bin/bash for filename in ${CONF_PATH_PREFIX}/conf/helmfile.d/*.yaml; do - deployment_name=$(yq r $filename releases[*].name | awk '{print $2}') - # 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