Skip to content

Commit 2c7b1d7

Browse files
authored
[elasticsearch] use new node.roles settings (#1186)
* [elasticsearch] use new node.roles settings This commit update Elasticsearch chart to use the new node.roles settings introduced in elastic/elasticsearch#54998. * [elasticsearch] update doc * [elasticsearch] update examples * add link to roles doc * add workaround for coordinating node * update roles list * fixup! update roles list * remove data_frozen from default roles this is needed because `data_frozen` role doesn't exist in Elasticsearch < 7.12.0 * fixup! remove data_frozen from default roles
1 parent fdc4a57 commit 2c7b1d7

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

elasticsearch/README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ support multiple versions with minimal changes.
154154
| `readinessProbe` | Configuration fields for the readiness [probe][] | see [values.yaml][] |
155155
| `replicas` | Kubernetes replica count for the StatefulSet (i.e. how many pods) | `3` |
156156
| `resources` | Allows you to set the [resources][] for the StatefulSet | see [values.yaml][] |
157-
| `roles` | A hash map with the specific [roles][] for the `nodeGroup` | see [values.yaml][] |
157+
| `roles` | A list with the specific [roles][] for the `nodeGroup` | see [values.yaml][] |
158158
| `schedulerName` | Name of the [alternate scheduler][] | `""` |
159159
| `secretMounts` | Allows you easily mount a secret as a file inside the StatefulSet. Useful for mounting certificates and other secrets. See [values.yaml][] for an example | `[]` |
160160
| `securityContext` | Allows you to set the [securityContext][] for the container | see [values.yaml][] |
@@ -212,8 +212,27 @@ while they share the same `clusterName` value.
212212

213213
For each Helm release, the nodes types can then be defined using `roles` value.
214214

215-
An example of Elasticsearch cluster using 2 different Helm releases for master
216-
and data nodes can be found in [examples/multi][].
215+
An example of Elasticsearch cluster using 2 different Helm releases for master,
216+
data and coordinating nodes can be found in [examples/multi][].
217+
218+
#### Coordinating nodes
219+
220+
Every node is implicitly a coordinating node. This means that a node that has an
221+
explicit empty list of roles will only act as a coordinating node.
222+
223+
When deploying coordinating-only node with Elasticsearch chart, it is required
224+
to define the empty list of roles in both `roles` value and `node.roles`
225+
settings:
226+
227+
```yaml
228+
roles: []
229+
230+
esConfig:
231+
elasticsearch.yml: |
232+
node.roles: []
233+
```
234+
235+
More details in [#1186 (comment)][]
217236
218237
#### Clustering and Node Discovery
219238
@@ -380,6 +399,7 @@ about our development and testing process.
380399

381400
[7.x]: https://github.com/elastic/helm-charts/releases
382401
[#63]: https://github.com/elastic/helm-charts/issues/63
402+
[#1186 (comment)]: https://github.com/elastic/helm-charts/pull/1186#discussion_r631166442
383403
[7.9.2]: https://github.com/elastic/helm-charts/blob/7.9.2/elasticsearch/README.md
384404
[BREAKING_CHANGES.md]: https://github.com/elastic/helm-charts/blob/master/BREAKING_CHANGES.md
385405
[CHANGELOG.md]: https://github.com/elastic/helm-charts/blob/master/CHANGELOG.md

elasticsearch/templates/_helpers.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
5151
{{- end -}}
5252
{{- end -}}
5353

54+
{{- define "elasticsearch.roles" -}}
55+
{{- range $.Values.roles -}}
56+
{{ . }},
57+
{{- end -}}
58+
{{- end -}}
59+
5460
{{- define "elasticsearch.esMajorVersion" -}}
5561
{{- if .Values.esMajorVersion -}}
5662
{{ .Values.esMajorVersion }}

elasticsearch/templates/statefulset.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,12 @@ spec:
295295
valueFrom:
296296
fieldRef:
297297
fieldPath: metadata.name
298-
{{- if eq .Values.roles.master "true" }}
299-
{{- if ge (int (include "elasticsearch.esMajorVersion" .)) 7 }}
298+
{{- if has "master" .Values.roles }}
300299
- name: cluster.initial_master_nodes
301300
value: "{{ template "elasticsearch.endpoints" . }}"
302-
{{- else }}
303-
- name: discovery.zen.minimum_master_nodes
304-
value: "{{ .Values.minimumMasterNodes }}"
305-
{{- end }}
306301
{{- end }}
302+
- name: node.roles
303+
value: "{{ template "elasticsearch.roles" . }}"
307304
{{- if lt (int (include "elasticsearch.esMajorVersion" .)) 7 }}
308305
- name: discovery.zen.ping.unicast.hosts
309306
value: "{{ template "elasticsearch.masterService" . }}-headless"
@@ -319,10 +316,6 @@ spec:
319316
- name: ES_JAVA_OPTS
320317
value: "{{ .Values.esJavaOpts }}"
321318
{{- end }}
322-
{{- range $role, $enabled := .Values.roles }}
323-
- name: node.{{ $role }}
324-
value: "{{ $enabled }}"
325-
{{- end }}
326319
{{- if .Values.extraEnvs }}
327320
{{ toYaml .Values.extraEnvs | indent 10 }}
328321
{{- end }}

elasticsearch/values.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ nodeGroup: "master"
77
masterService: ""
88

99
# Elasticsearch roles that will be applied to this nodeGroup
10-
# These will be set as environment variables. E.g. node.master=true
10+
# These will be set as environment variables. E.g. node.roles=master
11+
# https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html#node-roles
1112
roles:
12-
master: "true"
13-
ingest: "true"
14-
data: "true"
15-
remote_cluster_client: "true"
16-
ml: "true"
13+
- master
14+
- data
15+
- data_content
16+
- data_hot
17+
- data_warm
18+
- data_cold
19+
- ingest
20+
- ml
21+
- remote_cluster_client
22+
- transform
1723

1824
replicas: 3
1925
minimumMasterNodes: 2

0 commit comments

Comments
 (0)