X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=helm%2Finfrastructure%2Fsubcharts%2Fkong%2Ftemplates%2Fmigrations-pre-upgrade.yaml;fp=helm%2Finfrastructure%2Fsubcharts%2Fkong%2Ftemplates%2Fmigrations-pre-upgrade.yaml;h=18398715d7114fe47a9071daad630de2b0fc21cf;hb=38dc857062b14145f5b9db89d10eba0ae5b90d11;hp=0000000000000000000000000000000000000000;hpb=0c9bc21e8efc4c7205a46ef1456d1f08e65c56f2;p=ric-plt%2Fric-dep.git diff --git a/helm/infrastructure/subcharts/kong/templates/migrations-pre-upgrade.yaml b/helm/infrastructure/subcharts/kong/templates/migrations-pre-upgrade.yaml new file mode 100755 index 0000000..1839871 --- /dev/null +++ b/helm/infrastructure/subcharts/kong/templates/migrations-pre-upgrade.yaml @@ -0,0 +1,76 @@ +{{- if (and (.Values.runMigrations) (not (eq .Values.env.database "off"))) }} +# Why is this Job duplicated and not using only helm hooks? +# See: https://github.com/helm/charts/pull/7362 +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ template "kong.fullname" . }}-pre-upgrade-migrations + labels: + app: {{ template "kong.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + component: pre-upgrade-migrations + annotations: + helm.sh/hook: "pre-upgrade" + helm.sh/hook-delete-policy: "before-hook-creation" +spec: + template: + metadata: + name: {{ template "kong.name" . }}-pre-upgrade-migrations + labels: + app: {{ template "kong.name" . }} + release: "{{ .Release.Name }}" + component: pre-upgrade-migrations + spec: + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + {{- if .Values.postgresql.enabled }} + initContainers: + - name: wait-for-postgres + image: "{{ .Values.waitImage.repository }}:{{ .Values.waitImage.tag }}" + env: + - name: KONG_PG_HOST + value: {{ template "kong.postgresql.fullname" . }} + - name: KONG_PG_PORT + value: "{{ .Values.postgresql.service.port }}" + - name: KONG_PG_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "kong.postgresql.fullname" . }} + key: postgresql-password + command: [ "/bin/sh", "-c", "until nc -zv $KONG_PG_HOST $KONG_PG_PORT -w1; do echo 'waiting for db'; sleep 1; done" ] + {{- end }} + containers: + - name: {{ template "kong.name" . }}-upgrade-migrations + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: KONG_NGINX_DAEMON + value: "off" + {{- if .Values.enterprise.enabled }} + {{- include "kong.license" . | nindent 8 }} + {{- end }} + {{- if .Values.postgresql.enabled }} + - name: KONG_PG_HOST + value: {{ template "kong.postgresql.fullname" . }} + - name: KONG_PG_PORT + value: "{{ .Values.postgresql.service.port }}" + - name: KONG_PG_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "kong.postgresql.fullname" . }} + key: postgresql-password + {{- end }} + {{- if .Values.cassandra.enabled }} + - name: KONG_CASSANDRA_CONTACT_POINTS + value: {{ template "kong.cassandra.fullname" . }} + {{- end }} + {{- include "kong.env" . | indent 8 }} + command: [ "/bin/sh", "-c", "kong migrations up" ] + restartPolicy: OnFailure +{{- end }}