-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathserver-job.yaml
More file actions
187 lines (187 loc) · 8.7 KB
/
server-job.yaml
File metadata and controls
187 lines (187 loc) · 8.7 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
{{- $jobName := include "temporal.componentname" (list $ (printf "schema-%s-%d" $.Chart.Version $.Release.Revision | replace "." "-")) }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ $jobName }}
labels:
{{- include "temporal.resourceLabels" (list $ "database" "") | nindent 4 }}
{{- with $.Values.schema.jobAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
backoffLimit: {{ $.Values.schema.backoffLimit }}
ttlSecondsAfterFinished: {{ $.Values.schema.ttlSecondsAfterFinished }}
template:
metadata:
name: {{ $jobName }}
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:
{{- with $.Values.admintools.additionalInitContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- range $_, $store := (include "temporal.persistence.eachStore" $ | fromYaml) }}
{{- if $store.config.createDatabase }}
- name: create-{{ $store.name }}-store
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
{{- if eq $store.driver "cassandra" }}
command: ['temporal-cassandra-tool', 'create', '-k', '{{ $store.config.keyspace }}', '--replication-factor', '{{ $store.config.replicationFactor | default 1 }}'{{- if $store.config.datacenter }}, '--
datacenter', '{{ $store.config.datacenter }}'{{- end }}]
{{- else if eq $store.driver "sql" }}
command: ['temporal-sql-tool', 'create-database']
{{- else -}}
{{- fail (printf "createDatabase is not supported for %s store" $store.driver) -}}
{{- 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 }}
{{- if $store.config.manageSchema }}
{{- $schema := include "temporal.persistence.schema" $store }}
- name: manage-schema-{{ $store.name }}-store
image: "{{ $.Values.admintools.image.repository }}:{{ $.Values.admintools.image.tag }}"
imagePullPolicy: {{ $.Values.admintools.image.pullPolicy }}
command: ['sh', '-c']
args:
{{- if eq $store.driver "cassandra" }}
- temporal-cassandra-tool setup-schema -v 0.0 && temporal-cassandra-tool update-schema --schema-dir /etc/temporal/schema/cassandra/{{ $schema }}/versioned
{{- else if eq $store.driver "sql" }}
{{- if eq $store.config.pluginName "mysql8" }}
- temporal-sql-tool setup-schema -v 0.0 && temporal-sql-tool update-schema --schema-dir /etc/temporal/schema/mysql/v8/{{ $schema }}/versioned
{{- else if or (eq $store.config.pluginName "postgres12") (eq $store.config.pluginName "postgres12_pgx") }}
- temporal-sql-tool setup-schema -v 0.0 && temporal-sql-tool update-schema --schema-dir /etc/temporal/schema/postgresql/v12/{{ $schema }}/versioned
{{- else -}}
{{- fail (printf "manageSchema is not supported for %s SQL database plugin" $store.config.pluginName) -}}
{{- end }}
{{- else if eq $store.driver "elasticsearch" }}
- temporal-elasticsearch-tool setup-schema && temporal-elasticsearch-tool create-index && temporal-elasticsearch-tool update-schema --index "$ES_VISIBILITY_INDEX"
{{- end }}
env:
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
volumeMounts:
{{- with $.Values.admintools.additionalVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if $.Values.shims.elasticsearchTool }}
- name: shims
mountPath: /usr/local/sbin/temporal-elasticsearch-tool
subPath: temporal-elasticsearch-tool
{{- end }}
{{- with $.Values.schema.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- 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 (index $.Values.server "internal-frontend").enabled }}
value: {{ include "temporal.fullname" $ }}-internal-frontend.{{ $.Release.Namespace }}.svc:{{ (index $.Values.server "internal-frontend").service.port }}
{{- else if $.Values.server.frontend.ingress.enabled }}
value: "{{ index $.Values.server.frontend.ingress.hosts 0 }}"
{{- else }}
value: "{{ include "temporal.fullname" $ }}-frontend.{{ $.Release.Namespace }}.svc:{{ $.Values.server.frontend.service.port }}"
{{- end }}
{{- with $.Values.admintools.additionalEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or $.Values.admintools.additionalEnvSecretName $.Values.admintools.additionalEnvConfigMapName }}
envFrom:
{{- with $.Values.admintools.additionalEnvSecretName }}
- secretRef:
name: {{ . }}
{{- end }}
{{- with $.Values.admintools.additionalEnvConfigMapName }}
- configMapRef:
name: {{ . }}
{{- end }}
{{- 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 }}
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 }}
{{- if or $.Values.admintools.additionalVolumes $.Values.shims.elasticsearchTool }}
volumes:
{{- with $.Values.admintools.additionalVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $.Values.shims.elasticsearchTool }}
- name: shims
configMap:
name: "{{ include "temporal.fullname" $ }}-shims"
defaultMode: 0555
{{- end }}
{{- end }}