blob: 85ea2bbc5415d8764b9ef4eaddb31c812ad52672 [file] [log] [blame]
Jakub Latusek3659d9f2020-09-14 16:21:55 +02001{{/*
Alexander Dehnab86ec12020-02-05 14:38:54 +00002# Copyright © 2020 Bitnami, AT&T, Amdocs, Bell Canada, highstreet technologies
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Jakub Latusek3659d9f2020-09-14 16:21:55 +020015*/}}
Alexander Dehnab86ec12020-02-05 14:38:54 +000016
17apiVersion: apps/v1
18kind: StatefulSet
19{{ $role := "master" -}}
20{{ $suffix := $role -}}
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010021{{ $labels := (dict "role" $role "discovery" .Values.cluster_name) -}}
Alexander Dehnab86ec12020-02-05 14:38:54 +000022metadata: {{- include "common.resourceMetadata" (dict "suffix" $suffix "labels" $labels "dot" . )| nindent 2 }}
23spec:
24 updateStrategy:
25 type: {{ .Values.updateStrategy.type }}
26 {{- if (eq "OnDelete" .Values.updateStrategy.type) }}
27 rollingUpdate: null
28 {{- end }}
29 selector: {{- include "common.selectors" (dict "matchLabels" $labels "dot" .)| nindent 4 }}
30 serviceName: {{ include "common.fullname" . }}-master
31 replicas: {{ .Values.replicaCount }}
32 template:
33 metadata: {{- include "common.templateMetadata" (dict "labels" $labels "dot" .) | nindent 6 }}
34 spec:
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010035 imagePullSecrets:
36 - name: "{{ include "common.namespace" . }}-docker-registry-key"
Alexander Dehnab86ec12020-02-05 14:38:54 +000037 {{- if .Values.affinity }}
38 affinity: {{- include "common.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
39 {{- end }}
40 {{- if .Values.nodeSelector }}
41 nodeSelector: {{- include "common.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
42 {{- end }}
43 {{- if .Values.tolerations }}
44 tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
45 {{- end }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000046 {{- if .Values.securityContext.enabled }}
47 securityContext:
48 fsGroup: {{ .Values.securityContext.fsGroup }}
49 {{- end }}
50 {{- if or .Values.sysctlImage.enabled (and .Values.volumePermissions.enabled .Values.persistence.enabled) }}
51 initContainers:
52 {{- if .Values.sysctlImage.enabled }}
53 ## Image that performs the sysctl operation to modify Kernel settings (needed sometimes to avoid boot errors)
54 - name: sysctl
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010055 image: {{ include "repositoryGenerator.image.busybox" . }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000056 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
57 command:
58 - /bin/sh
59 - -c
60 - |
61 set -o errexit
62 set -o pipefail
63 set -o nounset
64 sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
65 securityContext:
66 privileged: true
67 {{- end }}
68 {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
69 - name: volume-permissions
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010070 image: {{ include "repositoryGenerator.image.busybox" . }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000071 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72 command:
73 - /bin/sh
74 - -c
75 - |
76 chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} //bitnami/elasticsearch/data
77 securityContext:
78 runAsUser: 0
79 {{- if .Values.volumePermissions.resource }}
80 resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
81 {{- end }}
82 volumeMounts:
83 - name: data
84 mountPath: "/bitnami/elasticsearch/data"
85 {{- end }}
86 {{- end }}
87 containers:
Alexander Dehn9b797d62020-04-21 09:53:50 +000088 - name: {{ include "common.name" . }}-master
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010089 image: {{ printf "%s/%s" (include "repositoryGenerator.dockerHubRepository" .) .Values.image }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000090 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
91 {{- if .Values.securityContext.enabled }}
92 securityContext:
93 runAsUser: {{ .Values.securityContext.runAsUser }}
94 {{- end }}
95 env:
96 - name: BITNAMI_DEBUG
Alexander Dehnc2a36862020-09-02 11:48:20 +000097 value: {{ ternary "true" "false" .Values.debug | quote }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000098 - name: ELASTICSEARCH_CLUSTER_NAME
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010099 value: {{ .Values.cluster_name }}
Alexander Dehnab86ec12020-02-05 14:38:54 +0000100 - name: ELASTICSEARCH_CLUSTER_HOSTS
101 value: {{ include "common.name" . }}-discovery
102 - name: ELASTICSEARCH_CLUSTER_MASTER_HOSTS
103 {{- $elasticsearchMasterFullname := printf "%s-%s" (include "common.fullname" . ) "master" }}
104 {{- $replicas := int .Values.replicaCount }}
105 value: {{range $i, $e := until $replicas }}{{ $elasticsearchMasterFullname }}-{{ $e }} {{ end }}
106 - name: ELASTICSEARCH_MINIMUM_MASTER_NODES
107 value: {{ add (div .Values.replicaCount 2) 1 | quote }}
108 {{- if .Values.plugins }}
109 - name: ELASTICSEARCH_PLUGINS
110 value: {{ .Values.plugins | quote }}
111 {{- end }}
112 - name: ELASTICSEARCH_HEAP_SIZE
113 value: {{ .Values.heapSize | quote }}
114 - name: ELASTICSEARCH_IS_DEDICATED_NODE
115 value: {{ .Values.dedicatednode | quote }}
116 - name: ELASTICSEARCH_NODE_TYPE
117 value: "master"
Radoslaw Chmiel13a93682022-06-02 19:06:16 +0200118 - name: network.bind_host
119 value: 127.0.0.1
120 - name: network.publish_host
121 valueFrom:
122 fieldRef:
123 fieldPath: status.podIP
Alexander Dehnab86ec12020-02-05 14:38:54 +0000124 ports: {{- include "common.containerPorts" . |indent 12 }}
125 {{- if .Values.livenessProbe.enabled }}
126 livenessProbe:
127 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
128 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
129 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
130 successThreshold: {{ .Values.livenessProbe.successThreshold }}
131 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
132 httpGet:
133 path: /_cluster/health?local=true
134 port: 9200
135 {{- end }}
136 {{- if .Values.readinessProbe.enabled }}
137 readinessProbe:
138 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
139 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
140 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
141 successThreshold: {{ .Values.livenessProbe.successThreshold }}
142 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
143 httpGet:
144 path: /_cluster/health?local=true
145 port: 9200
146 {{- end }}
147 {{- if .Values.resources }}
148 resources: {{- toYaml .Values.resources | nindent 12 }}
149 {{- end }}
150 volumeMounts:
151 {{- if .Values.config }}
152 - mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml
153 name: config
154 subPath: elasticsearch.yml
155 {{- end }}
156 - name: data
157 mountPath: /bitnami/elasticsearch/data
158 {{- if .Values.extraVolumeMounts }}
159 {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
160 {{- end }}
161 volumes:
162 {{- if .Values.config }}
163 - name: config
164 configMap:
165 name: {{ include "common.fullname" . }}
166 {{- end }}
167 {{- if .Values.extraVolumes }}
168 {{- toYaml .Values.extraVolumes | nindent 8 }}
169 {{- end }}
170{{- if not .Values.persistence.enabled }}
171 - name: "data"
172 emptyDir: {}
173{{- else }}
174 volumeClaimTemplates:
175 - metadata:
176 name: "data"
177 {{- if .Values.persistence.annotations }}
178 annotations: {{- toYaml .Values.persistence.annotations | nindent 10 }}
179 {{- end }}
180 spec:
181 accessModes:
182 - {{ .Values.persistence.accessMode }}
183 storageClassName: {{ include "common.storageClass" (dict "dot" . "suffix" .Values.persistence.suffix) }}
184 resources:
185 requests:
186 storage: {{ .Values.persistence.size | quote }}
187{{- end }}