Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/temporal/templates/_admintools-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
value: {{ splitList ":" $url.host | first }}
- name: ES_PORT
value: {{ splitList ":" $url.host | last | quote }}
- name: ES_SERVER
value: {{ urlJoin $url }}
- name: ES_USER
value: {{ $store.config.username | quote }}
- name: ES_PWD
Expand Down
26 changes: 22 additions & 4 deletions charts/temporal/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }}
{{- $_ := unset $storeConfig "password" -}}
{{- end -}}
{{- end -}}
{{- $_ := set $dsCopy $storeType (omit $storeConfig "existingSecret" "secretKey") -}}
{{- $_ := set $dsCopy $storeType (omit $storeConfig "existingSecret" "secretKey" "createDatabase" "manageSchema") -}}
{{- end -}}
{{- end -}}
{{- $_ := set $patchedDatastores $name $dsCopy -}}
Expand All @@ -179,13 +179,31 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }}
{{- $config := get $datastores $storeName -}}
{{- if hasKey $config "sql" -}}
{{- $_ := set $store "driver" "sql" -}}
{{- $_ := set $store "config" (get $config "sql") -}}
{{- $storeConfig := get $config "sql" -}}
{{- if not (hasKey $storeConfig "createDatabase") -}}
{{- $_ := set $storeConfig "createDatabase" true -}}
{{- end -}}
{{- if not (hasKey $storeConfig "manageSchema") -}}
{{- $_ := set $storeConfig "manageSchema" true -}}
{{- end -}}
{{- $_ := set $store "config" $storeConfig -}}
{{- else if hasKey $config "cassandra" -}}
{{- $_ := set $store "driver" "cassandra" -}}
{{- $_ := set $store "config" (get $config "cassandra") -}}
{{- $storeConfig := get $config "cassandra" -}}
{{- if not (hasKey $storeConfig "createDatabase") -}}
{{- $_ := set $storeConfig "createDatabase" true -}}
{{- end -}}
{{- if not (hasKey $storeConfig "manageSchema") -}}
{{- $_ := set $storeConfig "manageSchema" true -}}
{{- end -}}
{{- $_ := set $store "config" $storeConfig -}}
{{- else if hasKey $config "elasticsearch" -}}
{{- $_ := set $store "driver" "elasticsearch" -}}
{{- $_ := set $store "config" (get $config "elasticsearch") -}}
{{- $storeConfig := get $config "elasticsearch" -}}
{{- if not (hasKey $storeConfig "manageSchema") -}}
{{- $_ := set $storeConfig "manageSchema" true -}}
{{- end -}}
{{- $_ := set $store "config" $storeConfig -}}
{{- else -}}
{{- fail (printf "No valid driver configured for %s store" $store.name) -}}
{{- end -}}
Expand Down
4 changes: 0 additions & 4 deletions charts/temporal/templates/server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ spec:
subPath: config_template.yaml
- name: dynamic-config
mountPath: /etc/temporal/dynamic_config
{{- if semverCompare "~1.29.0" $.Values.server.image.tag }}
- name: shims
mountPath: /usr/local/bin/dockerize
subPath: dockerize
{{- end }}
{{- if $.Values.server.additionalVolumeMounts }}
{{- toYaml $.Values.server.additionalVolumeMounts | nindent 12}}
{{- end }}
Expand All @@ -126,12 +124,10 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- if semverCompare "~1.29.0" $.Values.server.image.tag}}
- name: shims
configMap:
name: "{{ include "temporal.fullname" $ }}-shims"
defaultMode: 0555
{{- end }}
- name: config
configMap:
name: "{{ include "temporal.fullname" $ }}-config"
Expand Down
111 changes: 44 additions & 67 deletions charts/temporal/templates/server-job.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- 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 }}
backoffLimit: {{ $.Values.schema.backoffLimit }}
ttlSecondsAfterFinished: 86400
template:
metadata:
Expand All @@ -27,50 +26,18 @@ spec:
{{- with $.Values.admintools.additionalInitContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $.Values.schema.createDatabase.enabled }}
{{- range $_, $store := (include "temporal.persistence.eachStore" $ | fromYaml) }}
{{- if ne $store.driver "elasticsearch" }}
{{- 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 }}']
{{- else if eq $store.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 }}
{{- with $.Values.schema.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.schema.setup.enabled }}
{{- range $_, $store := (include "temporal.persistence.eachStore" $ | fromYaml) }}
- name: setup-{{ $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', 'setup-schema', '-v', '0.0']
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', 'setup-schema', '-v', '0.0']
{{- else if eq $store.driver "elasticsearch" }}
# TODO: Use temporal-elasticsearch-tool if available. curl will not be part of the image in the future.
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'
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 }}
Expand All @@ -87,37 +54,42 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.schema.update.enabled }}
{{- range $_, $store := (include "temporal.persistence.eachStore" $ | fromYaml) }}
{{- if $store.config.manageSchema }}
{{- $schema := include "temporal.persistence.schema" $store }}
{{- if ne $store.driver "elasticsearch" }}
- name: update-{{ $store.name }}-store
- name: manage-schema-{{ $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', 'update-schema', '--schema-dir', '/etc/temporal/schema/cassandra/{{ $schema }}/versioned']
{{- else if eq $store.driver "sql" }}
{{- if eq $store.config.pluginName "mysql8" }}
command: ['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") }}
command: ['temporal-sql-tool', 'update-schema', '--schema-dir', '/etc/temporal/schema/postgresql/v12/{{ $schema }}/versioned']
{{- end }}
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 }}
{{- with $.Values.admintools.additionalVolumeMounts }}
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.resources }}
{{- with $.Values.admintools.additionalVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
- name: shims
mountPath: /usr/local/sbin/temporal-elasticsearch-tool
subPath: temporal-elasticsearch-tool
{{- with $.Values.schema.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.schema.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
Expand Down Expand Up @@ -183,8 +155,13 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $.Values.admintools.additionalVolumes }}
{{- if or $.Values.admintools.additionalVolumes true }}
volumes:
{{- toYaml . | nindent 8 }}
{{- with $.Values.admintools.additionalVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
- name: shims
configMap:
name: "{{ include "temporal.fullname" $ }}-shims"
defaultMode: 0555
{{- end }}
{{- end -}}
6 changes: 2 additions & 4 deletions charts/temporal/templates/server-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- if or $.Values.server.enabled $.Values.schema.createDatabase.enabled $.Values.schema.setup.enabled $.Values.schema.update.enabled }}
{{- range $_, $store := (include "temporal.persistence.eachStore" $ | fromYaml) }}
{{- range $_, $store := (include "temporal.persistence.eachStore" $ | fromYaml) }}
{{- if empty $store.config.existingSecret }}
apiVersion: v1
kind: Secret
Expand All @@ -15,6 +14,5 @@ type: Opaque
data:
password: {{ default "" $store.config.password | b64enc | quote }}
---
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading