Alexander Dehn | ab86ec1 | 2020-02-05 14:38:54 +0000 | [diff] [blame] | 1 | # Copyright © 2020 Bitnami, AT&T, Amdocs, Bell Canada, highstreet technologies |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | apiVersion: apps/v1 |
| 15 | kind: StatefulSet |
| 16 | {{ $role := "data" -}} |
| 17 | {{ $suffix := $role -}} |
| 18 | {{ $labels := (dict "role" $role "discovery" (include "elasticsearch.clustername" .)) -}} |
| 19 | metadata: {{- include "common.resourceMetadata" (dict "suffix" $suffix "labels" $labels "dot" . )| nindent 2 }} |
| 20 | spec: |
| 21 | updateStrategy: |
| 22 | type: {{ .Values.updateStrategy.type }} |
| 23 | {{- if (eq "OnDelete" .Values.updateStrategy.type) }} |
| 24 | rollingUpdate: null |
| 25 | {{- else if .Values.updateStrategy.rollingUpdatePartition }} |
| 26 | rollingUpdate: |
| 27 | partition: {{ .Values.updateStrategy.rollingUpdatePartition }} |
| 28 | {{- end }} |
| 29 | selector: {{- include "common.selectors" (dict "matchLabels" $labels "dot" .) | nindent 4 }} |
| 30 | serviceName: {{ include "common.fullname" . }}-data |
| 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.data.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 Dehn | 9b797d6 | 2020-04-21 09:53:50 +0000 | [diff] [blame] | 88 | - name: {{ include "common.name" . }}-data |
Alexander Dehn | c2a3686 | 2020-09-02 11:48:20 +0000 | [diff] [blame] | 89 | image: {{ printf "%s/%s" (include "common.repository" .) .Values.image }} |
Alexander Dehn | ab86ec1 | 2020-02-05 14:38:54 +0000 | [diff] [blame] | 90 | 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 Dehn | c2a3686 | 2020-09-02 11:48:20 +0000 | [diff] [blame] | 97 | value: {{ ternary "true" "false" .Values.debug | quote }} |
Alexander Dehn | ab86ec1 | 2020-02-05 14:38:54 +0000 | [diff] [blame] | 98 | - name: ELASTICSEARCH_CLUSTER_NAME |
| 99 | value: {{include "elasticsearch.clustername" .}} |
| 100 | - name: ELASTICSEARCH_CLUSTER_HOSTS |
| 101 | value: {{ include "common.name" . }}-discovery |
| 102 | {{- if .Values.plugins }} |
| 103 | - name: ELASTICSEARCH_PLUGINS |
| 104 | value: {{ .Values.plugins | quote }} |
| 105 | {{- end }} |
| 106 | - name: ELASTICSEARCH_HEAP_SIZE |
| 107 | value: {{ .Values.heapSize | quote }} |
| 108 | - name: ELASTICSEARCH_IS_DEDICATED_NODE |
| 109 | value: "yes" |
| 110 | - name: ELASTICSEARCH_NODE_TYPE |
| 111 | value: "data" |
| 112 | ports: {{- include "common.containerPorts" . |indent 12 }} |
| 113 | {{- if .Values.livenessProbe.enabled }} |
| 114 | livenessProbe: |
| 115 | initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} |
| 116 | periodSeconds: {{ .Values.livenessProbe.periodSeconds }} |
| 117 | timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} |
| 118 | successThreshold: {{ .Values.livenessProbe.successThreshold }} |
| 119 | failureThreshold: {{ .Values.livenessProbe.failureThreshold }} |
| 120 | httpGet: |
| 121 | path: /_cluster/health?local=true |
| 122 | port: 9200 |
| 123 | {{- end }} |
| 124 | {{- if .Values.readinessProbe.enabled }} |
| 125 | readinessProbe: |
| 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.resources }} |
| 136 | resources: {{- toYaml .Values.resources | nindent 12 }} |
| 137 | {{- end }} |
| 138 | volumeMounts: |
| 139 | {{- if .Values.config }} |
| 140 | - mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml |
| 141 | name: "config" |
| 142 | subPath: elasticsearch.yml |
| 143 | {{- end }} |
| 144 | - name: "data" |
| 145 | mountPath: "/bitnami/elasticsearch/data" |
| 146 | {{- if .Values.extraVolumeMounts }} |
| 147 | {{- toYaml .Values.extraVolumeMounts | nindent 12 }} |
| 148 | {{- end }} |
| 149 | volumes: |
| 150 | {{- if .Values.config }} |
| 151 | - name: "config" |
| 152 | configMap: |
| 153 | name: {{ template "common.fullname" . }} |
| 154 | {{- end }} |
| 155 | {{- if .Values.extraVolumes }} |
| 156 | {{- toYaml .Values.extraVolumes | nindent 8 }} |
| 157 | {{- end }} |
| 158 | {{- if not .Values.persistence.enabled }} |
| 159 | - name: "data" |
| 160 | emptyDir: {} |
| 161 | {{- else }} |
| 162 | volumeClaimTemplates: |
| 163 | - metadata: |
| 164 | name: "data" |
| 165 | {{- if .Values.persistence.annotations }} |
| 166 | annotations: {{- toYaml .Values.persistence.annotations | nindent 10 }} |
| 167 | {{- end }} |
| 168 | spec: |
| 169 | accessModes: |
| 170 | - {{ .Values.persistence.accessMode }} |
| 171 | storageClassName: {{ include "common.storageClass" (dict "dot" . "suffix" .Values.persistence.suffix) }} |
| 172 | resources: |
| 173 | requests: |
| 174 | storage: {{ .Values.persistence.size | quote }} |
| 175 | {{- end }} |