From 8af02e63b706fc033a9f7cc8a0808f29f5578d64 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Fri, 19 Jan 2024 14:08:45 +0200 Subject: [PATCH] home-assistant: pre-migration actions (#2056) * home-assistant: pre-migration actions * fix selectors * fix init wait --- .../ix-dev/charts/home-assistant/Chart.yaml | 2 +- .../templates/backup-postgres-hook.yaml | 38 ------------------- .../home-assistant/templates/deployment.yaml | 6 +-- .../templates/postgres-deployment.yaml | 2 +- .../templates/postgres-service.yaml | 2 +- .../charts/home-assistant/to_keep_versions.md | 4 ++ .../home-assistant/to_keep_versions.yaml | 1 + 7 files changed, 11 insertions(+), 44 deletions(-) delete mode 100644 library/ix-dev/charts/home-assistant/templates/backup-postgres-hook.yaml create mode 100644 library/ix-dev/charts/home-assistant/to_keep_versions.md create mode 100644 library/ix-dev/charts/home-assistant/to_keep_versions.yaml diff --git a/library/ix-dev/charts/home-assistant/Chart.yaml b/library/ix-dev/charts/home-assistant/Chart.yaml index 4c606c31cc..206d27b540 100644 --- a/library/ix-dev/charts/home-assistant/Chart.yaml +++ b/library/ix-dev/charts/home-assistant/Chart.yaml @@ -3,7 +3,7 @@ description: Home Assistant App for TrueNAS SCALE annotations: title: Home Assistant type: application -version: 1.0.129 +version: 1.0.130 apiVersion: v2 appVersion: 2024.1.3 kubeVersion: '>=1.16.0-0' diff --git a/library/ix-dev/charts/home-assistant/templates/backup-postgres-hook.yaml b/library/ix-dev/charts/home-assistant/templates/backup-postgres-hook.yaml deleted file mode 100644 index fe1b71ea24..0000000000 --- a/library/ix-dev/charts/home-assistant/templates/backup-postgres-hook.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- if .Values.ixChartContext.isUpgrade -}} -{{ $values := (. | mustDeepCopy) }} -{{ $_ := set $values "common" (dict "nameSuffix" "postgres") }} -apiVersion: batch/v1 -kind: Job -metadata: - name: "pre-upgrade-hook" - annotations: - "helm.sh/hook": pre-upgrade - "helm.sh/hook-weight": "1" - "helm.sh/hook-delete-policy": hook-succeeded - rollme: {{ randAlphaNum 5 | quote }} -spec: - template: - metadata: - name: "pre-upgrade-hook" - spec: - restartPolicy: Never - containers: - - name: {{ .Chart.Name }}-postgres-backup - image: {{ template "postgres.imageName" . }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: {{ include "postgres.envVariableConfiguration" $values | nindent 10 }} - - name: BACKUP_NAME - value: {{ template "postgres.backupName" . }} - volumeMounts: {{ include "postgres.volumeMountsConfiguration" $values | nindent 10 }} - - name: backup-script-configmap - mountPath: /bin/backup_entrypoint.sh - readOnly: true - subPath: entrypoint.sh - command: - - "/bin/backup_entrypoint.sh" - volumes: {{ include "postgres.volumeConfiguration" $values | nindent 8 }} - - name: backup-script-configmap - configMap: - defaultMode: 0700 - name: "postgres-backup-hook-config-map" -{{- end -}} diff --git a/library/ix-dev/charts/home-assistant/templates/deployment.yaml b/library/ix-dev/charts/home-assistant/templates/deployment.yaml index ad026c2eb0..fac5d0cc73 100644 --- a/library/ix-dev/charts/home-assistant/templates/deployment.yaml +++ b/library/ix-dev/charts/home-assistant/templates/deployment.yaml @@ -5,7 +5,7 @@ apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }} kind: Deployment metadata: - name: {{ template "common.names.fullname" . }} + name: {{ template "common.names.fullname" . }}-ha labels: app: {{ template "common.names.name" . }} chart: {{ template "common.names.chart" . }} @@ -40,7 +40,7 @@ spec: initContainers: - name: init-postgresdb image: {{ template "postgres.imageName" . }} - command: ['sh', '-c', "until pg_isready -h {{ template "common.names.fullname" $postgres_values }}; do echo waiting for postgres; sleep 2; done"] + command: ['sh', '-c', "until pg_isready -h {{ template "common.names.fullname" $postgres_values }}-ha; do echo waiting for postgres; sleep 2; done"] imagePullPolicy: {{ .Values.image.pullPolicy }} - name: init-configs image: "alpine:latest" @@ -50,7 +50,7 @@ spec: - "/config/init/init.sh" env: {{ $envList := (default list .Values.environmentVariables) }} - {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }} + {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s-ha:5432" (include "common.names.fullname" $postgres_values))) }} {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }} {{ $envList = mustAppend $envList (dict "name" "POSTGRES_USER" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-user")}} {{ $envList = mustAppend $envList (dict "name" "POSTGRES_PASSWORD" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-password")}} diff --git a/library/ix-dev/charts/home-assistant/templates/postgres-deployment.yaml b/library/ix-dev/charts/home-assistant/templates/postgres-deployment.yaml index 71fe845e75..c369bf86dd 100644 --- a/library/ix-dev/charts/home-assistant/templates/postgres-deployment.yaml +++ b/library/ix-dev/charts/home-assistant/templates/postgres-deployment.yaml @@ -1,5 +1,5 @@ {{ $values := (. | mustDeepCopy) }} -{{ $_ := set $values "common" (dict "nameSuffix" "postgres") }} +{{ $_ := set $values "common" (dict "nameSuffix" "postgres-ha") }} {{ include "common.deployment.common_config" $values | nindent 0 }} spec: {{ include "common.deployment.common_spec" $values | nindent 2 }} template: {{ include "common.deployment.pod.metadata" $values | nindent 4 }} diff --git a/library/ix-dev/charts/home-assistant/templates/postgres-service.yaml b/library/ix-dev/charts/home-assistant/templates/postgres-service.yaml index c6603fd62b..2a29b9cf1c 100644 --- a/library/ix-dev/charts/home-assistant/templates/postgres-service.yaml +++ b/library/ix-dev/charts/home-assistant/templates/postgres-service.yaml @@ -1,6 +1,6 @@ {{ $ports := list }} {{ $ports = mustAppend $ports (dict "name" "postgres-tcp" "port" 5432 "targetPort" 5432) }} {{ $values := (. | mustDeepCopy) }} -{{ $_ := set $values "common" (dict "nameSuffix" "postgres") }} +{{ $_ := set $values "common" (dict "nameSuffix" "postgres-ha") }} {{ $_1 := set $values "commonService" (dict "type" "ClusterIP" "ports" $ports ) }} {{ include "common.classes.service" $values }} diff --git a/library/ix-dev/charts/home-assistant/to_keep_versions.md b/library/ix-dev/charts/home-assistant/to_keep_versions.md new file mode 100644 index 0000000000..7572c06f63 --- /dev/null +++ b/library/ix-dev/charts/home-assistant/to_keep_versions.md @@ -0,0 +1,4 @@ +# 1.0.130 + +This version is kept because it contains a fix that is needed for migration to v2.x.x +It should be safe to remove few months after v2.x.x is released. diff --git a/library/ix-dev/charts/home-assistant/to_keep_versions.yaml b/library/ix-dev/charts/home-assistant/to_keep_versions.yaml new file mode 100644 index 0000000000..6b5a5c75e8 --- /dev/null +++ b/library/ix-dev/charts/home-assistant/to_keep_versions.yaml @@ -0,0 +1 @@ +- 1.0.130