diff --git a/elasticsearch/templates/configmap.yaml b/elasticsearch/templates/configmap.yaml index 4274d8b7d..fa0ee3c59 100644 --- a/elasticsearch/templates/configmap.yaml +++ b/elasticsearch/templates/configmap.yaml @@ -1,4 +1,5 @@ {{- if .Values.esConfig }} +--- apiVersion: v1 kind: ConfigMap metadata: @@ -14,3 +15,20 @@ data: {{ $config | indent 4 -}} {{- end -}} {{- end -}} +{{- if .Values.esJVMOptions }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "elasticsearch.uname" . }}-jvm-options + labels: + heritage: {{ .Release.Service | quote }} + release: {{ .Release.Name | quote }} + chart: "{{ .Chart.Name }}" + app: "{{ template "elasticsearch.uname" . }}" +data: +{{- range $path, $config := .Values.esJVMOptions }} + {{ $path }}: | +{{ $config | indent 4 -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index 5daec98d5..e1b1b816b 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -57,7 +57,7 @@ spec: {{ $key }}: {{ $value | quote }} {{- end }} {{/* This forces a restart if the configmap has changed */}} - {{- if .Values.esConfig }} + {{- if or .Values.esConfig .Values.esJVMOptions }} configchecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }} {{- end }} spec: @@ -131,6 +131,11 @@ spec: configMap: name: {{ template "elasticsearch.uname" . }}-config {{- end }} + {{- if .Values.esJVMOptions }} + - name: esjvmoptions + configMap: + name: {{ template "elasticsearch.uname" . }}-jvm-options + {{- end }} {{- if .Values.keystore }} - name: keystore emptyDir: {} @@ -354,6 +359,11 @@ spec: mountPath: /usr/share/elasticsearch/config/{{ $path }} subPath: {{ $path }} {{- end -}} + {{- range $path, $config := .Values.esJVMOptions }} + - name: esjvmoptions + mountPath: /usr/share/elasticsearch/config/jvm.options.d/{{ $path }} + subPath: {{ $path }} + {{- end -}} {{- if .Values.extraVolumeMounts }} # Currently some extra blocks accept strings # to continue with backwards compatibility this is being kept diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index b8ce0fd53..d63cb7d7c 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -825,6 +825,37 @@ def test_adding_in_es_config(): ) +def test_adding_in_jvm_options(): + config = """ +esJVMOptions: + processors.options: | + -XX:ActiveProcessorCount=3 +""" + r = helm_template(config) + c = r["configmap"][uname + "-jvm-options"]["data"] + + assert "processors.options" in c + + assert "-XX:ActiveProcessorCount=3" in c["processors.options"] + + s = r["statefulset"][uname]["spec"]["template"]["spec"] + + assert { + "configMap": {"name": "elasticsearch-master-jvm-options"}, + "name": "esjvmoptions", + } in s["volumes"] + assert { + "mountPath": "/usr/share/elasticsearch/config/jvm.options.d/processors.options", + "name": "esjvmoptions", + "subPath": "processors.options", + } in s["containers"][0]["volumeMounts"] + + assert ( + "configchecksum" + in r["statefulset"][uname]["spec"]["template"]["metadata"]["annotations"] + ) + + def test_dont_add_data_volume_when_persistance_is_disabled(): config = """ persistence: diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 412a00323..d5bf3b62b 100644 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -31,6 +31,10 @@ esConfig: {} # log4j2.properties: | # key = value +esJVMOptions: {} +# processors.options: | +# -XX:ActiveProcessorCount=3 + # Extra environment variables to append to this nodeGroup # This will be appended to the current 'env:' key. You can use any of the kubernetes env # syntax here