From 7f3c04640ac5d1734a2bfe8e7642417ebd8da4fd Mon Sep 17 00:00:00 2001 From: Matthew B <106352182+artntek@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:20:13 -0800 Subject: [PATCH 1/5] sutopopulating solr & rmq hostnames, claimname, mn_url --- helm/config/dataone-indexer.properties | 4 +- helm/templates/_helpers.tpl | 39 +++++++++++ helm/templates/configmap.yaml | 2 +- helm/templates/deployment.yaml | 27 ++++---- helm/values.yaml | 92 ++++++++++++++++++-------- 5 files changed, 120 insertions(+), 44 deletions(-) diff --git a/helm/config/dataone-indexer.properties b/helm/config/dataone-indexer.properties index 48fa1991..57cb921e 100644 --- a/helm/config/dataone-indexer.properties +++ b/helm/config/dataone-indexer.properties @@ -1,4 +1,4 @@ -index.d1node.baseURL={{ .Values.idxworker.mn_url }} +index.d1node.baseURL={{ include "idxworker.mn.url" . }} index.data.root.directory={{ .Values.idxworker.data_directory }} index.document.root.directory={{ .Values.idxworker.document_directory }} index.tdb.directory={{ .Values.idxworker.tripleDbDirectory }} @@ -12,7 +12,7 @@ index.rabbitmq.password=${env:RABBITMQ_PASSWORD} #If changing max priority, existing queue must be deleted, and consumers must use the same number index.rabbitmq.max.priority=10 -solr.base.uri=http://{{ .Values.solr.hostname }}: +solr.base.uri=http://{{ include "idxworker.solr.hostname" . }}: {{- .Values.solr.service.ports.http }}/solr/{{ .Values.solr.customCollection }} solr.query.uri=${solr.base.uri}/select/ solr.index.uri=${solr.base.uri}/update/?commit=true diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 413eb2d0..f950f8b8 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -61,6 +61,34 @@ Create the name of the service account to use {{- end }} {{- end }} +{{/* +set MN url +If we're running as a subchart, can use direct access without needing to go through ingress/https; + e.g. http://metacatbrooke-hl:8080/metacat/d1/mn +If connecting to an instance outside the cluster, should use https; + e.g. https://metacat-dev.test.dataone.org/metacat/d1/mn +*/}} +{{- define "idxworker.mn.url" -}} +{{- if not .Values.idxworker.mn_url }} +{{- printf "http://%s-hl:8080/%s/d1/mn" .Release.Name .Values.global.metacatAppContext }} +{{- else }} +{{- .Values.idxworker.mn_url }} +{{- end }} +{{- end }} + +{{/* +set Claim Name of existing PVC to use (typically the volume that is shared with metacat) +Either use the value set in .Values.persistence.claimName, or if blank, autopopulate with + {podname}-metacat-{releaseName}-0 (e.g. metacatbrooke-metacat-metacatbrooke-0) +*/}} +{{- define "idxworker.shared.claimName" -}} +{{- if not .Values.persistence.claimName }} +{{- .Release.Name }}-metacat-{{- .Release.Name }}-0 +{{- else }} +{{- .Values.persistence.claimName }} +{{- end }} +{{- end }} + {{/* set RabbitMQ HostName */}} @@ -71,3 +99,14 @@ set RabbitMQ HostName {{- .Values.rabbitmq.hostname }} {{- end }} {{- end }} + +{{/* +set Solr HostName +*/}} +{{- define "idxworker.solr.hostname" -}} +{{- if not .Values.solr.hostname }} +{{- .Release.Name }}-solr-headless +{{- else }} +{{- .Values.solr.hostname }} +{{- end }} +{{- end }} diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 61a82525..1975ddb6 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ .Release.Name }}-configfiles + name: {{ .Release.Name }}-indexer-configfiles labels: {{- include "idxworker.labels" . | nindent 4 }} data: diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index e37dc509..12916ef3 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -49,7 +49,7 @@ spec: subPath: dataone-indexer.properties name: {{ .Release.Name }}-config-volume - mountPath: {{ .Values.persistence.mountPath }} - name: {{ .Values.persistence.volumeName }} + name: indexer-metacat-pv readOnly: true - mountPath: /etc/dataone/tdb-cache name: {{ .Release.Name }}-temp-tripledb-volume @@ -94,13 +94,16 @@ spec: - sh - -c - > - URI="/solr/{{- .Values.solr.customCollection -}} + URI="/solr/ + {{- required "solr.customCollection IS REQUIRED" .Values.solr.customCollection -}} /admin/file?file=schema.xml&contentType=text/xml"; - until [[ $(echo -e "GET $URI HTTP/1.1\r\nHost: {{ .Values.solr.hostname -}} - \r\n\r\n" | nc {{ .Values.solr.hostname }}{{ print " " -}} - {{ .Values.solr.service.ports.http }} | grep -c " Date: Thu, 30 Nov 2023 11:00:50 -0800 Subject: [PATCH 2/5] move idxworker values out of bitnami subchart config --- helm/config/dataone-indexer.properties | 2 +- helm/templates/NOTES.txt | 4 +-- helm/templates/_helpers.tpl | 34 +++++++++++++++----- helm/templates/deployment.yaml | 7 +++-- helm/values.yaml | 43 ++++++++++++++------------ 5 files changed, 56 insertions(+), 34 deletions(-) diff --git a/helm/config/dataone-indexer.properties b/helm/config/dataone-indexer.properties index 57cb921e..9f84f2cc 100644 --- a/helm/config/dataone-indexer.properties +++ b/helm/config/dataone-indexer.properties @@ -5,7 +5,7 @@ index.tdb.directory={{ .Values.idxworker.tripleDbDirectory }} #The section for the rabbitMQ configuration index.rabbitmq.hostname={{ include "idxworker.rabbitmq.hostname" . }} -index.rabbitmq.hostport={{ default .Values.rabbitmq.service.ports.amqp .Values.rabbitmq.hostport }} +index.rabbitmq.hostport={{- include "idxworker.rabbitmq.hostport" . }} index.rabbitmq.username={{ .Values.rabbitmq.auth.username }} ## index.rabbitmq.password will be read from RABBITMQ_PASSWORD env var index.rabbitmq.password=${env:RABBITMQ_PASSWORD} diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index 40f62ce5..3b77c527 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -16,7 +16,7 @@ This is applicable when no passwords are set and therefore the random password i More information about the credentials may be found at https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#credential-errors-while-upgrading-chart-releases. -{{- $rmqHostPort := default .Values.rabbitmq.service.ports.amqp .Values.rabbitmq.hostport -}} +{{- $rmqHostPort := include "idxworker.rabbitmq.hostport" . -}} RabbitMQ can be accessed within the cluster on port {{ $rmqHostPort }} at {{ include "idxworker.rabbitmq.hostname" . }} @@ -42,7 +42,7 @@ SOLR: Solr can be accessed via port {{ .Values.global.solrPort }} on the following DNS name from within your cluster: - {{ .Values.solr.hostname }}:{{ .Values.global.solrPort }} + {{ include "idxworker.solr.hostname" . }}:{{ .Values.global.solrPort }} {{- if .Values.solr.auth.enabled }} diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index f950f8b8..18f51887 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -89,24 +89,42 @@ Either use the value set in .Values.persistence.claimName, or if blank, autopopu {{- end }} {{- end }} +{{/* +Check if RabbitMQ SubChart is enabled +*/}} +{{- define "rmq.enabled" -}} +{{ $rmqEnabled := (or (((.Values.global).rabbitmq).enabled) ((.Values.rabbitmq).enabled)) }} +{{ end }} + {{/* set RabbitMQ HostName */}} {{- define "idxworker.rabbitmq.hostname" -}} -{{- if not .Values.rabbitmq.hostname }} -{{- .Release.Name }}-rabbitmq-headless -{{- else }} -{{- .Values.rabbitmq.hostname }} +{{- $rmqHost := .Values.idxworker.rabbitmqHostname }} +{{- if and (include "rmq.enabled" .) (not $rmqHost) -}} +{{- $rmqHost = printf "%s-rabbitmq-headless" .Release.Name -}} +{{- end }} +{{- $rmqHost }} {{- end }} + +{{/* +set RabbitMQ HostPort +*/}} +{{- define "idxworker.rabbitmq.hostport" }} +{{- $rmqPort := .Values.idxworker.rabbitmqHostPort }} +{{- if and (include "rmq.enabled" .) (not $rmqPort) -}} +{{ $rmqPort = .Values.rabbitmq.service.ports.amqp }} +{{- end }} +{{- $rmqPort }} {{- end }} {{/* set Solr HostName */}} {{- define "idxworker.solr.hostname" -}} -{{- if not .Values.solr.hostname }} -{{- .Release.Name }}-solr-headless -{{- else }} -{{- .Values.solr.hostname }} +{{- $solrHost := .Values.idxworker.solrHostname }} +{{- if and (or (((.Values.global).solr).enabled) ((.Values.solr).enabled)) (not $solrHost) -}} + {{- $solrHost = printf "%s-solr-headless" .Release.Name -}} {{- end }} +{{- $solrHost }} {{- end }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 12916ef3..1976c82c 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -85,9 +85,10 @@ spec: - sh - -c - > - until nc -z {{ include "idxworker.rabbitmq.hostname" . }}{{- print " " }} - {{- default .Values.rabbitmq.service.ports.amqp .Values.rabbitmq.hostport }} > - {{- print " " }}/dev/null; do echo waiting for RabbitMQ; sleep 2; done; + HOST="{{ include "idxworker.rabbitmq.hostname" . }}"; + PORT={{ include "idxworker.rabbitmq.hostport" . }}; + until nc -z $HOST $PORT > /dev/null; do + echo waiting for RabbitMQ at $HOST - port $PORT; sleep 1; done; - name: init-solr image: busybox:latest command: diff --git a/helm/values.yaml b/helm/values.yaml index 4c00f3f5..d52b161a 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -17,6 +17,7 @@ global: ## @param global.ephemeralVolumeStorageClass Optional override of global.storageClass. ## Can be used to assign a storageClass that has a 'Delete' Reclaim Policy, thus allowing ## ephemeral volumes to be cleaned up automatically (eg "csi-cephfs-sc-ephemeral") + ## Comment out to use default StorageClass, if one is set on your cluster ## ephemeralVolumeStorageClass: csi-cephfs-sc-ephemeral @@ -103,6 +104,21 @@ idxworker: ## cn_url: "https://cn.dataone.org/cn" + ## @param idxworker.solrHostname hostname of the solr service to use + ## Leave this value unset (solrHostname: "") to automatically populate when using solr subchart + ## + solrHostname: "" + + ## @param rabbitmq.hostname (idxworker-specific param): hostname of the rabbitmq service to use + ## Leave this value unset (hostname: "") to have it automatically populated + ## + rabbitmqHostname: "" + + ## @param rabbitmq.hostport (idxworker-specific param): hostport of the rabbitmq service + ## Leave this value unset (hostport: "") to have it automatically populated + ## + rabbitmqHostPort: "" + ## @param idxworker.data_directory Location of data within the metacat shared volume ## data_directory: /var/metacat/data @@ -119,19 +135,10 @@ idxworker: ## tripleDbDirectory: /etc/dataone/tdb-cache -## @section RabbitMQ Configuration +## @section RabbitMQ Bitnami Sub-Chart Configuration ## rabbitmq: enabled: true - ## @param rabbitmq.hostname (idxworker-specific param): hostname of the rabbitmq service to use - ## Leave this value unset (hostname: "") to have it automatically populated - ## - hostname: "" - ## @param rabbitmq.hostport (idxworker-specific param): hostport of the rabbitmq service - ## Leave this value unset (hostport: "") to have it automatically populated - ## - hostport: "" - persistence: size: 10Gi #replicaCount: 3 @@ -150,9 +157,10 @@ rabbitmq: existingPasswordSecret: "" -## @section Solr Configuration +## @section Solr Bitnami Sub-Chart Configuration ## solr: + enabled: true collection: temp_collection ## @param solr.customCollection (required) name of the solr collection to use @@ -163,11 +171,10 @@ solr: - dataone_core #javaMem: "-Xms512m -Xmx2g" - ## @param solr.hostname (idxworker-specific param): hostname of the solr service to use - ## Leave this value unset (hostname: "") to have it automatically populated - ## - hostname: "" - + containerSecurityContext: + runAsUser: 1000 + persistence: + size: 10Gi service: ports: ## @param solr.service.ports.http: see global.solrPort (required) @@ -183,8 +190,6 @@ solr: ## instead connecting to a solr instance outside the cluster ## enabled: false - persistence: - size: 10Gi extraVolumes: - name: solr-config configMap: @@ -200,5 +205,3 @@ solr: postStart: exec: command: ["/bin/bash", "-c", "/solrconfig/config-solr.sh"] - containerSecurityContext: - runAsUser: 1000 From 78ea9be509e570a4c732a96623ce72b7ebe8b18c Mon Sep 17 00:00:00 2001 From: Matthew B <106352182+artntek@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:13:06 -0800 Subject: [PATCH 3/5] minor doc tweaks --- helm/templates/NOTES.txt | 6 ++++-- helm/values.yaml | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index 3b77c527..79c53e72 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -4,13 +4,14 @@ APP VERSION: {{ .Chart.AppVersion }} ** Please be patient while the chart is being deployed ** + RABBITMQ: ========= Credentials: echo "Username: {{ .Values.rabbitmq.auth.username }}" - echo "Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ .Values.rabbitmq.auth.existingPasswordSecret }} -o jsonpath="{.data.rabbitmq-password}" | base64 -d)" + echo "To get password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ .Values.rabbitmq.auth.existingPasswordSecret }} -o jsonpath="{.data.rabbitmq-password}" | base64 -d)" -Note that the credentials are saved in persistent volume claims and will not be changed upon upgrade or reinstallation unless the persistent volume claim has been deleted. If this is not the first installation of this chart, the credentials may not be valid. +IMPORTANT NOTE: the credentials are saved in persistent volume claims and will not be changed upon upgrade or re-installation unless the persistent volume claim has been deleted. If this is not the first installation of this chart, the credentials may not be valid. This is applicable when no passwords are set and therefore the random password is autogenerated. In case of using a fixed password, you should specify it when upgrading. @@ -37,6 +38,7 @@ Then, open the obtained URL in a browser. {{- end }} + SOLR: ===== Solr can be accessed via port {{ .Values.global.solrPort }} on the following DNS name from within diff --git a/helm/values.yaml b/helm/values.yaml index d52b161a..97f48ee9 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -105,17 +105,17 @@ idxworker: cn_url: "https://cn.dataone.org/cn" ## @param idxworker.solrHostname hostname of the solr service to use - ## Leave this value unset (solrHostname: "") to automatically populate when using solr subchart + ## Leave unset (solrHostname: "") to automatically populate when using solr bitnami subchart ## solrHostname: "" - ## @param rabbitmq.hostname (idxworker-specific param): hostname of the rabbitmq service to use - ## Leave this value unset (hostname: "") to have it automatically populated + ## @param idxworker.rabbitmqHostname hostname of the rabbitmq service to use + ## Leave unset (rabbitmqHostname: "") to automatically populate when using rmq bitnami subchart ## rabbitmqHostname: "" - ## @param rabbitmq.hostport (idxworker-specific param): hostport of the rabbitmq service - ## Leave this value unset (hostport: "") to have it automatically populated + ## @param idxworker.rabbitmqHostPort hostport of the rabbitmq service + ## Leave unset (rabbitmqHostPort: "") to automatically populate when using rmq bitnami subchart ## rabbitmqHostPort: "" From f43d43f4b3b9c474813060c2d71bb16fd176b010 Mon Sep 17 00:00:00 2001 From: Matthew B <106352182+artntek@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:29:43 -0800 Subject: [PATCH 4/5] DRY --- helm/templates/_helpers.tpl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 18f51887..503c0f3f 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -69,10 +69,11 @@ If connecting to an instance outside the cluster, should use https; e.g. https://metacat-dev.test.dataone.org/metacat/d1/mn */}} {{- define "idxworker.mn.url" -}} -{{- if not .Values.idxworker.mn_url }} +{{- $mn_url := .Values.idxworker.mn_url }} +{{- if not $mn_url }} {{- printf "http://%s-hl:8080/%s/d1/mn" .Release.Name .Values.global.metacatAppContext }} {{- else }} -{{- .Values.idxworker.mn_url }} +{{- $mn_url }} {{- end }} {{- end }} @@ -82,10 +83,11 @@ Either use the value set in .Values.persistence.claimName, or if blank, autopopu {podname}-metacat-{releaseName}-0 (e.g. metacatbrooke-metacat-metacatbrooke-0) */}} {{- define "idxworker.shared.claimName" -}} -{{- if not .Values.persistence.claimName }} +{{- $claimName := .Values.persistence.claimName }} +{{- if not $claimName }} {{- .Release.Name }}-metacat-{{- .Release.Name }}-0 {{- else }} -{{- .Values.persistence.claimName }} +{{- $claimName }} {{- end }} {{- end }} From 82a74e71933c9acfa835a0166a5c14b27be55339 Mon Sep 17 00:00:00 2001 From: Matthew B <106352182+artntek@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:35:41 -0800 Subject: [PATCH 5/5] missed an edit --- helm/templates/_helpers.tpl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 503c0f3f..66962069 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -71,10 +71,9 @@ If connecting to an instance outside the cluster, should use https; {{- define "idxworker.mn.url" -}} {{- $mn_url := .Values.idxworker.mn_url }} {{- if not $mn_url }} -{{- printf "http://%s-hl:8080/%s/d1/mn" .Release.Name .Values.global.metacatAppContext }} -{{- else }} -{{- $mn_url }} +{{- $mn_url = printf "http://%s-hl:8080/%s/d1/mn" .Release.Name .Values.global.metacatAppContext }} {{- end }} +{{- $mn_url }} {{- end }} {{/* @@ -85,10 +84,9 @@ Either use the value set in .Values.persistence.claimName, or if blank, autopopu {{- define "idxworker.shared.claimName" -}} {{- $claimName := .Values.persistence.claimName }} {{- if not $claimName }} -{{- .Release.Name }}-metacat-{{- .Release.Name }}-0 -{{- else }} -{{- $claimName }} +{{- $claimName = .Release.Name }}-metacat-{{- .Release.Name }}-0 {{- end }} +{{- $claimName }} {{- end }} {{/*