Skip to content

Commit

Permalink
[elasticsearch] elastic#1495 Configure JVM options files
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuildy committed Dec 19, 2021
1 parent fdc1776 commit e98e8aa
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
18 changes: 18 additions & 0 deletions elasticsearch/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.esConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -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 -}}
12 changes: 11 additions & 1 deletion elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: {}
Expand Down Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e98e8aa

Please sign in to comment.