Files
charts/bitnami/kong/templates/migrate-job.yaml
Javier J. Salmerón-García 0e29ba9fb3 [bitnami/kong] Make override migration image as optional (#2354)
* [bitnami/kong] Make override migration image as optional

* Use helm hooks to have support for --wait

* Set the annotations as a value

* Fix annotations

* [bitnami/kong] Update components versions

Signed-off-by: Bitnami Containers <containers@bitnami.com>

Co-authored-by: Bitnami Containers <containers@bitnami.com>
2020-04-21 14:28:47 +02:00

104 lines
4.5 KiB
YAML

apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "kong.fullname" . }}-migrate
namespace: {{ .Release.Namespace }}
labels: {{- include "kong.labels" . | nindent 4 }}
annotations: {{- include "kong.tplValue" ( dict "value" .Values.migration.annotations "context" $ ) | nindent 4 }}
spec:
template:
metadata:
labels: {{- include "kong.labels" . | nindent 8 }}
app.kubernetes.io/component: migration
annotations:
{{- if .Values.migration.podAnnotations }}
{{- include "kong.tplValue" (dict "value" .Values.migration.podAnnotations "context" $) | nindent 8 }}
{{- end }}
spec:
{{- include "kong.imagePullSecrets" . | nindent 6 }}
restartPolicy: OnFailure
{{- if .Values.podSecurityContext }}
securityContext: {{- include "kong.tplValue" (dict "value" .Values.podSecurityContext "context" $) | nindent 8 }}
{{- end }}
containers:
- name: kong-migrate
image: {{ template "kong.migration.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.migration.command }}
command: {{- include "kong.tplValue" (dict "value" .Values.migration.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.migration.args }}
args: {{- include "kong.tplValue" (dict "value" .Values.migration.args "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.containerSecurityContext }}
securityContext: {{- include "kong.tplValue" (dict "value" .Values.containerSecurityContext "context" $) | nindent 12 }}
{{- end }}
env:
- name: KONG_MIGRATE
value: "yes"
- name: KONG_EXIT_AFTER_MIGRATE
value: "yes"
{{- if (eq .Values.database "postgresql") }}
- name: KONG_DATABASE
value: "postgres"
{{- if .Values.postgresql.usePasswordFile }}
- name: KONG_POSTGRESQL_PASSWORD_FILE
value: "/bitnami/kong/secrets/postgresql-password"
{{- else }}
- name: KONG_PG_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "kong.postgresql.secretName" . }}
key: postgresql-password
{{- end }}
- name: KONG_PG_HOST
value: {{ include "kong.postgresql.host" . }}
- name: KONG_PG_USER
value: {{ include "kong.postgresql.user" . }}
{{- end }}
{{- if (eq .Values.database "cassandra") }}
- name: KONG_DATABASE
value: "cassandra"
{{- if .Values.cassandra.usePasswordFile }}
- name: KONG_CASSANDRA_PASSWORD_FILE
value: "/bitnami/kong/secrets/cassandra-password"
{{- else }}
- name: KONG_CASSANDRA_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "kong.cassandra.secretName" . }}
key: cassandra-password
{{- end }}
- name: KONG_CASSANDRA_CONTACT_POINTS
value: {{ include "kong.cassandra.contactPoints" . }}
- name: KONG_CASSANDRA_PORT
value: {{ include "kong.cassandra.port" . | quote }}
- name: KONG_CASSANDRA_USER
value: {{ include "kong.cassandra.user" . | quote }}
{{- end }}
{{- if .Values.migration.extraEnvVars }}
{{- include "kong.tplValue" (dict "value" .Values.migration.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
{{- if or .Values.migration.extraEnvVarsCM .Values.migration.extraEnvVarsSecret }}
envFrom:
{{- if .Values.migration.extraEnvVarsCM }}
- configMapRef:
name: {{ .Values.migration.extraEnvVarsCM }}
{{- end }}
{{- if .Values.migration.extraEnvVarsSecret }}
- secretRef:
name: {{ .Values.migration.extraEnvVarsSecret }}
{{- end }}
{{- end }}
{{- if .Values.migration.extraVolumeMounts }}
volumeMounts:
{{- include "kong.tplValue" (dict "value" .Values.migration.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.migration.resources }}
resources: {{- toYaml .Values.migration.resources | nindent 12 }}
{{- end }}
{{- if .Values.extraVolumes }}
volumes:
{{- include "kong.tplValue" (dict "value" .Values.extraVolumes "context" $) | nindent 6 }}
{{- end }}