peridot/infrastructure/dev-helm/temporal/templates/server-job.yaml

304 lines
14 KiB
YAML
Raw Normal View History

2022-07-07 20:11:50 +00:00
{{- if $.Values.server.enabled }}
{{- if .Values.schema.setup.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "temporal.componentname" (list . "schema-setup") }}
labels:
app.kubernetes.io/name: {{ include "temporal.name" . }}
helm.sh/chart: {{ include "temporal.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: database
app.kubernetes.io/part-of: {{ .Chart.Name }}
annotations:
{{- if .Values.cassandra.enabled }}
"helm.sh/hook": post-install
{{- else }}
"helm.sh/hook": pre-install
{{- end }}
"helm.sh/hook-weight": "0"
{{- if not .Values.debug }}
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
{{- end }}
spec:
backoffLimit: {{ .Values.schema.setup.backoffLimit }}
template:
metadata:
name: {{ include "temporal.componentname" (list . "schema-setup") }}
labels:
app.kubernetes.io/name: {{ include "temporal.name" . }}
helm.sh/chart: {{ include "temporal.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: database
app.kubernetes.io/part-of: {{ .Chart.Name }}
spec:
{{ include "temporal.serviceAccount" . }}
restartPolicy: "OnFailure"
initContainers:
{{- if or .Values.cassandra.enabled (eq (include "temporal.persistence.driver" (list $ "default")) "cassandra") (eq (include "temporal.persistence.driver" (list $ "visibility")) "cassandra") }}
{{- if .Values.cassandra.enabled }}
- name: check-cassandra-service
image: busybox
command: ['sh', '-c', 'until nslookup {{ include "cassandra.host" $ }}; do echo waiting for cassandra service; sleep 1; done;']
- name: check-cassandra
image: "{{ .Values.cassandra.image.repo }}:{{ .Values.cassandra.image.tag }}"
imagePullPolicy: {{ .Values.cassandra.image.pullPolicy }}
command: ['sh', '-c', 'until cqlsh {{ include "cassandra.host" $ }} {{ .Values.cassandra.config.ports.cql }} -e "SHOW VERSION"; do echo waiting for cassandra to start; sleep 1; done;']
{{- end }}
{{- range $store := (list "default" "visibility") }}
{{- $storeConfig := index $.Values.server.config.persistence $store }}
{{- if eq (include "temporal.persistence.driver" (list $ $store)) "cassandra" }}
- name: create-{{ $store }}-store
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
command: ['sh', '-c', 'temporal-cassandra-tool create -k {{ $storeConfig.cassandra.keyspace }} --replication-factor {{ $storeConfig.cassandra.replicationFactor }}']
env:
- name: CASSANDRA_HOST
value: {{ first (splitList "," (include "temporal.persistence.cassandra.hosts" (list $ $store))) }}
- name: CASSANDRA_PORT
value: {{ include "temporal.persistence.cassandra.port" (list $ $store) | quote }}
- name: CASSANDRA_KEYSPACE
value: {{ $storeConfig.cassandra.keyspace }}
{{- if $storeConfig.cassandra.user }}
- name: CASSANDRA_USER
value: {{ $storeConfig.cassandra.user }}
{{- end }}
{{- if (or $storeConfig.cassandra.password $storeConfig.cassandra.existingSecret) }}
- name: CASSANDRA_PASSWORD
{{- if $storeConfig.cassandra.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ include "temporal.persistence.secretName" (list $ $store) }}
key: {{ include "temporal.persistence.secretKey" (list $ $store) }}
{{- else }}
value: {{ $storeConfig.cassandra.password }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- else }}
[]
{{- end }}
containers:
{{- range $store := (list "default" "visibility") }}
{{- $storeConfig := index $.Values.server.config.persistence $store }}
- name: {{ $store }}-schema
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
command: ["temporal-{{ include "temporal.persistence.driver" (list $ $store) }}-tool", "setup-schema", "-v", "0.0"]
env:
{{- if eq (include "temporal.persistence.driver" (list $ $store)) "cassandra" }}
- name: CASSANDRA_HOST
value: {{ first (splitList "," (include "temporal.persistence.cassandra.hosts" (list $ $store))) }}
- name: CASSANDRA_PORT
value: {{ include "temporal.persistence.cassandra.port" (list $ $store) | quote }}
- name: CASSANDRA_KEYSPACE
value: {{ $storeConfig.cassandra.keyspace }}
{{- if $storeConfig.cassandra.user }}
- name: CASSANDRA_USER
value: {{ $storeConfig.cassandra.user }}
{{- end }}
{{- if (or $storeConfig.cassandra.password $storeConfig.cassandra.existingSecret) }}
- name: CASSANDRA_PASSWORD
{{- if $storeConfig.cassandra.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ include "temporal.persistence.secretName" (list $ $store) }}
key: {{ include "temporal.persistence.secretKey" (list $ $store) }}
{{- else }}
value: {{ $storeConfig.cassandra.password }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with (default $.Values.server.nodeSelector) }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
---
{{- end }}
{{- if .Values.schema.update.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "temporal.componentname" (list . "schema-update") }}
labels:
app.kubernetes.io/name: {{ include "temporal.name" . }}
helm.sh/chart: {{ include "temporal.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: database
app.kubernetes.io/part-of: {{ .Chart.Name }}
annotations:
{{- if .Values.cassandra.enabled }}
"helm.sh/hook": post-install,pre-upgrade
{{- else }}
"helm.sh/hook": pre-install,pre-upgrade
{{- end }}
"helm.sh/hook-weight": "1"
{{- if not .Values.debug }}
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
{{- end }}
spec:
backoffLimit: {{ .Values.schema.update.backoffLimit }}
template:
metadata:
name: {{ include "temporal.componentname" (list . "schema-update") }}
labels:
app.kubernetes.io/name: {{ include "temporal.name" . }}
helm.sh/chart: {{ include "temporal.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: database
app.kubernetes.io/part-of: {{ .Chart.Name }}
spec:
{{ include "temporal.serviceAccount" . }}
restartPolicy: "OnFailure"
initContainers:
{{- if .Values.cassandra.enabled }}
- name: check-cassandra-service
image: busybox
command: ['sh', '-c', 'until nslookup {{ include "cassandra.host" $ }}; do echo waiting for cassandra service; sleep 1; done;']
- name: check-cassandra
image: "{{ .Values.cassandra.image.repo }}:{{ .Values.cassandra.image.tag }}"
imagePullPolicy: {{ .Values.cassandra.image.pullPolicy }}
command: ['sh', '-c', 'until cqlsh {{ include "cassandra.host" $ }} {{ .Values.cassandra.config.ports.cql }} -e "SHOW VERSION"; do echo waiting for cassandra to start; sleep 1; done;']
{{- else }}
[]
{{- end }}
containers:
{{- range $store := (list "default" "visibility") }}
{{- $storeConfig := index $.Values.server.config.persistence $store }}
- name: {{ $store }}-schema
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
{{- if eq (include "temporal.persistence.driver" (list $ $store)) "cassandra" }}
command: ['sh', '-c', 'temporal-cassandra-tool update-schema -d /etc/temporal/schema/cassandra/{{ include "temporal.persistence.schema" $store }}/versioned']
{{- end }}
env:
{{- if eq (include "temporal.persistence.driver" (list $ $store)) "cassandra" }}
- name: CASSANDRA_HOST
value: {{ first (splitList "," (include "temporal.persistence.cassandra.hosts" (list $ $store))) }}
- name: CASSANDRA_PORT
value: {{ include "temporal.persistence.cassandra.port" (list $ $store) | quote }}
- name: CASSANDRA_KEYSPACE
value: {{ $storeConfig.cassandra.keyspace }}
{{- if $storeConfig.cassandra.user }}
- name: CASSANDRA_USER
value: {{ $storeConfig.cassandra.user }}
{{- end }}
{{- if (or $storeConfig.cassandra.password $storeConfig.cassandra.existingSecret) }}
- name: CASSANDRA_PASSWORD
{{- if $storeConfig.cassandra.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ include "temporal.persistence.secretName" (list $ $store) }}
key: {{ include "temporal.persistence.secretKey" (list $ $store) }}
{{- else }}
value: {{ $storeConfig.cassandra.password }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- with (default $.Values.admintools.nodeSelector) }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.admintools.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.admintools.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
---
{{- end }}
{{- if or $.Values.elasticsearch.enabled $.Values.elasticsearch.external }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "temporal.componentname" (list . "es-index-setup") }}
labels:
app.kubernetes.io/name: {{ include "temporal.name" . }}
helm.sh/chart: {{ include "temporal.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: database
app.kubernetes.io/part-of: {{ .Chart.Name }}
annotations:
{{- if .Values.elasticsearch.external }}
"helm.sh/hook": pre-install
{{- else }}
"helm.sh/hook": post-install
{{- end }}
"helm.sh/hook-weight": "0"
{{- if not .Values.debug }}
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
{{- end }}
spec:
backoffLimit: {{ .Values.schema.setup.backoffLimit }}
template:
metadata:
name: {{ include "temporal.componentname" (list . "es-index-setup") }}
labels:
app.kubernetes.io/name: {{ include "temporal.name" . }}
helm.sh/chart: {{ include "temporal.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/component: database
app.kubernetes.io/part-of: {{ .Chart.Name }}
spec:
{{ include "temporal.serviceAccount" . }}
restartPolicy: "OnFailure"
initContainers:
- name: check-elasticsearch-service
image: busybox
command: ['sh', '-c', 'until nslookup {{ .Values.elasticsearch.host }}; do echo waiting for elasticsearch service; sleep 1; done;']
- name: check-elasticsearch
image: "{{ .Values.admintools.image.repository }}:{{ .Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
command: ['sh', '-c', 'until curl --silent --fail --user {{ .Values.elasticsearch.username }}:{{ .Values.elasticsearch.password }} {{ .Values.elasticsearch.scheme }}://{{ .Values.elasticsearch.host }}:{{ .Values.elasticsearch.port }} 2>&1 > /dev/null; do echo waiting for elasticsearch to start; sleep 1; done;']
containers:
- name: create-elasticsearch-index
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
command: ['sh', '-c']
args:
- 'curl -X PUT --fail --user {{ .Values.elasticsearch.username }}:{{ .Values.elasticsearch.password }} {{ .Values.elasticsearch.scheme }}://{{ .Values.elasticsearch.host }}:{{ .Values.elasticsearch.port }}/_template/temporal_visibility_v1_template -H "Content-Type: application/json" --data-binary "@schema/elasticsearch/visibility/index_template_{{ .Values.elasticsearch.version }}.json" 2>&1 &&
curl -X PUT --fail --user {{ .Values.elasticsearch.username }}:{{ .Values.elasticsearch.password }} {{ .Values.elasticsearch.scheme }}://{{ .Values.elasticsearch.host }}:{{ .Values.elasticsearch.port }}/{{ .Values.elasticsearch.visibilityIndex }} 2>&1'
{{- with (default $.Values.admintools.nodeSelector) }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.admintools.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.admintools.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}