Skip to content

Commit 0626843

Browse files
authored
[elasticsearch] use new node.roles settings (elastic#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 8ddb15b commit 0626843

File tree

12 files changed

+74
-73
lines changed

12 files changed

+74
-73
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/examples/migration/client.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
---
2-
32
replicas: 2
43

54
clusterName: "elasticsearch"
65
nodeGroup: "client"
76

87
esMajorVersion: 6
98

10-
roles:
11-
master: "false"
12-
ingest: "false"
13-
data: "false"
9+
roles: []
1410

1511
volumeClaimTemplate:
16-
accessModes: [ "ReadWriteOnce" ]
12+
accessModes: ["ReadWriteOnce"]
1713
storageClassName: "standard"
1814
resources:
1915
requests:

elasticsearch/examples/migration/data.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
replicas: 2
43

54
esMajorVersion: 6
@@ -12,6 +11,4 @@ clusterName: "elasticsearch"
1211
nodeGroup: "data"
1312

1413
roles:
15-
master: "false"
16-
ingest: "false"
17-
data: "true"
14+
- data

elasticsearch/examples/migration/master.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
# Temporarily set to 3 so we can scale up/down the old a new cluster
43
# one at a time whilst always keeping 3 masters running
54
replicas: 1
@@ -14,12 +13,10 @@ clusterName: "elasticsearch"
1413
nodeGroup: "master"
1514

1615
roles:
17-
master: "true"
18-
ingest: "false"
19-
data: "false"
16+
- master
2017

2118
volumeClaimTemplate:
22-
accessModes: [ "ReadWriteOnce" ]
19+
accessModes: ["ReadWriteOnce"]
2320
storageClassName: "standard"
2421
resources:
2522
requests:
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
32
clusterName: "multi"
43
nodeGroup: "client"
54

6-
roles:
7-
master: "false"
8-
ingest: "false"
9-
data: "false"
10-
ml: "false"
11-
remote_cluster_client: "false"
5+
roles: []
126

137
persistence:
148
enabled: false
9+
10+
# For client nodes, we also need to add an empty node.roles in elasticsearch.yml
11+
# This is due to https://github.com/elastic/helm-charts/pull/1186#discussion_r631225687
12+
esConfig:
13+
elasticsearch.yml: |
14+
node.roles: []
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
2-
32
clusterName: "multi"
43
nodeGroup: "data"
54

65
roles:
7-
master: "false"
8-
ingest: "true"
9-
data: "true"
10-
ml: "false"
11-
remote_cluster_client: "false"
6+
- data
7+
- data_content
8+
- data_hot
9+
- data_warm
10+
- data_cold
11+
- data_frozen
12+
- ingest
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
2-
32
clusterName: "multi"
43
nodeGroup: "master"
54

65
roles:
7-
master: "true"
8-
ingest: "false"
9-
data: "false"
10-
ml: "false"
11-
remote_cluster_client: "false"
6+
- master

elasticsearch/examples/security/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ clusterName: "security"
33
nodeGroup: "master"
44

55
roles:
6-
master: "true"
7-
ingest: "true"
8-
data: "true"
6+
- master
7+
- ingest
8+
- data
99

1010
protocol: https
1111

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/tests/elasticsearch_test.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ def test_defaults():
4545
{"name": "discovery.seed_hosts", "value": uname + "-headless"},
4646
{"name": "network.host", "value": "0.0.0.0"},
4747
{"name": "cluster.name", "value": clusterName},
48-
{"name": "node.master", "value": "true"},
49-
{"name": "node.data", "value": "true"},
50-
{"name": "node.ingest", "value": "true"},
48+
{
49+
"name": "node.roles",
50+
"value": "master,data,data_content,data_hot,data_warm,data_cold,ingest,ml,remote_cluster_client,transform,",
51+
},
5152
]
5253

5354
c = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][0]
@@ -174,7 +175,7 @@ def test_overriding_the_image_and_tag():
174175
def test_set_initial_master_nodes():
175176
config = """
176177
roles:
177-
master: "true"
178+
- master
178179
"""
179180
r = helm_template(config)
180181
env = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][0]["env"]
@@ -192,7 +193,7 @@ def test_set_initial_master_nodes():
192193
def test_dont_set_initial_master_nodes_if_not_master():
193194
config = """
194195
roles:
195-
master: "false"
196+
- data
196197
"""
197198
r = helm_template(config)
198199
env = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][0]["env"]
@@ -203,7 +204,7 @@ def test_dont_set_initial_master_nodes_if_not_master():
203204
def test_set_discovery_seed_host():
204205
config = """
205206
roles:
206-
master: "true"
207+
- master
207208
"""
208209
r = helm_template(config)
209210
env = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][0]["env"]
@@ -216,17 +217,6 @@ def test_set_discovery_seed_host():
216217
assert e["name"] != "discovery.zen.ping.unicast.hosts"
217218

218219

219-
def test_enabling_machine_learning_role():
220-
config = """
221-
roles:
222-
ml: "true"
223-
"""
224-
r = helm_template(config)
225-
env = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][0]["env"]
226-
227-
assert {"name": "node.ml", "value": "true"} in env
228-
229-
230220
def test_adding_extra_env_vars():
231221
config = """
232222
extraEnvs:

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)