diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index 25e861b5..07770dce 100644 --- a/charts/common/Chart.yaml +++ b/charts/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 10.3.1 +version: 10.4.0 diff --git a/charts/common/templates/lib/controller/_prepare.tpl b/charts/common/templates/lib/controller/_prepare.tpl index e097a937..c6df7425 100644 --- a/charts/common/templates/lib/controller/_prepare.tpl +++ b/charts/common/templates/lib/controller/_prepare.tpl @@ -63,6 +63,24 @@ before chart installation. name: clickhousecreds key: ping {{- end }} + {{- if .Values.solr.enabled }} + - name: "SOLR_HOST" + valueFrom: + secretKeyRef: + name: solrcreds + key: plainhost + - name: SOLR_CORES + value: "{{ .Values.solr.solrCores }}" + - name: SOLR_ENABLE_AUTHENTICATION + value: "{{ .Values.solr.solrEnableAuthentication }}" + - name: SOLR_ADMIN_USERNAME + value: "{{ .Values.solr.solrUsername }}" + - name: SOLR_ADMIN_PASSWORD + valueFrom: + secretKeyRef: + name: solrcreds + key: solr-password + {{- end }} command: - "/bin/sh" - "-c" @@ -144,6 +162,14 @@ before chart installation. sleep 2 done {{- end }} + {{- if .Values.solr.enabled }} + if [ "$SOLR_ENABLE_AUTHENTICATION" == "yes" ]; then + until curl --fail --user "${SOLR_ADMIN_USERNAME}":"${SOLR_ADMIN_PASSWORD}" "${SOLR_HOST}":8983/solr/"${SOLR_CORES}"/admin/ping; do sleep 2; done + else + until curl --fail "${SOLR_HOST}":8983/solr/"${SOLR_CORES}"/admin/ping; do sleep 2; done + fi; + {{- end }} + EOF volumeMounts: diff --git a/charts/common/templates/lib/dependencies/_solrInjector.tpl b/charts/common/templates/lib/dependencies/_solrInjector.tpl new file mode 100644 index 00000000..ef98fc69 --- /dev/null +++ b/charts/common/templates/lib/dependencies/_solrInjector.tpl @@ -0,0 +1,32 @@ +{{/* +This template generates a random password and ensures it persists across updates/edits to the chart +*/}} +{{- define "tc.common.dependencies.solr.injector" -}} +{{- $host := printf "%v-%v" .Release.Name "solr" }} + +{{- if .Values.solr.enabled }} +--- +apiVersion: v1 +kind: Secret +metadata: + labels: + {{- include "tc.common.labels" . | nindent 4 }} + name: solrcreds +{{- $solrprevious := lookup "v1" "Secret" .Release.Namespace "solrcreds" }} +{{- $solrPass := "" }} +data: +{{- if $solrprevious }} + {{- $solrPass = ( index $solrprevious.data "solr-password" ) | b64dec }} + solr-password: {{ ( index $solrprevious.data "solr-password" ) }} +{{- else }} + {{- $solrPass = randAlphaNum 50 }} + solr-password: {{ $solrPass | b64enc | quote }} +{{- end }} + url: {{ ( printf "http://%v:%v@%v-solr:8983/%v" .Values.solr.solrUsername $solrPass .Release.Name .Values.solr.solrCores ) | b64enc | quote }} +type: Opaque +{{- $_ := set .Values.solr "solrPassword" ( $solrPass | quote ) }} +{{- $_ := set .Values.solr.url "plain" ( ( printf "%v-%v" .Release.Name "solr" ) | quote ) }} +{{- $_ := set .Values.solr.url "plainhost" ( ( printf "%v-%v" .Release.Name "solr" ) | quote ) }} + +{{- end }} +{{- end -}} diff --git a/charts/common/templates/loader/_init.tpl b/charts/common/templates/loader/_init.tpl index 2d939b3e..dd38d904 100644 --- a/charts/common/templates/loader/_init.tpl +++ b/charts/common/templates/loader/_init.tpl @@ -30,4 +30,7 @@ {{- /* Autogenerate clickhouse passwords if needed */ -}} {{- include "tc.common.dependencies.clickhouse.injector" . }} + + {{- /* Autogenerate solr passwords if needed */ -}} + {{- include "tc.common.dependencies.solr.injector" . }} {{- end -}} diff --git a/charts/common/values.yaml b/charts/common/values.yaml index 28bd7937..4496cc51 100644 --- a/charts/common/values.yaml +++ b/charts/common/values.yaml @@ -1166,3 +1166,11 @@ clickhouse: existingSecret: "clickhousecreds" # -- can be used to make an easy accessable note which URLS to use to access the DB. url: {} + +# -- solr dependency configuration +# @default -- See below +solr: + enabled: false + existingSecret: "solrcreds" + # -- can be used to make an easy accessable note which URLS to use to access the DB. + url: {}