blob: a7278ba1044850982676085a7c612b46d789ec5d [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 +000016apiVersion: apps/v1
17kind: StatefulSet
18{{ $role := "data" -}}
19{{ $suffix := $role -}}
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010020{{ $labels := (dict "role" $role "discovery" .Values.cluster_name) -}}
Alexander Dehnab86ec12020-02-05 14:38:54 +000021metadata: {{- include "common.resourceMetadata" (dict "suffix" $suffix "labels" $labels "dot" . )| nindent 2 }}
22spec:
23 updateStrategy:
24 type: {{ .Values.updateStrategy.type }}
25 {{- if (eq "OnDelete" .Values.updateStrategy.type) }}
26 rollingUpdate: null
27 {{- else if .Values.updateStrategy.rollingUpdatePartition }}
28 rollingUpdate:
29 partition: {{ .Values.updateStrategy.rollingUpdatePartition }}
30 {{- end }}
31 selector: {{- include "common.selectors" (dict "matchLabels" $labels "dot" .) | nindent 4 }}
32 serviceName: {{ include "common.fullname" . }}-data
33 replicas: {{ .Values.replicaCount }}
34 template:
35 metadata: {{- include "common.templateMetadata" (dict "labels" $labels "dot" .) | nindent 6 }}
36 spec:
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010037 imagePullSecrets:
38 - name: "{{ include "common.namespace" . }}-docker-registry-key"
Alexander Dehnab86ec12020-02-05 14:38:54 +000039 {{- if .Values.affinity }}
40 affinity: {{- include "common.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
41 {{- end }}
42 {{- if .Values.nodeSelector }}
43 nodeSelector: {{- include "common.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
44 {{- end }}
45 {{- if .Values.tolerations }}
46 tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
47 {{- end }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000048 {{- if .Values.securityContext.enabled }}
49 securityContext:
50 fsGroup: {{ .Values.securityContext.fsGroup }}
51 {{- end }}
52 {{- if or .Values.sysctlImage.enabled (and .Values.volumePermissions.enabled .Values.persistence.enabled) }}
53 initContainers:
54 {{- if .Values.sysctlImage.enabled }}
55 ## Image that performs the sysctl operation to modify Kernel settings (needed sometimes to avoid boot errors)
56 - name: sysctl
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010057 image: {{ include "repositoryGenerator.image.busybox" . }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000058 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59 command:
60 - /bin/sh
61 - -c
62 - |
63 set -o errexit
64 set -o pipefail
65 set -o nounset
66 sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
67 securityContext:
68 privileged: true
69 {{- end }}
70 {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
71 - name: volume-permissions
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010072 image: {{ include "repositoryGenerator.image.busybox" . }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000073 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74 command:
75 - /bin/sh
76 - -c
77 - |
78 chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} //bitnami/elasticsearch/data
79 securityContext:
80 runAsUser: 0
81 {{- if .Values.volumePermissions.resource }}
82 resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
83 {{- end }}
84 volumeMounts:
85 - name: data
86 mountPath: "/bitnami/elasticsearch/data"
87 {{- end }}
88 {{- end }}
89 containers:
Alexander Dehn9b797d62020-04-21 09:53:50 +000090 - name: {{ include "common.name" . }}-data
Sylvain Desbureaux829344b2020-11-19 17:07:26 +010091 image: {{ printf "%s/%s" (include "repositoryGenerator.dockerHubRepository" .) .Values.image }}
Alexander Dehnab86ec12020-02-05 14:38:54 +000092 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
93 {{- if .Values.securityContext.enabled }}
94 securityContext:
95 runAsUser: {{ .Values.securityContext.runAsUser }}
96 {{- end }}
97 env:
98 - name: BITNAMI_DEBUG
Alexander Dehnc2a36862020-09-02 11:48:20 +000099 value: {{ ternary "true" "false" .Values.debug | quote }}
Alexander Dehnab86ec12020-02-05 14:38:54 +0000100 - name: ELASTICSEARCH_CLUSTER_NAME
Sylvain Desbureaux829344b2020-11-19 17:07:26 +0100101 value: {{ .Values.cluster_name }}
Alexander Dehnab86ec12020-02-05 14:38:54 +0000102 - name: ELASTICSEARCH_CLUSTER_HOSTS
103 value: {{ include "common.name" . }}-discovery
104 {{- if .Values.plugins }}
105 - name: ELASTICSEARCH_PLUGINS
106 value: {{ .Values.plugins | quote }}
107 {{- end }}
108 - name: ELASTICSEARCH_HEAP_SIZE
109 value: {{ .Values.heapSize | quote }}
110 - name: ELASTICSEARCH_IS_DEDICATED_NODE
111 value: "yes"
112 - name: ELASTICSEARCH_NODE_TYPE
113 value: "data"
Radoslaw Chmiel13a93682022-06-02 19:06:16 +0200114 - name: network.bind_host
115 value: 127.0.0.1
116 - name: network.publish_host
117 valueFrom:
118 fieldRef:
119 fieldPath: status.podIP
Alexander Dehnab86ec12020-02-05 14:38:54 +0000120 ports: {{- include "common.containerPorts" . |indent 12 }}
121 {{- if .Values.livenessProbe.enabled }}
122 livenessProbe:
123 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
124 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
125 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
126 successThreshold: {{ .Values.livenessProbe.successThreshold }}
127 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
128 httpGet:
129 path: /_cluster/health?local=true
130 port: 9200
131 {{- end }}
132 {{- if .Values.readinessProbe.enabled }}
133 readinessProbe:
134 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
135 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
136 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
137 successThreshold: {{ .Values.livenessProbe.successThreshold }}
138 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
139 httpGet:
140 path: /_cluster/health?local=true
141 port: 9200
142 {{- end }}
143 {{- if .Values.resources }}
144 resources: {{- toYaml .Values.resources | nindent 12 }}
145 {{- end }}
146 volumeMounts:
147 {{- if .Values.config }}
148 - mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml
149 name: "config"
150 subPath: elasticsearch.yml
151 {{- end }}
152 - name: "data"
153 mountPath: "/bitnami/elasticsearch/data"
154 {{- if .Values.extraVolumeMounts }}
155 {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
156 {{- end }}
157 volumes:
158 {{- if .Values.config }}
159 - name: "config"
160 configMap:
161 name: {{ template "common.fullname" . }}
162 {{- end }}
163 {{- if .Values.extraVolumes }}
164 {{- toYaml .Values.extraVolumes | nindent 8 }}
165 {{- end }}
166{{- if not .Values.persistence.enabled }}
167 - name: "data"
168 emptyDir: {}
169{{- else }}
170 volumeClaimTemplates:
171 - metadata:
172 name: "data"
173 {{- if .Values.persistence.annotations }}
174 annotations: {{- toYaml .Values.persistence.annotations | nindent 10 }}
175 {{- end }}
176 spec:
177 accessModes:
178 - {{ .Values.persistence.accessMode }}
179 storageClassName: {{ include "common.storageClass" (dict "dot" . "suffix" .Values.persistence.suffix) }}
180 resources:
181 requests:
182 storage: {{ .Values.persistence.size | quote }}
183{{- end }}