Skip to content

Commit 86dee42

Browse files
[OPS-4460] Allow temporal helm chart to inject custom elasticsearch index template (#46)
* [OPS-4460] Allow temporal helm chart to inject custom elasticsearch index template * [OPS-4460] Allow temporal helm chart to inject custom elasticsearch index template * [OPS-4460] Allow temporal helm chart to inject custom elasticsearch index template
1 parent 3df2ed8 commit 86dee42

5 files changed

Lines changed: 241 additions & 6 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"order": 0,
3+
"index_patterns": ["temporal_visibility_v1*"],
4+
"settings": {
5+
"index": {
6+
"number_of_shards": "3",
7+
"number_of_replicas": "2",
8+
"search.idle.after": "365d",
9+
"sort.field": ["CloseTime", "StartTime", "RunId"],
10+
"sort.order": ["desc", "desc", "desc"],
11+
"sort.missing": ["_first", "_first", "_first"]
12+
}
13+
},
14+
"mappings": {
15+
"dynamic": "false",
16+
"properties": {
17+
"NamespaceId": {
18+
"type": "keyword"
19+
},
20+
"TemporalNamespaceDivision": {
21+
"type": "keyword"
22+
},
23+
"WorkflowId": {
24+
"type": "keyword"
25+
},
26+
"RunId": {
27+
"type": "keyword"
28+
},
29+
"WorkflowType": {
30+
"type": "keyword"
31+
},
32+
"StartTime": {
33+
"type": "date_nanos"
34+
},
35+
"ExecutionTime": {
36+
"type": "date_nanos"
37+
},
38+
"CloseTime": {
39+
"type": "date_nanos"
40+
},
41+
"ExecutionDuration": {
42+
"type": "long"
43+
},
44+
"ExecutionStatus": {
45+
"type": "keyword"
46+
},
47+
"TaskQueue": {
48+
"type": "keyword"
49+
},
50+
"TemporalChangeVersion": {
51+
"type": "keyword"
52+
},
53+
"BatcherNamespace": {
54+
"type": "keyword"
55+
},
56+
"BatcherUser": {
57+
"type": "keyword"
58+
},
59+
"BinaryChecksums": {
60+
"type": "keyword"
61+
},
62+
"HistoryLength": {
63+
"type": "long"
64+
},
65+
"StateTransitionCount": {
66+
"type": "long"
67+
},
68+
"TemporalScheduledStartTime": {
69+
"type": "date_nanos"
70+
},
71+
"TemporalScheduledById": {
72+
"type": "keyword"
73+
},
74+
"TemporalSchedulePaused": {
75+
"type": "boolean"
76+
},
77+
"HistorySizeBytes": {
78+
"type": "long"
79+
},
80+
"BuildIds": {
81+
"type": "keyword"
82+
},
83+
"ParentWorkflowId": {
84+
"type": "keyword"
85+
},
86+
"ParentRunId": {
87+
"type": "keyword"
88+
},
89+
"RootWorkflowId": {
90+
"type": "keyword"
91+
},
92+
"RootRunId": {
93+
"type": "keyword"
94+
}
95+
}
96+
},
97+
"aliases": {}
98+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"order": 0,
3+
"index_patterns": ["temporal_visibility_v1*"],
4+
"settings": {
5+
"index": {
6+
"number_of_shards": "1",
7+
"number_of_replicas": "0",
8+
"search.idle.after": "365d",
9+
"sort.field": ["CloseTime", "StartTime", "RunId"],
10+
"sort.order": ["desc", "desc", "desc"],
11+
"sort.missing": ["_first", "_first", "_first"]
12+
}
13+
},
14+
"mappings": {
15+
"dynamic": "false",
16+
"properties": {
17+
"NamespaceId": {
18+
"type": "keyword"
19+
},
20+
"TemporalNamespaceDivision": {
21+
"type": "keyword"
22+
},
23+
"WorkflowId": {
24+
"type": "keyword"
25+
},
26+
"RunId": {
27+
"type": "keyword"
28+
},
29+
"WorkflowType": {
30+
"type": "keyword"
31+
},
32+
"StartTime": {
33+
"type": "date_nanos"
34+
},
35+
"ExecutionTime": {
36+
"type": "date_nanos"
37+
},
38+
"CloseTime": {
39+
"type": "date_nanos"
40+
},
41+
"ExecutionDuration": {
42+
"type": "long"
43+
},
44+
"ExecutionStatus": {
45+
"type": "keyword"
46+
},
47+
"TaskQueue": {
48+
"type": "keyword"
49+
},
50+
"TemporalChangeVersion": {
51+
"type": "keyword"
52+
},
53+
"BatcherNamespace": {
54+
"type": "keyword"
55+
},
56+
"BatcherUser": {
57+
"type": "keyword"
58+
},
59+
"BinaryChecksums": {
60+
"type": "keyword"
61+
},
62+
"HistoryLength": {
63+
"type": "long"
64+
},
65+
"StateTransitionCount": {
66+
"type": "long"
67+
},
68+
"TemporalScheduledStartTime": {
69+
"type": "date_nanos"
70+
},
71+
"TemporalScheduledById": {
72+
"type": "keyword"
73+
},
74+
"TemporalSchedulePaused": {
75+
"type": "boolean"
76+
},
77+
"HistorySizeBytes": {
78+
"type": "long"
79+
},
80+
"BuildIds": {
81+
"type": "keyword"
82+
},
83+
"ParentWorkflowId": {
84+
"type": "keyword"
85+
},
86+
"ParentRunId": {
87+
"type": "keyword"
88+
},
89+
"RootWorkflowId": {
90+
"type": "keyword"
91+
},
92+
"RootRunId": {
93+
"type": "keyword"
94+
}
95+
}
96+
},
97+
"aliases": {}
98+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.schema.elasticsearchIndexTemplate }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
annotations:
6+
argocd.argoproj.io/sync-wave: '-20'
7+
name: {{ include "temporal.fullname" $ }}-{{ .Values.schema.elasticsearchIndexTemplate | replace ".json" "" }}
8+
data:
9+
{{ .Values.schema.elasticsearchIndexTemplate }}: |-
10+
{{- (.Files.Get (printf "files/%s" .Values.schema.elasticsearchIndexTemplate)) | nindent 4 }}
11+
{{- end }}
12+

