From 2100d14fe335f2eee142d416268818475b31f496 Mon Sep 17 00:00:00 2001 From: Taehyun Kim Date: Mon, 29 Apr 2019 22:30:48 +0900 Subject: [PATCH] refactor configmap Signed-off-by: Taehyun Kim --- stable/elasticsearch/templates/configmap.yaml | 81 +++++-------------- 1 file changed, 22 insertions(+), 59 deletions(-) diff --git a/stable/elasticsearch/templates/configmap.yaml b/stable/elasticsearch/templates/configmap.yaml index e5863da295d2..20b22c78ce11 100644 --- a/stable/elasticsearch/templates/configmap.yaml +++ b/stable/elasticsearch/templates/configmap.yaml @@ -1,3 +1,4 @@ +{{ $majorAppVersion := regexFind "[0-9]*" .Values.appVersion | int -}} {{ $minorAppVersion := regexFind "[0-9]*.[0-9]*" .Values.appVersion | float64 -}} apiVersion: v1 kind: ConfigMap @@ -14,74 +15,39 @@ data: node.data: ${NODE_DATA:true} node.master: ${NODE_MASTER:true} -{{- if hasPrefix "5." .Values.appVersion }} - node.ingest: ${NODE_INGEST:true} -{{- else if hasPrefix "6." .Values.appVersion }} - node.ingest: ${NODE_INGEST:true} -{{- else if hasPrefix "7." .Values.appVersion }} +{{- if not (lt $majorAppVersion 5) }} node.ingest: ${NODE_INGEST:true} {{- end }} node.name: ${HOSTNAME} network.host: 0.0.0.0 -{{- if hasPrefix "2." .Values.appVersion }} - # see https://github.com/kubernetes/kubernetes/issues/3595 - bootstrap.mlockall: ${BOOTSTRAP_MLOCKALL:false} - - discovery: - zen: - ping.unicast.hosts: ${DISCOVERY_SERVICE:} - minimum_master_nodes: ${MINIMUM_MASTER_NODES:2} -{{- else if hasPrefix "5." .Values.appVersion }} - # see https://github.com/kubernetes/kubernetes/issues/3595 - bootstrap.memory_lock: ${BOOTSTRAP_MEMORY_LOCK:false} - - discovery: - zen: - ping.unicast.hosts: ${DISCOVERY_SERVICE:} - minimum_master_nodes: ${MINIMUM_MASTER_NODES:2} - - {{- if .Values.cluster.xpackEnable }} + {{- if and (not (lt $majorAppVersion 5)) .Values.cluster.xpackEnable }} # see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html - {{- if or ( gt $minorAppVersion 5.4 ) ( eq $minorAppVersion 5.4 ) }} + # or https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-xpack.html + {{- if not ( lt $minorAppVersion 5.4 ) }} xpack.ml.enabled: ${XPACK_ML_ENABLED:false} {{- end }} + xpack.monitoring.enabled: ${XPACK_MONITORING_ENABLED:false} - xpack.security.enabled: ${XPACK_SECURITY_ENABLED:false} - xpack.watcher.enabled: ${XPACK_WATCHER_ENABLED:false} - {{- else }} - {{- if or ( gt $minorAppVersion 5.4 ) ( eq $minorAppVersion 5.4 ) }} - xpack.ml.enabled: false + {{- if gt $minorAppVersion 6.3 }} + xpack.monitoring.collection.enabled: ${XPACK_MONITORING_ENABLED:false} {{- end }} - xpack.monitoring.enabled: false - xpack.security.enabled: false - xpack.watcher.enabled: false - {{- end }} -{{- else if hasPrefix "6." .Values.appVersion }} - # see https://github.com/kubernetes/kubernetes/issues/3595 - bootstrap.memory_lock: ${BOOTSTRAP_MEMORY_LOCK:false} - discovery: - zen: - ping.unicast.hosts: ${DISCOVERY_SERVICE:} - minimum_master_nodes: ${MINIMUM_MASTER_NODES:2} - - {{- if and ( .Values.cluster.xpackEnable ) ( gt $minorAppVersion 6.3 ) }} - # see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html - # After 6.3 xpack systems changed and are enabled by default and different configs manage them this enables monitoring - xpack.monitoring.collection.enabled: ${XPACK_MONITORING_ENABLED:false} - {{- else if .Values.cluster.xpackEnable }} - # see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html - xpack.ml.enabled: ${XPACK_ML_ENABLED:false} - xpack.monitoring.enabled: ${XPACK_MONITORING_ENABLED:false} xpack.security.enabled: ${XPACK_SECURITY_ENABLED:false} xpack.watcher.enabled: ${XPACK_WATCHER_ENABLED:false} {{- end }} -{{- else if hasPrefix "7." .Values.appVersion }} + + +{{- if not (lt $majorAppVersion 5) }} # see https://github.com/kubernetes/kubernetes/issues/3595 bootstrap.memory_lock: ${BOOTSTRAP_MEMORY_LOCK:false} +{{- else if not (lt $majorAppVersion 2) }} + # see https://github.com/kubernetes/kubernetes/issues/3595 + bootstrap.mlockall: ${BOOTSTRAP_MLOCKALL:false} +{{- end }} +{{- if not (lt $majorAppVersion 7) }} discovery.seed_hosts: - ${DISCOVERY_SERVICE:} cluster.initial_master_nodes: @@ -89,15 +55,11 @@ data: {{- range $i := untilStep 0 $replicas 1 }} - {{ template "elasticsearch.master.fullname" $ }}-{{ $i }} {{- end }} - - {{- if .Values.cluster.xpackEnable }} - # see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html - xpack.ml.enabled: ${XPACK_ML_ENABLED:false} - xpack.monitoring.enabled: ${XPACK_MONITORING_ENABLED:false} - xpack.monitoring.collection.enabled: ${XPACK_MONITORING_ENABLED:false} - xpack.security.enabled: ${XPACK_SECURITY_ENABLED:false} - xpack.watcher.enabled: ${XPACK_WATCHER_ENABLED:false} - {{- end }} +{{- else if not (lt $majorAppVersion 2) }} + discovery: + zen: + ping.unicast.hosts: ${DISCOVERY_SERVICE:} + minimum_master_nodes: ${MINIMUM_MASTER_NODES:2} {{- end }} # see https://github.com/elastic/elasticsearch-definitive-guide/pull/679 @@ -112,6 +74,7 @@ data: {{- with .Values.cluster.config }} {{ toYaml . | indent 4 }} {{- end }} + {{- if hasPrefix "2." .Values.appVersion }} logging.yml: |- # you can override this using by setting a system property, for example -Des.logger.level=DEBUG