Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / elasticsearch / components / master / templates / statefulset.yaml
1 {{/*
2 # 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.
15 */}}
16
17 apiVersion: apps/v1
18 kind: StatefulSet
19 {{ $role := "master" -}}
20 {{ $suffix := $role -}}
21 {{ $labels := (dict "role" $role "discovery" .Values.cluster_name) -}}
22 metadata: {{- include "common.resourceMetadata" (dict "suffix" $suffix "labels" $labels "dot" . )| nindent 2 }}
23 spec:
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 "common.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       {{- if .Values.securityContext.enabled }}
46       securityContext:
47         fsGroup: {{ .Values.securityContext.fsGroup }}
48       {{- end }}
49       {{- if or .Values.sysctlImage.enabled (and .Values.volumePermissions.enabled .Values.persistence.enabled) }}
50       initContainers:
51         {{- if .Values.sysctlImage.enabled }}
52         ## Image that performs the sysctl operation to modify Kernel settings (needed sometimes to avoid boot errors)
53         - name: sysctl
54           image: {{ include "repositoryGenerator.image.busybox" . }}
55           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
56           command:
57             - /bin/sh
58             - -c
59             - |
60               set -o errexit
61               set -o pipefail
62               set -o nounset
63               sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536
64           securityContext:
65             privileged: true
66         {{- end }}
67         {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
68         - name: volume-permissions
69           image: {{ include "repositoryGenerator.image.busybox" . }}
70           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
71           command:
72             - /bin/sh
73             - -c
74             - |
75               chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} //bitnami/elasticsearch/data
76           securityContext:
77             runAsUser: 0
78           {{- if .Values.volumePermissions.resource }}
79           resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
80           {{- end }}
81           volumeMounts:
82             - name: data
83               mountPath: "/bitnami/elasticsearch/data"
84         {{- end }}
85       {{- end }}
86       containers:
87         - name: {{ include "common.name" . }}-master
88           image: {{ printf "%s/%s" (include "repositoryGenerator.dockerHubRepository" .)  .Values.image }}
89           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
90           {{- if .Values.securityContext.enabled }}
91           securityContext:
92             runAsUser: {{ .Values.securityContext.runAsUser }}
93           {{- end }}
94           env:
95             - name: BITNAMI_DEBUG
96               value: {{ ternary "true" "false" .Values.debug | quote }}
97             - name: ELASTICSEARCH_CLUSTER_NAME
98               value: {{ .Values.cluster_name }}
99             - name: ELASTICSEARCH_CLUSTER_HOSTS
100               value: {{ include "common.name" . }}-discovery
101             - name: ELASTICSEARCH_CLUSTER_MASTER_HOSTS
102               {{- $elasticsearchMasterFullname := printf "%s-%s" (include "common.fullname" . ) "master" }}
103               {{- $replicas := int .Values.replicaCount }}
104               value: {{range $i, $e := until $replicas }}{{ $elasticsearchMasterFullname }}-{{ $e }} {{ end }}
105             - name: ELASTICSEARCH_MINIMUM_MASTER_NODES
106               value: {{ add (div .Values.replicaCount 2) 1 | quote }}
107             {{- if .Values.plugins }}
108             - name: ELASTICSEARCH_PLUGINS
109               value: {{ .Values.plugins | quote }}
110             {{- end }}
111             - name: ELASTICSEARCH_HEAP_SIZE
112               value: {{ .Values.heapSize | quote }}
113             - name: ELASTICSEARCH_IS_DEDICATED_NODE
114               value: {{ .Values.dedicatednode | quote }}
115             - name: ELASTICSEARCH_NODE_TYPE
116               value: "master"
117             - name: network.bind_host
118               value: 127.0.0.1
119             - name: network.publish_host
120               valueFrom:
121                 fieldRef:
122                   fieldPath: status.podIP
123           ports: {{- include "common.containerPorts" . |indent 12 }}
124           {{- if .Values.livenessProbe.enabled }}
125           livenessProbe:
126             initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
127             periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
128             timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
129             successThreshold: {{ .Values.livenessProbe.successThreshold }}
130             failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
131             httpGet:
132               path: /_cluster/health?local=true
133               port: 9200
134           {{- end }}
135           {{- if .Values.readinessProbe.enabled }}
136           readinessProbe:
137             initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
138             periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
139             timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
140             successThreshold: {{ .Values.livenessProbe.successThreshold }}
141             failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
142             httpGet:
143               path: /_cluster/health?local=true
144               port: 9200
145           {{- end }}
146           {{- if .Values.resources }}
147           resources: {{- toYaml .Values.resources | nindent 12 }}
148           {{- end }}
149           volumeMounts:
150             {{- if .Values.config }}
151             - mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml
152               name: config
153               subPath: elasticsearch.yml
154             {{- end }}
155             - name: data
156               mountPath: /bitnami/elasticsearch/data
157             {{- if .Values.extraVolumeMounts }}
158             {{- toYaml .Values.extraVolumeMounts | nindent 12 }}
159             {{- end }}
160       volumes:
161         {{- if .Values.config }}
162         - name: config
163           configMap:
164             name: {{ include "common.fullname" . }}
165         {{- end }}
166         {{- if .Values.extraVolumes }}
167         {{- toYaml .Values.extraVolumes | nindent 8 }}
168         {{- end }}
169 {{- if not .Values.persistence.enabled }}
170         - name: "data"
171           emptyDir: {}
172 {{- else }}
173   volumeClaimTemplates:
174     - metadata:
175         name: "data"
176         {{- if .Values.persistence.annotations }}
177         annotations: {{- toYaml .Values.persistence.annotations | nindent 10 }}
178         {{- end }}
179       spec:
180         accessModes:
181           - {{ .Values.persistence.accessMode }}
182         storageClassName: {{ include "common.storageClass" (dict "dot" . "suffix" .Values.persistence.suffix) }}
183         resources:
184           requests:
185             storage: {{ .Values.persistence.size | quote }}
186 {{- end }}