Bläddra i källkod

home-assistant: pre-migration actions (#2056)

* home-assistant: pre-migration actions

* fix selectors

* fix init wait
Stavros Kois 1 år sedan
förälder
incheckning
8af02e63b7

+ 1 - 1
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'

+ 0 - 38
library/ix-dev/charts/home-assistant/templates/backup-postgres-hook.yaml

@@ -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 -}}

+ 3 - 3
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")}}

+ 1 - 1
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 }}

+ 1 - 1
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 }}

+ 4 - 0
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.

+ 1 - 0
library/ix-dev/charts/home-assistant/to_keep_versions.yaml

@@ -0,0 +1 @@
+- 1.0.130