From 1ac8b99f7e2a448620d65b50d884aa1531b4a34a Mon Sep 17 00:00:00 2001 From: josebb Date: Tue, 5 Apr 2022 20:50:28 +0300 Subject: [PATCH] Add helm hook annotations in horizon db-init and db-sync jobs Change-Id: I5e4b86cdf16e11d30142819e496f0d46ebdfae0d --- horizon/Chart.yaml | 2 +- horizon/templates/job-db-init.yaml | 8 ++++++++ horizon/templates/job-db-sync.yaml | 4 ++++ horizon/values.yaml | 4 ++++ releasenotes/notes/horizon.yaml | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/horizon/Chart.yaml b/horizon/Chart.yaml index e78075e0a5..f801c996c9 100644 --- a/horizon/Chart.yaml +++ b/horizon/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Horizon name: horizon -version: 0.2.20 +version: 0.2.21 home: https://docs.openstack.org/horizon/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Horizon/OpenStack_Project_Horizon_vertical.png sources: diff --git a/horizon/templates/job-db-init.yaml b/horizon/templates/job-db-init.yaml index 095a1f3df8..67169b5308 100644 --- a/horizon/templates/job-db-init.yaml +++ b/horizon/templates/job-db-init.yaml @@ -12,12 +12,20 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{- define "metadata.annotations.job.db_init" }} +helm.sh/hook: post-install,post-upgrade +helm.sh/hook-weight: "-5" +{{- end }} + {{- if .Values.manifests.job_db_init }} {{- $dbToInit := dict "inputType" "secret" "adminSecret" .Values.secrets.oslo_db.admin "userSecret" .Values.secrets.oslo_db.horizon -}} {{- $dbInitJob := dict "envAll" . "serviceName" "horizon" "dbToInit" $dbToInit -}} {{- if .Values.manifests.certificates -}} {{- $_ := set $dbInitJob "dbAdminTlsSecret" .Values.endpoints.oslo_db.auth.admin.secret.tls.internal -}} {{- end -}} +{{- if .Values.helm3_hook }} +{{- $_ := set $dbInitJob "jobAnnotations" (include "metadata.annotations.job.db_init" . | fromYaml) }} +{{- end }} {{- if .Values.pod.tolerations.horizon.enabled -}} {{- $_ := set $dbInitJob "tolerationsEnabled" true -}} {{- end -}} diff --git a/horizon/templates/job-db-sync.yaml b/horizon/templates/job-db-sync.yaml index fe5a213b06..c2229cdd08 100644 --- a/horizon/templates/job-db-sync.yaml +++ b/horizon/templates/job-db-sync.yaml @@ -28,6 +28,10 @@ metadata: labels: {{ tuple $envAll "horizon" "db-sync" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} annotations: +{{- if .Values.helm3_hook }} + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-weight: "-4" +{{- end }} {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} spec: template: diff --git a/horizon/values.yaml b/horizon/values.yaml index a17c09d530..4ea901bb10 100644 --- a/horizon/values.yaml +++ b/horizon/values.yaml @@ -1355,6 +1355,10 @@ network_policy: egress: - {} +# NOTE(helm_hook): helm_hook might break for helm2 binary. +# set helm3_hook: false when using the helm2 binary. +helm3_hook: true + manifests: certificates: false configmap_bin: true diff --git a/releasenotes/notes/horizon.yaml b/releasenotes/notes/horizon.yaml index 4a4fa8c3a1..46eb05defd 100644 --- a/releasenotes/notes/horizon.yaml +++ b/releasenotes/notes/horizon.yaml @@ -30,4 +30,5 @@ horizon: - 0.2.18 Enable taint toleration for Openstack services - 0.2.19 Remove unsupported value overrides - 0.2.20 Add SHOW_OPENRC_FILE value + - 0.2.21 Add helm hook annotations in db-sync and db-init jobs ...