From 367bed952ff79a6b098a5468d9bfc595675600eb Mon Sep 17 00:00:00 2001 From: Dustin Specker Date: Thu, 5 May 2022 16:16:00 -0500 Subject: [PATCH] fix helm-release-status role to use helm3 commands Helm3 requires specifying a namespace to retrieve status and values for a given release. Before this role would not retrieve any values or statuses. Now values and statuses are retrieved in saved in Zuul archive correctly. Change-Id: If8cf28349b0c14ba6e1de74d49e46ab4a61b93c7 --- roles/helm-release-status/tasks/main.yaml | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/roles/helm-release-status/tasks/main.yaml b/roles/helm-release-status/tasks/main.yaml index 954b13f36..35e199dad 100644 --- a/roles/helm-release-status/tasks/main.yaml +++ b/roles/helm-release-status/tasks/main.yaml @@ -21,28 +21,25 @@ - values - releases -- name: "retrieve all deployed charts" - shell: |- - set -e - helm ls --short - args: - executable: /bin/bash - register: helm_releases - ignore_errors: True - - name: "Gather get release status for helm charts" shell: |- set -e - helm status {{ helm_released }} >> {{ logs_dir }}/helm/releases/{{ helm_release }}.txt - helm get values {{ helm_released }} >> {{ logs_dir }}/helm/values/{{ helm_release }}.yaml + + for namespace in $(kubectl get namespaces --no-headers --output custom-columns=":metadata.name"); do + # get all Helm releases including pending and failed releases + for release in $(helm list --all --short --namespace $namespace); do + # Make respective directories only when a Helm release actually exists in the namespace + # to prevent uploading a bunch of empty directories for namespaces without a Helm release. + mkdir -p {{ logs_dir }}/helm/releases/$namespace + mkdir -p {{ logs_dir }}/helm/values/$namespace + + helm status $release --namespace $namespace >> {{ logs_dir }}/helm/releases/$namespace/$release.txt + helm get values $release --namespace $namespace --all >> {{ logs_dir }}/helm/values/$namespace/$release.yaml + done + done args: executable: /bin/bash ignore_errors: True - vars: - helm_release: "{{ helm_released }}" - loop_control: - loop_var: helm_released - with_items: "{{ helm_releases.stdout_lines }}" - name: "Downloads logs to executor" synchronize: