Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

[elasticsearch] Add option to provide custom start/stop hooks #197

Merged
merged 7 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ helm install --name elasticsearch elastic/elasticsearch --version 7.2.0 --set im
| `ingress` | Configurable [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) to expose the Elasticsearch service. See [`values.yaml`](./values.yaml) for an example | `enabled: false` |
| `schedulerName` | Name of the [alternate scheduler](https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/#specify-schedulers-for-pods) | `nil` |
| `masterTerminationFix` | A workaround needed for Elasticsearch < 7.2.0 to prevent master status being lost during restarts [#63](https://github.com/elastic/helm-charts/issues/63) | `false` |
| `lifecycle` | Allows you to add lifecycle configuration. See [values.yaml](./values.yaml) for an example of the formatting. | `{}` |

## Try it out

Expand Down
1 change: 0 additions & 1 deletion elasticsearch/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- if .Values.esConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.lifecycle }}
Crazybus marked this conversation as resolved.
Show resolved Hide resolved
lifecycle:
{{ toYaml .Values.lifecycle | indent 10 }}
{{- end }}
17 changes: 17 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,20 @@ def test_master_termination_fixed_enabled():

c = r['statefulset'][uname]['spec']['template']['spec']['containers'][1]
assert c['name'] == 'elasticsearch-master-graceful-termination-handler'

def test_lifecycle_hooks():
config = ''
r = helm_template(config)
c = r['statefulset'][uname]['spec']['template']['spec']['containers'][0]
assert 'lifecycle' not in c

config = '''
lifecycle:
preStop:
exec:
command: ["/bin/bash","/preStop"]
'''
r = helm_template(config)
c = r['statefulset'][uname]['spec']['template']['spec']['containers'][0]

assert c['lifecycle']['preStop']['exec']['command'] == ["/bin/bash","/preStop"]
8 changes: 8 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,11 @@ fullnameOverride: ""

# https://github.com/elastic/helm-charts/issues/63
masterTerminationFix: false

lifecycle: {}
# preStop:
# exec:
# command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
# postStart:
# exec:
# command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]