Skip to content

Commit 6717225

Browse files
committed
chore: tidy up
1 parent dc5f82c commit 6717225

File tree

5 files changed

+48
-14
lines changed

5 files changed

+48
-14
lines changed

addons/elasticsearch/configs/elasticsearch-6.yml.tpl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@ cluster:
2222
discovery:
2323
{{- if eq $mode "multi-node" }}
2424
zen:
25-
minimum_master_nodes: 1
25+
{{- $masterCount := 0 }}
26+
{{- $parts := splitList ";" .ALL_CMP_REPLICA_FQDN }}
27+
{{- range $part := $parts }}
28+
{{- if hasPrefix "master:" $part }}
29+
{{- $masterPart := trimPrefix "master:" $part }}
30+
{{- $masters := splitList "," $masterPart }}
31+
{{- $masterCount = len $masters }}
32+
{{- end }}
33+
{{- end }}
34+
# Calculate minimum_master_nodes as quorum: (master_count / 2) + 1
35+
# This ensures cluster stability and prevents data loss
36+
minimum_master_nodes: {{ add (div $masterCount 2) 1 }}
2637
ping:
2738
unicast:
2839
hosts:
29-
{{- $parts := splitList ";" .ALL_CMP_REPLICA_FQDN }}
3040
{{- range $part := $parts }}
3141
{{- if hasPrefix "master:" $part }}
3242
{{- $masterPart := trimPrefix "master:" $part }}
@@ -66,7 +76,9 @@ node:
6676
{{- $myRoles := $roles | splitList "," }}
6777
{{- if semverCompare "<7.9" $esVersion }}
6878
{{- range $i, $e := $myRoles }}
79+
{{- if ne $e "transform" }}
6980
{{ $e }}: true
81+
{{- end }}
7082
{{- end }}
7183
{{- else }}
7284
roles:

addons/elasticsearch/scripts/member-leave.sh

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,33 @@ if [ $? != 0 ]; then
2626
exit 1
2727
fi
2828
version=${version%.*}
29-
if awk "BEGIN {exit !($version < 7.8)}"; then
30-
url=${endpoint}/_cluster/voting_config_exclusions/$KB_LEAVE_MEMBER_POD_NAME
29+
# Check if voting_config_exclusions API is supported (available from ES 7.0+)
30+
if awk "BEGIN {exit !($version >= 7.0)}"; then
31+
if awk "BEGIN {exit !($version < 7.8)}"; then
32+
url=${endpoint}/_cluster/voting_config_exclusions/$KB_LEAVE_MEMBER_POD_NAME
33+
else
34+
url=${endpoint}/_cluster/voting_config_exclusions?node_names=$KB_LEAVE_MEMBER_POD_NAME
35+
fi
36+
curl ${common_options} -v -X POST $url
37+
if [ $? != 0 ]; then
38+
echo "failed to add node $KB_LEAVE_MEMBER_POD_NAME to voting config exclusion list"
39+
echo "may be the voting config exclusion list is full, try to remove it first"
40+
curl ${common_options} -X DELETE "${endpoint}/_cluster/voting_config_exclusions?pretty&wait_for_removal=false"
41+
exit 1
42+
else
43+
echo "successfully added node $KB_LEAVE_MEMBER_POD_NAME to voting config exclusion list"
44+
fi
3145
else
32-
url=${endpoint}/_cluster/voting_config_exclusions?node_names=$KB_LEAVE_MEMBER_POD_NAME
33-
fi
34-
curl ${common_options} -v -X POST $url
35-
if [ $? != 0 ]; then
36-
echo "failed to add node $KB_LEAVE_MEMBER_POD_NAME to voting config exclusion list"
37-
echo "may be the voting config exclusion list is full, try to remove it first"
38-
curl ${common_options} -X DELETE "${endpoint}/_cluster/voting_config_exclusions?pretty&wait_for_removal=false"
39-
exit 1
40-
else
41-
echo "successfully added node $KB_LEAVE_MEMBER_POD_NAME to voting config exclusion list"
46+
echo "ES version $version does not support voting_config_exclusions API, skipping node exclusion"
47+
48+
# For ES 6.x, check if this is a master node and warn about minimum_master_nodes
49+
if [[ "$KB_LEAVE_MEMBER_POD_NAME" == *-master-* ]]; then
50+
echo "WARNING: Removing master node $KB_LEAVE_MEMBER_POD_NAME from ES $version cluster"
51+
echo "Please ensure the remaining master nodes count >= minimum_master_nodes setting"
52+
echo "Check cluster health after removal to avoid split-brain scenarios"
53+
else
54+
echo "Removing data node $KB_LEAVE_MEMBER_POD_NAME, data will be automatically migrated"
55+
fi
56+
57+
echo "Node $KB_LEAVE_MEMBER_POD_NAME will be removed from cluster naturally"
4258
fi

addons/elasticsearch/templates/cmpd-es-6.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ spec:
1919
password: Required
2020
- name: ELASTIC_PASSWORD
2121
value: $(ELASTIC_USER_PASSWORD)
22+
- name: ES_JAVA_OPTS
23+
value: "-Des.http.cname_in_publish_address=true"
2224
- name: KIBANA_SYSTEM_USER_PASSWORD
2325
valueFrom:
2426
credentialVarRef:

addons/elasticsearch/templates/cmpd-es-data-6.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ spec:
2525
password: Required
2626
- name: ELASTIC_PASSWORD
2727
value: $(ELASTIC_USER_PASSWORD)
28+
- name: ES_JAVA_OPTS
29+
value: "-Des.http.cname_in_publish_address=true"
2830
- name: KIBANA_SYSTEM_USER_PASSWORD
2931
valueFrom:
3032
credentialVarRef:

addons/elasticsearch/templates/cmpd-es-master-6.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ spec:
2525
password: Required
2626
- name: ELASTIC_PASSWORD
2727
value: $(ELASTIC_USER_PASSWORD)
28+
- name: ES_JAVA_OPTS
29+
value: "-Des.http.cname_in_publish_address=true"
2830
- name: KIBANA_SYSTEM_USER_PASSWORD
2931
valueFrom:
3032
credentialVarRef:

0 commit comments

Comments
 (0)