Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 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
8 changes: 5 additions & 3 deletions charts/temporal/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,12 @@ Source: https://stackoverflow.com/a/52024583/3027614
All Cassandra hosts.
*/}}
{{- define "cassandra.hosts" -}}
{{- range $i := (until (int .Values.cassandra.config.cluster_size)) }}
{{- $hosts := list -}}
{{- range $i := (until (int .Values.cassandra.config.cluster_size)) -}}
{{- $cassandraName := include "call-nested" (list $ "cassandra" "cassandra.fullname") -}}
{{- printf "%s.%s," $cassandraName $.Release.Namespace -}}
{{- end }}
{{- $hosts = append $hosts (printf "%s.%s" $cassandraName $.Release.Namespace) -}}
Comment thread
chaptersix marked this conversation as resolved.
{{- end -}}
{{- join "," $hosts -}}
{{- end -}}

{{/*
Expand Down
77 changes: 71 additions & 6 deletions charts/temporal/templates/server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/server-configmap.yaml") $ | sha256sum }}
checksum/config: {{ include (print $.Template.BasePath "/server-sprig-configmap.yaml") $ | sha256sum }}-{{ include (print $.Template.BasePath "/server-dockerize-configmap.yaml") $ | sha256sum }}
{{- if (dig "metrics" "annotations" "enabled" $.Values.server.metrics.annotations.enabled $serviceValues) }}
prometheus.io/job: {{ $.Chart.Name }}-{{ $service }}
prometheus.io/scrape: 'true'
Expand All @@ -38,7 +38,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if or (or $.Values.server.additionalInitContainers $.Values.cassandra.enabled) (or $.Values.elasticsearch.enabled $.Values.elasticsearch.external)}}
{{- if or $.Values.server.additionalInitContainers $.Values.cassandra.enabled (or $.Values.elasticsearch.enabled $.Values.elasticsearch.external) }}
initContainers:
{{- with $.Values.server.additionalInitContainers }}
{{- toYaml . | nindent 8}}
Expand All @@ -65,7 +65,28 @@ spec:
- name: check-elasticsearch-index
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/$ES_VISIBILITY_INDEX 2>&1 > /dev/null; do echo waiting for elasticsearch index to become ready; sleep 1; done;']
command: ['/bin/sh', '-c']
args:
- |
set -e
echo "Waiting for Elasticsearch index to become ready..."

if [ -x /usr/local/bin/temporal-elasticsearch-tool ]; then
echo "Using temporal-elasticsearch-tool to check index: $ES_VISIBILITY_INDEX"
# Use ping to verify ES is accessible, assuming index was created by setup job
until temporal-elasticsearch-tool --endpoint "$ES_SCHEME://$ES_HOST:$ES_PORT" --user "$ES_USER" --password "$ES_PWD" ping 2>&1 > /dev/null; do
sleep 1
done
elif command -v curl >/dev/null 2>&1; then
echo "Using curl to check index: $ES_VISIBILITY_INDEX"
until curl --silent --fail --user "$ES_USER:$ES_PWD" "$ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX" 2>&1 > /dev/null; do
sleep 1
done
else
echo "ERROR: Neither temporal-elasticsearch-tool nor curl found" >&2
exit 1
fi
echo "Elasticsearch index is ready"
env:
{{- include "temporal.admintools-env" (list $ "visibility") | nindent 12 }}
{{- with $serviceValues.containerSecurityContext }}
Expand All @@ -78,13 +99,18 @@ spec:
- name: {{ $.Chart.Name }}-{{ $service }}
image: "{{ $.Values.server.image.repository }}:{{ $.Values.server.image.tag }}"
imagePullPolicy: {{ $.Values.server.image.pullPolicy }}
{{- if $.Values.server.useEntrypointScript }}
command: ['/entrypoint/entrypoint.sh']
{{- end }}
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: SERVICES
value: {{ $service }}
- name: TEMPORAL_SERVICES
value: {{ $service }}
- name: TEMPORAL_SERVER_CONFIG_FILE_PATH
value: /etc/temporal/config/config_template.yaml
{{- if ne (include "temporal.persistence.driver" (list $ "default")) "custom" }}
Expand Down Expand Up @@ -143,9 +169,33 @@ spec:
port: rpc
{{- end }}
volumeMounts:
- name: config
{{- if $.Values.server.useEntrypointScript }}
{{- if or (eq $.Values.server.configMapsToMount "both") (eq $.Values.server.configMapsToMount "dockerize") }}
- name: config-dockerize
mountPath: /etc/temporal/config-source/dockerize
readOnly: true
{{- end }}
{{- if or (eq $.Values.server.configMapsToMount "both") (eq $.Values.server.configMapsToMount "sprig") }}
- name: config-sprig
mountPath: /etc/temporal/config-source/sprig
readOnly: true
{{- end }}
- name: entrypoint-script
mountPath: /entrypoint
readOnly: true
- name: config-processed
mountPath: /etc/temporal/config
{{- else }}
{{- if eq $.Values.server.configMapsToMount "dockerize" }}
- name: config-dockerize
mountPath: /etc/temporal/config/config_template.yaml
subPath: config_template.yaml
{{- else }}
- name: config-sprig
mountPath: /etc/temporal/config/config_template.yaml
subPath: config_template.yaml
{{- end }}
{{- end }}
- name: dynamic-config
mountPath: /etc/temporal/dynamic_config
{{- if $.Values.server.additionalVolumeMounts }}
Expand All @@ -162,9 +212,24 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- if or (eq $.Values.server.configMapsToMount "both") (eq $.Values.server.configMapsToMount "dockerize") }}
- name: config-dockerize
configMap:
name: "{{ include "temporal.fullname" $ }}-dockerize-config"
{{- end }}
{{- if or (eq $.Values.server.configMapsToMount "both") (eq $.Values.server.configMapsToMount "sprig") }}
- name: config-sprig
configMap:
name: "{{ include "temporal.fullname" $ }}-config"
name: "{{ include "temporal.fullname" $ }}-sprig-config"
{{- end }}
{{- if $.Values.server.useEntrypointScript }}
- name: entrypoint-script
configMap:
name: "{{ include "temporal.fullname" $ }}-entrypoint-script"
defaultMode: 0755
- name: config-processed
emptyDir: {}
{{- end }}
- name: dynamic-config
configMap:
name: "{{ include "temporal.fullname" $ }}-dynamic-config"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{- if .Values.server.enabled -}}
{{- if and .Values.server.enabled (or (eq .Values.server.configMapsToMount "both") (eq .Values.server.configMapsToMount "dockerize")) -}}
{{- $server := .Values.server -}}
{{- $elasticsearch := .Values.elasticsearch -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ include "temporal.fullname" $ }}-config"
name: "{{ include "temporal.fullname" $ }}-dockerize-config"
labels:
{{- include "temporal.resourceLabels" (list $ "" "") | nindent 4 }}
data:
Expand Down Expand Up @@ -83,7 +83,7 @@ data:
membership:
name: temporal
maxJoinDuration: 30s
broadcastAddress: {{ `{{ default .Env.POD_IP "0.0.0.0" }}` }}
broadcastAddress: {{ `{{ .Env.POD_IP }}` }}

pprof:
port: 7936
Expand Down
49 changes: 49 additions & 0 deletions charts/temporal/templates/server-entrypoint-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- if and .Values.server.enabled .Values.server.useEntrypointScript -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ include "temporal.fullname" $ }}-entrypoint-script"
labels:
{{- include "temporal.resourceLabels" (list $ "" "") | nindent 4 }}
data:
entrypoint.sh: |-
#!/bin/sh
set -e

echo "Temporal entrypoint override - starting ${TEMPORAL_SERVICES}"

{{- if eq .Values.server.configMapsToMount "both" }}
# Auto-detect config format based on dockerize availability
if command -v dockerize >/dev/null 2>&1; then
echo "Using dockerize config"
SOURCE_CONFIG="/etc/temporal/config-source/dockerize/config_template.yaml"
TARGET_CONFIG="/etc/temporal/config/docker.yaml"
dockerize -template "${SOURCE_CONFIG}:${TARGET_CONFIG}"
exec temporal-server --root / --config etc/temporal/config --env docker start --service="${TEMPORAL_SERVICES}"
else
echo "Using sprig config"
export TEMPORAL_SERVER_CONFIG_FILE_PATH="/etc/temporal/config-source/sprig/config_template.yaml"
exec temporal-server start
fi
{{- else if eq .Values.server.configMapsToMount "dockerize" }}
if ! command -v dockerize >/dev/null 2>&1; then
echo "ERROR: dockerize config requires dockerize but it was not found" >&2
echo "Either install an image with dockerize or use configMapsToMount: sprig" >&2
exit 1
fi

echo "Using dockerize config"
SOURCE_CONFIG="/etc/temporal/config-source/dockerize/config_template.yaml"
TARGET_CONFIG="/etc/temporal/config/docker.yaml"
dockerize -template "${SOURCE_CONFIG}:${TARGET_CONFIG}"
exec temporal-server --root / --config etc/temporal/config --env docker start --service="${TEMPORAL_SERVICES}"
{{- else if eq .Values.server.configMapsToMount "sprig" }}
echo "Using sprig config"
export TEMPORAL_SERVER_CONFIG_FILE_PATH="/etc/temporal/config-source/sprig/config_template.yaml"
exec temporal-server start
{{- else }}
echo "ERROR: Invalid configMapsToMount value: {{ .Values.server.configMapsToMount }}" >&2
echo "Must be one of: both, dockerize, sprig" >&2
exit 1
{{- end }}
{{- end }}
75 changes: 70 additions & 5 deletions charts/temporal/templates/server-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,27 @@ spec:
- 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;']
command: ['/bin/sh', '-c']
args:
- |
set -e
echo "Waiting for Elasticsearch to become available..."

if [ -x /usr/local/bin/temporal-elasticsearch-tool ]; then
echo "Using temporal-elasticsearch-tool for Elasticsearch health check"
until temporal-elasticsearch-tool --endpoint "$ES_SCHEME://$ES_HOST:$ES_PORT" --user "$ES_USER" --password "$ES_PWD" ping 2>&1 > /dev/null; do
sleep 1
done
elif command -v curl >/dev/null 2>&1; then
echo "Using curl for Elasticsearch health check"
until curl --silent --fail --user "$ES_USER:$ES_PWD" "$ES_SCHEME://$ES_HOST:$ES_PORT" 2>&1 > /dev/null; do
sleep 1
done
else
echo "ERROR: Neither temporal-elasticsearch-tool nor curl found" >&2
exit 1
fi
echo "Elasticsearch is ready"
env:
{{- include "temporal.admintools-env" (list $ "visibility") | nindent 12 }}
{{- with $.Values.schema.containerSecurityContext }}
Expand Down Expand Up @@ -92,11 +112,56 @@ spec:
{{- else if eq $driver "sql" }}
command: ['temporal-sql-tool', 'setup-schema', '-v', '0.0']
{{- else if eq $driver "elasticsearch" }}
command: ['sh', '-c']
command: ['/bin/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'
- |
set -e
echo "Setting up Elasticsearch visibility store..."

if command -v curl >/dev/null 2>&1; then
echo "Using curl for Elasticsearch setup"

echo "Creating index template: temporal_visibility_v1_template"
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"

echo "Checking if index exists: $ES_VISIBILITY_INDEX"
if ! curl --head --fail --user "$ES_USER:$ES_PWD" \
"$ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX" 2>&1 > /dev/null; then
echo "Creating index: $ES_VISIBILITY_INDEX"
curl -X PUT --fail --user "$ES_USER:$ES_PWD" \
"$ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX"
else
echo "Index already exists"
fi

elif [ -x /usr/local/bin/temporal-elasticsearch-tool ]; then
Comment thread
chaptersix marked this conversation as resolved.
Outdated
echo "Using temporal-elasticsearch-tool for Elasticsearch setup"

echo "Setting up cluster settings and index template"
temporal-elasticsearch-tool \
--endpoint "$ES_SCHEME://$ES_HOST:$ES_PORT" \
--user "$ES_USER" \
--password "$ES_PWD" \
setup-schema

echo "Creating visibility index: $ES_VISIBILITY_INDEX"
temporal-elasticsearch-tool \
--endpoint "$ES_SCHEME://$ES_HOST:$ES_PORT" \
--user "$ES_USER" \
--password "$ES_PWD" \
create-index \
--index "$ES_VISIBILITY_INDEX" \
--fail

else
echo "ERROR: Neither curl nor temporal-elasticsearch-tool found" >&2
exit 1
fi

echo "Elasticsearch setup completed successfully"
{{- end }}
env:
{{- include "temporal.admintools-env" (list $ $store) | nindent 12 }}
Expand Down
Loading
Loading