charts/temporal/templates/server-job.yaml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,11 @@ spec:
166166
echo "Using curl for Elasticsearch setup"
167167
168168
echo "Creating index template: temporal_visibility_v1_template"
169+
TEMPLATE_PATH="{{ if $.Values.schema.elasticsearchIndexTemplate }}/tmp/elasticsearch-template/{{ $.Values.schema.elasticsearchIndexTemplate }}{{ else }}schema/elasticsearch/visibility/index_template_$ES_VERSION.json{{ end }}"
169170
curl -X PUT --fail --user "$ES_USER:$ES_PWD" \
170171
"$ES_SCHEME://$ES_HOST:$ES_PORT/_template/temporal_visibility_v1_template" \
171172
-H "Content-Type: application/json" \
172-
--data-binary "@schema/elasticsearch/visibility/index_template_$ES_VERSION.json"
173+
--data-binary "@$TEMPLATE_PATH"
173174
174175
echo "Checking if index exists: $ES_VISIBILITY_INDEX"
175176
if ! curl --head --fail --user "$ES_USER:$ES_PWD" \
@@ -190,8 +191,13 @@ spec:
190191
{{- end }}
191192
env:
192193
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
194+
volumeMounts:
195+
{{- if $.Values.schema.elasticsearchIndexTemplate }}
196+
- name: elasticsearch-index-template
197+
mountPath: /tmp/elasticsearch-template
198+
readOnly: true
199+
{{- end }}
193200
{{- with $.Values.admintools.additionalVolumeMounts }}
194-
volumeMounts:
195201
{{- toYaml . | nindent 12 }}
196202
{{- end }}
197203
{{- with $.Values.schema.resources }}
@@ -217,13 +223,28 @@ spec:
217223
{{- else if eq $driver "elasticsearch" }}
218224
command: ['sh', '-c']
219225
args:
220-
- '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 &&
221-
curl -X PUT --fail --user "$ES_USER:$ES_PWD" $ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX 2>&1'
226+
- |
227+
TEMPLATE_PATH="{{- if $.Values.schema.elasticsearchIndexTemplate -}}/tmp/elasticsearch-template/{{ $.Values.schema.elasticsearchIndexTemplate }}{{- else -}}schema/elasticsearch/visibility/index_template_$ES_VERSION.json{{- end -}}"
228+
229+
curl -X PUT --fail \
230+
--user "$ES_USER:$ES_PWD" \
231+
"$ES_SCHEME://$ES_HOST:$ES_PORT/_template/temporal_visibility_v1_template" \
232+
-H "Content-Type: application/json" \
233+
--data-binary "@$TEMPLATE_PATH" 2>&1 &&
234+
235+
curl -X PUT --fail \
236+
--user "$ES_USER:$ES_PWD" \
237+
"$ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX" 2>&1
222238
{{- end }}
223239
env:
224240
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
225-
{{- with $.Values.server.additionalVolumeMounts }}
226241
volumeMounts:
242+
{{- if $.Values.schema.elasticsearchIndexTemplate }}
243+
- name: elasticsearch-index-template
244+
mountPath: /tmp/elasticsearch-template
245+
readOnly: true
246+
{{- end }}
247+
{{- with $.Values.server.additionalVolumeMounts }}
227248
{{- toYaml . | nindent 12 }}
228249
{{- end }}
229250
{{- with $.Values.schema.resources }}
@@ -370,8 +391,13 @@ spec:
370391
tolerations:
371392
{{- toYaml . | nindent 8 }}
372393
{{- end }}
373-
{{- with $.Values.admintools.additionalVolumes }}
374394
volumes:
395+
{{- if $.Values.schema.elasticsearchIndexTemplate }}
396+
- name: elasticsearch-index-template
397+
configMap:
398+
name: {{ include "temporal.fullname" $ }}-{{ .Values.schema.elasticsearchIndexTemplate | replace ".json" "" }}
399+
{{- end }}
400+
{{- with $.Values.admintools.additionalVolumes }}
375401
{{- toYaml . | nindent 8 }}
376402
{{- end }}
377403
{{- end -}}

charts/temporal/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ web:
510510
topologySpreadConstraints: []
511511
podDisruptionBudget: {}
512512
schema:
513+
elasticsearchIndexTemplate: "" # leave empty to use default in image
513514
createDatabase:
514515
enabled: true
515516
setup:

0 commit comments

Comments
 (0)