-
Notifications
You must be signed in to change notification settings - Fork 438
Expand file tree
/
Copy pathserver-job.yaml
More file actions
200 lines (200 loc) · 10.3 KB
/
server-job.yaml
File metadata and controls
200 lines (200 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{{- if $.Values.server.enabled }}{{- if or $.Values.schema.createDatabase.enabled $.Values.schema.setup.enabled $.Values.schema.update.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "temporal.componentname" (list $ (printf "schema-%d" .Release.Revision | replace "." "-")) }}
labels:
{{- include "temporal.resourceLabels" (list $ "database" "") | nindent 4 }}
spec:
backoffLimit: {{ $.Values.schema.setup.backoffLimit }}
ttlSecondsAfterFinished: 86400
template:
metadata:
name: {{ include "temporal.componentname" (list $ (printf "schema-%d" .Release.Revision | replace "." "-")) }}
labels:
{{- include "temporal.resourceLabels" (list $ "database" "") | nindent 8 }}
{{- with $.Values.schema.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $.Values.schema.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{ include "temporal.serviceAccount" $ }}
restartPolicy: OnFailure
initContainers:
{{- if $.Values.cassandra.enabled }}
- name: check-cassandra-service
image: busybox
command: ['sh', '-c', 'until nc -z {{ include "cassandra.host" $ }} {{ $.Values.cassandra.config.ports.cql }}; 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 }}
{{- if or $.Values.elasticsearch.enabled }}
- 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 "$ES_USER:$ES_PWD" $ES_SCHEME://$ES_HOST:$ES_PORT 2>&1 > /dev/null; do echo waiting for elasticsearch to start; sleep 1; done;']
env:
{{- include "temporal.admintools-env" (list $ "visibility") | nindent 12 }}
{{- end }}
{{- if $.Values.schema.createDatabase.enabled }}
{{- range $store := (list "default" "visibility") }}
{{- $storeConfig := index $.Values.server.config.persistence $store }}
{{- $driver := include "temporal.persistence.driver" (list $ $store) }}
{{- if ne $driver "elasticsearch" }}
- name: create-{{ $store }}-store
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
{{- if eq $driver "cassandra" }}
command: ['temporal-cassandra-tool', 'create', '-k', '{{ $storeConfig.cassandra.keyspace }}', '--replication-factor', '{{ $storeConfig.cassandra.replicationFactor }}']
{{- else if eq $driver "sql" }}
command: ['temporal-sql-tool', 'create-database']
{{- end }}
env:
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
{{- with $.Values.admintools.additionalVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.schema.setup.enabled }}
{{- range $store := (list "default" "visibility") }}
{{- $storeConfig := index $.Values.server.config.persistence $store }}
{{- $driver := include "temporal.persistence.driver" (list $ $store) }}
- name: setup-{{ $store }}-store
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
{{- if eq $driver "cassandra" }}
command: ['temporal-cassandra-tool', 'setup-schema', '-v', '0.0']
{{- else if eq $driver "sql" }}
command: ['temporal-sql-tool', 'setup-schema', '-v', '0.0']
{{- else if eq $driver "elasticsearch" }}
command: ['sh', '-c']
args:
- 'curl -X PUT --fail --user "$ES_USER:$ES_PWD" $ES_SCHEME://$ES_HOST:$ES_PORT/_template/temporal_visibility_v1_template -H "Content-Type: application/json" --data-binary "@schema/elasticsearch/visibility/index_template_$ES_VERSION.json" 2>&1 &&
curl --head --fail --user "$ES_USER:$ES_PWD" $ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX 2>&1 ||
curl -X PUT --fail --user "$ES_USER:$ES_PWD" $ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX 2>&1'
{{- end }}
env:
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
{{- with $.Values.admintools.additionalVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.schema.update.enabled }}
{{- range $store := (list "default" "visibility") }}
{{- $storeConfig := index $.Values.server.config.persistence $store }}
{{- $driver := include "temporal.persistence.driver" (list $ $store) }}
{{- $schema := include "temporal.persistence.schema" $store }}
{{- if ne $driver "elasticsearch" }}
- name: update-{{ $store }}-store
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
{{- if eq $driver "cassandra" }}
command: ['temporal-cassandra-tool', 'update-schema', '--schema-dir', '/etc/temporal/schema/cassandra/{{ $schema }}/versioned']
{{- else if eq $driver "sql" }}
{{- $plugin := include "temporal.persistence.sql.driver" (list $ $store) }}
{{- if eq $plugin "mysql8" }}
command: ['temporal-sql-tool', 'update-schema', '--schema-dir', '/etc/temporal/schema/mysql/v8/{{ $schema }}/versioned']
{{- else if or (eq $plugin "postgres12") (eq $plugin "postgres12_pgx") }}
command: ['temporal-sql-tool', 'update-schema', '--schema-dir', '/etc/temporal/schema/postgresql/v12/{{ $schema }}/versioned']
{{- end }}
{{- end }}
env:
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
{{- with $.Values.admintools.additionalVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.server.config.namespaces.create }}
{{- range $namespace := $.Values.server.config.namespaces.namespace }}
- name: create-{{ $namespace.name }}-namespace
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
command: ['/bin/sh','-c']
args: ['temporal operator namespace describe -n {{ $namespace.name }} || temporal operator namespace create -n {{ $namespace.name }}{{- if hasKey $namespace "retention" }} --retention {{ $namespace.retention }}{{- end }}']
env:
- name: TEMPORAL_ADDRESS
{{- if and (hasKey $.Values.server "internalFrontend") $.Values.server.internalFrontend.enabled }}
value: {{ include "temporal.fullname" $ }}-internal-frontend.{{ $.Release.Namespace }}.svc:{{ $.Values.server.internalFrontend.service.port }}
{{- else }}
value: "{{ include "temporal.fullname" $ }}-frontend.{{ $.Release.Namespace }}.svc:{{ $.Values.server.frontend.service.port }}"
{{- end }}
{{- with $.Values.admintools.additionalVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.admintools.additionalInitContainers }}
{{- toYaml $.Values.admintools.additionalInitContainers | nindent 8 }}
{{- end }}
containers:
- name: done
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
command: ['sh', '-c', 'echo "Store setup completed"']
{{- with $.Values.schema.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $.Values.admintools.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $.Values.admintools.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $.Values.admintools.additionalVolumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}{{- end -}}