Skip to content

Commit 1a4f0ef

Browse files
committed
New approach for ElasticSearch template
When just having a single nodeSet with count for replication, we can't control which pod gets decommissioned when scaling down. Using named replicas we can achieve better control for these kinds of use-cases.
1 parent 523aa95 commit 1a4f0ef

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

generators/resources/elasticsearch.yaml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
# Example values.yaml:
77
# resources:
88
# %{camelName}:
9-
# replicas: 2 # Note: 2 replicas will also add a small third tiebreaker node
9+
# # Instead of using just a number to specify the number of replicas, we use
10+
# # a list of names. This allows controlling exactly which replica gets shut down
11+
# # when scaling down, which is useful when eg. decommissioning a node.
12+
# # Note: 2 replicas will also add a small third tiebreaker node
13+
# namedReplicas:
14+
# - replica1
15+
# - replica2
1016
# memory: 1Gi # Provide at least 1Gi of RAM to avoid OOM kills
1117
# cpu: 1
1218
# disk: 10Gi
@@ -37,8 +43,9 @@ spec:
3743
elasticsearchRefs:
3844
- name: {{ .Chart.Name }}%{suffix}
3945
nodeSets:
40-
- name: default
41-
count: {{ .Values.resources.%{camelName}.replicas }}
46+
{{ range $replica := .Values.resources.%{camelName}.namedReplicas }}
47+
- name: {{ $replica }}
48+
count: 1
4249
config:
4350
node.store.allow_mmap: true # disable this if you haven't increased vm.max_map_count
4451
podTemplate:
@@ -53,11 +60,11 @@ spec:
5360
- name: elasticsearch
5461
resources:
5562
requests:
56-
memory: {{ .Values.resources.%{camelName}.memory }}
57-
cpu: {{ .Values.resources.%{camelName}.cpu }}
63+
memory: {{ $.Values.resources.%{camelName}.memory }}
64+
cpu: {{ $.Values.resources.%{camelName}.cpu }}
5865
limits:
59-
memory: {{ .Values.resources.%{camelName}.memory }}
60-
cpu: {{ .Values.resources.%{camelName}.cpu }}
66+
memory: {{ $.Values.resources.%{camelName}.memory }}
67+
cpu: {{ $.Values.resources.%{camelName}.cpu }}
6168
tolerations:
6269
- key: role
6370
value: database
@@ -72,12 +79,13 @@ spec:
7279
- ReadWriteOnce
7380
resources:
7481
requests:
75-
storage: {{ .Values.resources.%{camelName}.disk }}
76-
{{- if eq (int .Values.resources.%{camelName}.replicas) 2 }}
82+
storage: {{ $.Values.resources.%{camelName}.disk }}
83+
{{ end }}
84+
{{- if eq (len .Values.resources.%{camelName}.namedReplicas) 2 }}
7785
- name: tiebreaker
7886
count: 1
7987
config:
80-
node.roles: [master, voting_only]
88+
node.roles: [master, voting_only, remote_cluster_client]
8189
podTemplate:
8290
spec:
8391
initContainers:

0 commit comments

Comments
 (0)