Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions addons/elasticsearch/configs/elasticsearch-8.yml.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- $clusterName := .CLUSTER_NAME }}
{{- $defaultRoles := .ELASTICSEARCH_ROLES }}
{{- $namespace := .CLUSTER_NAMESPACE }}
{{- $zoneAwareEnabled := .ZONE_AWARE_ENABLED }}

{{- $mode := "multi-node" }}
{{- if index . "mode" }}
Expand All @@ -12,7 +13,11 @@ cluster:
routing:
allocation:
awareness:
{{- if eq $zoneAwareEnabled "true" }}
attributes: zone,k8s_node_name
{{- else }}
attributes: k8s_node_name
{{- end }}
# INITIAL_MASTER_NODES_BLOCK_START
{{- if eq $mode "multi-node" }}
initial_master_nodes:
Expand Down Expand Up @@ -62,6 +67,9 @@ network:
node:
attr:
k8s_node_name: ${NODE_NAME}
{{- if eq $zoneAwareEnabled "true" }}
zone: ${ZONE_NAME}
{{- end }}
name: ${POD_NAME}
store:
allow_mmap: false
Expand Down
48 changes: 48 additions & 0 deletions addons/elasticsearch/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env sh
cp /etc/pki/tls/* /usr/share/elasticsearch/config/
# Parse zone from ZONE_AWARE_MAPPING based on NODE_NAME
if [ "${ZONE_AWARE_ENABLED}" = "true" ]; then
if [ -z "${ZONE_AWARE_MAPPING}" ]; then
echo "Error: ZONE_AWARE_ENABLED is true but ZONE_AWARE_MAPPING is not set"
exit 1
fi
if [ -z "${NODE_NAME}" ]; then
echo "Error: ZONE_AWARE_ENABLED is true but NODE_NAME is not set"
exit 1
fi
ZONE_NAME=""
IFS=';' read -ra PARTS <<< "${ZONE_AWARE_MAPPING}"
for PART in "${PARTS[@]}"; do
IFS=':' read -ra ZONE_PART <<< "${PART}"
if [ ${#ZONE_PART[@]} -eq 2 ]; then
ZONE="${ZONE_PART[0]// /}"
NODES="${ZONE_PART[1]}"
IFS=',' read -ra NODE_LIST <<< "${NODES}"
for NODE in "${NODE_LIST[@]}"; do
NODE_NAME_TRIMMED="${NODE// /}"
if [ "${NODE_NAME_TRIMMED}" = "${NODE_NAME}" ]; then
export ZONE_NAME="${ZONE}"
break
fi
done
if [ -n "${ZONE_NAME}" ]; then
break
fi
fi
done
if [ -z "${ZONE_NAME}" ]; then
echo "Error: ZONE_AWARE_ENABLED is true but failed to find zone for node ${NODE_NAME} in ZONE_AWARE_MAPPING: ${ZONE_AWARE_MAPPING}"
exit 1
fi
fi
# remove initial master nodes block if cluster has been formed
if [ -f "${CLUSTER_FORMED_FILE}" ]; then
sed -i '/# INITIAL_MASTER_NODES_BLOCK_START/,/# INITIAL_MASTER_NODES_BLOCK_END/d' config/elasticsearch.yml
fi
if [ -f /bin/tini ]; then
/bin/tini -- /usr/local/bin/docker-entrypoint.sh
elif [ -f /tini ]; then
/tini -- /usr/local/bin/docker-entrypoint.sh
else
/usr/local/bin/docker-entrypoint.sh
fi
14 changes: 1 addition & 13 deletions addons/elasticsearch/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -392,19 +392,7 @@ runtime:
- sh
- -c
- |
cp /etc/pki/tls/* /usr/share/elasticsearch/config/
# remove initial master nodes block if cluster has been formed
if [ -f "${CLUSTER_FORMED_FILE}" ]; then
sed -i '/# INITIAL_MASTER_NODES_BLOCK_START/,/# INITIAL_MASTER_NODES_BLOCK_END/d' config/elasticsearch.yml
fi
if [ -f /bin/tini ]; then
/bin/tini -- /usr/local/bin/docker-entrypoint.sh
elif [ -f /tini ]; then
/tini -- /usr/local/bin/docker-entrypoint.sh
else
/usr/local/bin/docker-entrypoint.sh
fi

{{- .Files.Get "scripts/entrypoint.sh" | nindent 10 }}
env:
- name: POD_IP
valueFrom:
Expand Down
9 changes: 9 additions & 0 deletions addons/elasticsearch/templates/cmpd-es-data-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,13 @@ spec:
valueFrom:
tlsVarRef:
enabled: Optional
- name: ZONE_AWARE_ENABLED
value: {{ .Values.zoneAware.enabled | quote }}
{{/* ZONE_AWARE_MAPPING ='zone1:node1,node2;zone2:node3,node4,node5' */}}
- name: ZONE_AWARE_MAPPING
valueFrom:
configMapKeyRef:
optional: {{ .Values.zoneAware.enabled }}
name: {{ .Values.zoneAware.configMap }}
key: mapping
{{ include "elasticsearch.common" . | nindent 2 }}
9 changes: 9 additions & 0 deletions addons/elasticsearch/templates/cmpd-es-master-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,13 @@ spec:
valueFrom:
tlsVarRef:
enabled: Optional
- name: ZONE_AWARE_ENABLED
value: {{ .Values.zoneAware.enabled | quote }}
{{/* ZONE_AWARE_MAPPING ='zone1:node1,node2;zone2:node3,node4,node5' */}}
- name: ZONE_AWARE_MAPPING
valueFrom:
configMapKeyRef:
optional: {{ .Values.zoneAware.enabled }}
name: {{ .Values.zoneAware.configMap }}
key: mapping
{{ include "elasticsearch.common" . | nindent 2 }}
14 changes: 14 additions & 0 deletions addons/elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ kibanaVersions:
- ["8.9.1", "8.9.1", "8.9.1", false]
- ["8.15.5", "8.15.5", "8.15.5", false]

# @param zoneAware enable zone awareness
# @param zoneAware.enabled enable zone awareness
# @param zoneAware.configMap config map name for zone awareness mapping
# The config map should have the following format:
# apiVersion: v1
# kind: ConfigMap
# metadata:
# name: elasticsearch-zone-aware-mapping
# data:
# mapping: zone1:node1,node2;zone2:node3,node4,node5
zoneAware:
enabled: false
configMap: elasticsearch-zone-aware-mapping

exporter:
service:
port: 9114