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

Commit

Permalink
Merge pull request #197 from tetianakravchenko/elasticsearch-add-hooks
Browse files Browse the repository at this point in the history
[elasticsearch] Add option to provide custom start/stop hooks
  • Loading branch information
Crazybus authored Jul 5, 2019
2 parents 51d3afd + 58142e4 commit e1dbc59
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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 @@ -281,3 +281,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.lifecycle }}
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 @@ -196,3 +196,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"]

0 comments on commit e1dbc59

Please sign in to comment.