blob: 6744f75f2630ad42adccd132c0165a2a50dd48f2 [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 -}}
21{{ $labels := (dict "role" $role "discovery" (include "elasticsearch.clustername" .)) -}}
22metadata: {{- 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:
35{{- include "elasticsearch.imagePullSecrets" . | nindent 6 }}
36 {{- if .Values.affinity }}
37 affinity: {{- include "common.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
38 {{- end }}
39 {{- if .Values.nodeSelector }}
40 nodeSelector: {{- include "common.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
41 {{- end }}
42 {{- if .Values.tolerations }}
43 tolerations: {{- include "common.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
44 {{- end }}
45 serviceAccountName: {{ template "elasticsearch.serviceAccountName" . }}
46 {{- 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
55 image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.global.busyboxImage | default .Values.busyboxImage }}
56 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
70 image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.global.busyboxImage | default .Values.busyboxImage }}
71 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
Alexander Dehnc2a36862020-09-02 11:48:20 +000089 image: {{ printf "%s/%s" (include "common.repository" .) .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
99 value: {{ include "elasticsearch.clustername" . }}
100 - 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"
118 ports: {{- include "common.containerPorts" . |indent 12 }}
119 {{- if .Values.livenessProbe.enabled }}
120 livenessProbe:
121 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
122 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
123 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
124 successThreshold: {{ .Values.livenessProbe.successThreshold }}
125 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
126 httpGet:
127 path: /_cluster/health?local=true
128 port: 9200
129 {{- end }}
130 {{- if .Values.readinessProbe.enabled }}
131 readinessProbe:
132 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
133 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
134 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
135 successThreshold: {{ .Values.livenessProbe.successThreshold }}
136 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
137 httpGet:
138 path: /_cluster/health?local=true
139 port: 9200
140 {{- end }}
141 {{- if .Values.resources }}
142 resources: {{- toYaml .Values.resources | nindent 12 }}
143 {{- end }}
144 volumeMounts:
145 {{- if .Values.config }}
146 - mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml
147 name: config
148 subPath: elasticsearch.yml
149 {{- end }}
150 - name: data
151 mountPath: /bitnami/elasticsearch/data
152 {{- if .Values.extraVolumeMounts }}
153 {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
154 {{- end }}
155 volumes:
156 {{- if .Values.config }}
157 - name: config
158 configMap:
159 name: {{ include "common.fullname" . }}
160 {{- end }}
161 {{- if .Values.extraVolumes }}
162 {{- toYaml .Values.extraVolumes | nindent 8 }}
163 {{- end }}
164{{- if not .Values.persistence.enabled }}
165 - name: "data"
166 emptyDir: {}
167{{- else }}
168 volumeClaimTemplates:
169 - metadata:
170 name: "data"
171 {{- if .Values.persistence.annotations }}
172 annotations: {{- toYaml .Values.persistence.annotations | nindent 10 }}
173 {{- end }}
174 spec:
175 accessModes:
176 - {{ .Values.persistence.accessMode }}
177 storageClassName: {{ include "common.storageClass" (dict "dot" . "suffix" .Values.persistence.suffix) }}
178 resources:
179 requests:
180 storage: {{ .Values.persistence.size | quote }}
181{{- end }}