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 3 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
2 changes: 2 additions & 0 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ helm install --name elasticsearch elastic/elasticsearch --version 7.2.0 --set im
| `minimumMasterNodes` | The value for [discovery.zen.minimum_master_nodes](https://www.elastic.co/guide/en/elasticsearch/reference/6.7/discovery-settings.html#minimum_master_nodes). Should be set to `(master_eligible_nodes / 2) + 1`. Ignored in Elasticsearch versions >= 7. | `2` |
| `esMajorVersion` | Used to set major version specific configuration | `7` |
| `esConfig` | Allows you to add any config files in `/usr/share/elasticsearch/config/` such as `elasticsearch.yml` and `log4j2.properties`. See [values.yaml](./values.yaml) for an example of the formatting. | `{}` |
| `hooks` | Allows you to add lifecycle preStop, postStart hooks. See [values.yaml](./values.yaml) for an example of the formatting. | `{}` |
| `extraEnvs` | Extra [environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#using-environment-variables-inside-of-your-config) which will be appended to the `env:` definition for the container | `[]` |
| `extraVolumes` | Additional volumes to be passed to the `tpl` function | |
| `extraVolumeMounts` | Additional volumeMounts to be passed to the `tpl` function | |
Expand Down Expand Up @@ -106,6 +107,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
9 changes: 7 additions & 2 deletions elasticsearch/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{- if .Values.esConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -10,8 +8,15 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: "{{ template "uname" . }}"
data:
{{- if .Values.esConfig }}
{{- range $path, $config := .Values.esConfig }}
{{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}
{{- if .Values.hooks }}
{{- range $path, $config := .Values.hooks }}
{{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end }}
17 changes: 14 additions & 3 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ spec:
secret:
secretName: {{ .secretName }}
{{- end }}
{{- if .Values.esConfig }}
- name: esconfig
{{- if or .Values.esConfig .Values.hooks }}
- name: config
configMap:
name: {{ template "uname" . }}-config
{{- end }}
Expand Down Expand Up @@ -215,10 +215,17 @@ spec:
{{- end }}
{{- end }}
{{- range $path, $config := .Values.esConfig }}
- name: esconfig
- name: config
mountPath: /usr/share/elasticsearch/config/{{ $path }}
subPath: {{ $path }}
{{- end -}}
{{- if .Values.hooks }}
{{- range $path, $config := .Values.hooks }}
- name: config
mountPath: /{{ $path }}
Crazybus marked this conversation as resolved.
Show resolved Hide resolved
subPath: {{ $path }}
{{- end -}}
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ tpl .Values.extraVolumeMounts . | indent 10 }}
{{- end }}
Expand Down Expand Up @@ -276,3 +283,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 }}
16 changes: 16 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ esConfig: {}
# log4j2.properties: |
# key = value

# Add custom preStop, postStart lifecycle hooks
hooks: {}
## (string) Script to execute prior the pod stops.
# preStop: |-

## (string) Script to execute after the pod starts.
# postStart: |-

# 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 Expand Up @@ -184,3 +192,11 @@ fullnameOverride: ""

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

lifecycle: {}
# preStop:
# exec:
# command: ["/bin/bash","/preStop"]
# preStop:
Crazybus marked this conversation as resolved.
Show resolved Hide resolved
# exec:
# command: ["/bin/bash","/preStop"]