From bc14827b6217816bef1c9036d69026f31038bbe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= Date: Thu, 25 Oct 2018 13:55:00 +0200 Subject: [PATCH] [incubator/elasticsearch] pre-stop-hook and post-start-hook drain scripts are now optional. (#8622) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need to always drain a data node that is restarting. Signed-off-by: Cédric de Saint Martin --- stable/elasticsearch/Chart.yaml | 2 +- stable/elasticsearch/README.md | 1 + stable/elasticsearch/templates/configmap.yaml | 2 ++ .../elasticsearch/templates/data-statefulset.yaml | 14 ++++++++------ stable/elasticsearch/values.yaml | 3 +++ 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/stable/elasticsearch/Chart.yaml b/stable/elasticsearch/Chart.yaml index 4e53fa69cc..83c0cd298b 100755 --- a/stable/elasticsearch/Chart.yaml +++ b/stable/elasticsearch/Chart.yaml @@ -1,6 +1,6 @@ name: elasticsearch home: https://www.elastic.co/products/elasticsearch -version: 1.12.0 +version: 1.13.0 appVersion: 6.4.2 description: Flexible and powerful open source, distributed real-time search and analytics engine. diff --git a/stable/elasticsearch/README.md b/stable/elasticsearch/README.md index 8b0a71642f..d19a29689f 100644 --- a/stable/elasticsearch/README.md +++ b/stable/elasticsearch/README.md @@ -110,6 +110,7 @@ The following table lists the configurable parameters of the elasticsearch chart | `data.resources` | Data node resources requests & limits | `{} - cpu limit must be an integer` | | `data.priorityClassName` | Data priorityClass | `nil` | | `data.heapSize` | Data node heap size | `1536m` | +| `data.hooks.drain.enabled | Data nodes: Enable drain pre-stop and post-start hook | `true` | | `data.persistence.enabled` | Data persistent enabled/disabled | `true` | | `data.persistence.name` | Data statefulset PVC template name | `data` | | `data.persistence.size` | Data persistent volume size | `30Gi` | diff --git a/stable/elasticsearch/templates/configmap.yaml b/stable/elasticsearch/templates/configmap.yaml index df8fd49c9e..dcc2422d54 100644 --- a/stable/elasticsearch/templates/configmap.yaml +++ b/stable/elasticsearch/templates/configmap.yaml @@ -119,6 +119,7 @@ data: logger.searchguard.name = com.floragunn logger.searchguard.level = info {{- end }} +{{- if .Values.data.hooks.drain.enabled }} pre-stop-hook.sh: |- #!/bin/bash exec &> >(tee -a "/var/log/elasticsearch-hooks.log") @@ -155,3 +156,4 @@ data: }" fi echo "Node ${NODE_NAME} is ready to be used" +{{- end }} diff --git a/stable/elasticsearch/templates/data-statefulset.yaml b/stable/elasticsearch/templates/data-statefulset.yaml index 2b3ca45a94..c17cbdad3a 100644 --- a/stable/elasticsearch/templates/data-statefulset.yaml +++ b/stable/elasticsearch/templates/data-statefulset.yaml @@ -138,18 +138,19 @@ spec: name: config subPath: log4j2.properties {{- end }} - - name: config - mountPath: /pre-stop-hook.sh - subPath: pre-stop-hook.sh - - name: config - mountPath: /post-start-hook.sh - subPath: post-start-hook.sh {{- if .Values.cluster.keystoreSecret }} - name: keystore mountPath: "/usr/share/elasticsearch/config/elasticsearch.keystore" subPath: elasticsearch.keystore readOnly: true {{- end }} +{{- if .Values.data.hooks.drain.enabled }} + - name: config + mountPath: /pre-stop-hook.sh + subPath: pre-stop-hook.sh + - name: config + mountPath: /post-start-hook.sh + subPath: post-start-hook.sh lifecycle: preStop: exec: @@ -157,6 +158,7 @@ spec: postStart: exec: command: ["/bin/bash","/post-start-hook.sh"] +{{- end }} terminationGracePeriodSeconds: {{ .Values.data.terminationGracePeriodSeconds }} {{- if .Values.image.pullSecrets }} imagePullSecrets: diff --git a/stable/elasticsearch/values.yaml b/stable/elasticsearch/values.yaml index 5cd7ee9cb6..04e655dc75 100644 --- a/stable/elasticsearch/values.yaml +++ b/stable/elasticsearch/values.yaml @@ -148,6 +148,9 @@ data: maxUnavailable: 1 updateStrategy: type: OnDelete + hooks: # post-start and pre-stop hooks + drain: # drain the node before stopping it and re-integrate it into the cluster after start + enabled: true ## Additional init containers extraInitContainers: |