blob: ea805c1813e057472ace58f26aa046bc09bcdcf4 [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"
114 ports: {{- include "common.containerPorts" . |indent 12 }}
115 {{- if .Values.livenessProbe.enabled }}
116 livenessProbe:
117 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
118 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
119 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
120 successThreshold: {{ .Values.livenessProbe.successThreshold }}
121 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
122 httpGet:
123 path: /_cluster/health?local=true
124 port: 9200
125 {{- end }}
126 {{- if .Values.readinessProbe.enabled }}
127 readinessProbe:
128 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
129 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
130 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
131 successThreshold: {{ .Values.livenessProbe.successThreshold }}
132 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
133 httpGet:
134 path: /_cluster/health?local=true
135 port: 9200
136 {{- end }}
137 {{- if .Values.resources }}
138 resources: {{- toYaml .Values.resources | nindent 12 }}
139 {{- end }}
140 volumeMounts:
141 {{- if .Values.config }}
142 - mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml
143 name: "config"
144 subPath: elasticsearch.yml
145 {{- end }}
146 - name: "data"
147 mountPath: "/bitnami/elasticsearch/data"
148 {{- if .Values.extraVolumeMounts }}
149 {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
150 {{- end }}
151 volumes:
152 {{- if .Values.config }}
153 - name: "config"
154 configMap:
155 name: {{ template "common.fullname" . }}
156 {{- end }}
157 {{- if .Values.extraVolumes }}
158 {{- toYaml .Values.extraVolumes | nindent 8 }}
159 {{- end }}
160{{- if not .Values.persistence.enabled }}
161 - name: "data"
162 emptyDir: {}
163{{- else }}
164 volumeClaimTemplates:
165 - metadata:
166 name: "data"
167 {{- if .Values.persistence.annotations }}
168 annotations: {{- toYaml .Values.persistence.annotations | nindent 10 }}
169 {{- end }}
170 spec:
171 accessModes:
172 - {{ .Values.persistence.accessMode }}
173 storageClassName: {{ include "common.storageClass" (dict "dot" . "suffix" .Values.persistence.suffix) }}
174 resources:
175 requests:
176 storage: {{ .Values.persistence.size | quote }}
177{{- end }}