From 5470bc0611c82628027013274ea88d51b1a6bda5 Mon Sep 17 00:00:00 2001 From: Tim Campbell Date: Wed, 13 Dec 2023 11:01:39 +0100 Subject: [PATCH] Add TLS field for simplicity --- templates/_helpers.tpl | 13 +++++++++++++ templates/configmap-env.yaml | 2 +- values.yaml | 5 +++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 6331a26..a58de9d 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -161,3 +161,16 @@ Find highest number of needed database connections to set DB_POOL variable {{- end }} {{- $poolSize | quote }} {{- end }} + +{{/* +Full hostname for a custom Elasticsearch cluster +*/}} +{{- define "mastodon.elasticsearch.fullHostname" -}} +{{- if not .Values.elasticsearch.enabled }} + {{- if .Values.elasticsearch.tls }} + {{- printf "https://%s" (tpl .Values.elasticsearch.hostname $) -}} + {{- else -}} + {{- printf "%s" (tpl .Values.elasticsearch.hostname $) -}} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/templates/configmap-env.yaml b/templates/configmap-env.yaml index 9258355..ab0d86a 100644 --- a/templates/configmap-env.yaml +++ b/templates/configmap-env.yaml @@ -23,7 +23,7 @@ data: ES_PORT: "9200" {{- else if .Values.elasticsearch.hostname }} ES_ENABLED: "true" - ES_HOST: {{ .Values.elasticsearch.hostname }} + ES_HOST: {{ include "mastodon.elasticsearch.fullHostname" .}} ES_PORT: {{ .Values.elasticsearch.port | default "9200" | quote }} {{- end }} {{- with .Values.elasticsearch.user }} diff --git a/values.yaml b/values.yaml index ffa86ea..8998fdd 100644 --- a/values.yaml +++ b/values.yaml @@ -259,10 +259,11 @@ elasticsearch: image: tag: 7 - # If you are using an external ES cluster, use `enabled: false` and set the hostname and port. - # When using a cluster with TLS enabled, the hostname must begin with https:// + # If you are using an external ES cluster, use `enabled: false` and set the hostname, port, + # and whether the cluster uses TLS. # hostname: # port: 9200 + # tls: true # This is optional, use it if you ES cluster requires authentication # user: