github.com/microsoft/fabrikate@v1.0.0-alpha.1.0.20210115014322-dc09194d0885/testdata/generate/infra/fabrikate-jaeger/helm_repos/jaeger/charts/elasticsearch/templates/data-statefulset.yaml (about) 1 apiVersion: apps/v1 2 kind: StatefulSet 3 metadata: 4 labels: 5 app: {{ template "elasticsearch.name" . }} 6 chart: {{ .Chart.Name }}-{{ .Chart.Version }} 7 component: "{{ .Values.data.name }}" 8 heritage: {{ .Release.Service }} 9 release: {{ .Release.Name }} 10 name: {{ template "elasticsearch.data.fullname" . }} 11 spec: 12 selector: 13 matchLabels: 14 app: {{ template "elasticsearch.name" . }} 15 component: "{{ .Values.data.name }}" 16 release: {{ .Release.Name }} 17 role: data 18 serviceName: {{ template "elasticsearch.data.fullname" . }} 19 replicas: {{ .Values.data.replicas }} 20 template: 21 metadata: 22 labels: 23 app: {{ template "elasticsearch.name" . }} 24 component: "{{ .Values.data.name }}" 25 release: {{ .Release.Name }} 26 role: data 27 {{- if or .Values.data.podAnnotations (eq .Values.data.updateStrategy.type "RollingUpdate") }} 28 annotations: 29 {{- if .Values.data.podAnnotations }} 30 {{ toYaml .Values.data.podAnnotations | indent 8 }} 31 {{- end }} 32 {{- if eq .Values.data.updateStrategy.type "RollingUpdate" }} 33 checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} 34 {{- end }} 35 {{- end }} 36 spec: 37 {{- if .Values.schedulerName }} 38 schedulerName: "{{ .Values.schedulerName }}" 39 {{- end }} 40 serviceAccountName: {{ template "elasticsearch.serviceAccountName.data" . }} 41 {{- if .Values.data.priorityClassName }} 42 priorityClassName: "{{ .Values.data.priorityClassName }}" 43 {{- end }} 44 securityContext: 45 fsGroup: 1000 46 {{- if or .Values.data.antiAffinity .Values.data.nodeAffinity }} 47 affinity: 48 {{- end }} 49 {{- if eq .Values.data.antiAffinity "hard" }} 50 podAntiAffinity: 51 requiredDuringSchedulingIgnoredDuringExecution: 52 - topologyKey: "kubernetes.io/hostname" 53 labelSelector: 54 matchLabels: 55 app: "{{ template "elasticsearch.name" . }}" 56 release: "{{ .Release.Name }}" 57 component: "{{ .Values.data.name }}" 58 {{- else if eq .Values.data.antiAffinity "soft" }} 59 podAntiAffinity: 60 preferredDuringSchedulingIgnoredDuringExecution: 61 - weight: 1 62 podAffinityTerm: 63 topologyKey: kubernetes.io/hostname 64 labelSelector: 65 matchLabels: 66 app: "{{ template "elasticsearch.name" . }}" 67 release: "{{ .Release.Name }}" 68 component: "{{ .Values.data.name }}" 69 {{- end }} 70 {{- with .Values.data.nodeAffinity }} 71 nodeAffinity: 72 {{ toYaml . | indent 10 }} 73 {{- end }} 74 {{- if .Values.data.nodeSelector }} 75 nodeSelector: 76 {{ toYaml .Values.data.nodeSelector | indent 8 }} 77 {{- end }} 78 {{- if .Values.data.tolerations }} 79 tolerations: 80 {{ toYaml .Values.data.tolerations | indent 8 }} 81 {{- end }} 82 {{- if or .Values.extraInitContainers .Values.sysctlInitContainer.enabled .Values.chownInitContainer.enabled .Values.cluster.plugins }} 83 initContainers: 84 {{- end }} 85 {{- if .Values.sysctlInitContainer.enabled }} 86 # see https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html 87 # and https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration-memory.html#mlockall 88 - name: "sysctl" 89 image: "{{ .Values.initImage.repository }}:{{ .Values.initImage.tag }}" 90 imagePullPolicy: {{ .Values.initImage.pullPolicy | quote }} 91 resources: 92 {{ toYaml .Values.data.initResources | indent 12 }} 93 command: ["sysctl", "-w", "vm.max_map_count=262144"] 94 securityContext: 95 privileged: true 96 {{- end }} 97 {{- if .Values.chownInitContainer.enabled }} 98 - name: "chown" 99 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 100 imagePullPolicy: {{ .Values.image.pullPolicy | quote }} 101 resources: 102 {{ toYaml .Values.data.initResources | indent 12 }} 103 command: 104 - /bin/bash 105 - -c 106 - > 107 set -e; 108 set -x; 109 chown elasticsearch:elasticsearch /usr/share/elasticsearch/data; 110 for datadir in $(find /usr/share/elasticsearch/data -mindepth 1 -maxdepth 1 -not -name ".snapshot"); do 111 chown -R elasticsearch:elasticsearch $datadir; 112 done; 113 chown elasticsearch:elasticsearch /usr/share/elasticsearch/logs; 114 for logfile in $(find /usr/share/elasticsearch/logs -mindepth 1 -maxdepth 1 -not -name ".snapshot"); do 115 chown -R elasticsearch:elasticsearch $logfile; 116 done 117 securityContext: 118 runAsUser: 0 119 volumeMounts: 120 - mountPath: /usr/share/elasticsearch/data 121 name: data 122 {{- end }} 123 {{- if .Values.extraInitContainers }} 124 {{ tpl .Values.extraInitContainers . | indent 6 }} 125 {{- end }} 126 {{- if .Values.cluster.plugins }} 127 {{ include "plugin-installer" . | indent 6 }} 128 {{- end }} 129 containers: 130 - name: elasticsearch 131 env: 132 - name: DISCOVERY_SERVICE 133 value: {{ template "elasticsearch.fullname" . }}-discovery 134 - name: NODE_MASTER 135 value: "false" 136 - name: PROCESSORS 137 valueFrom: 138 resourceFieldRef: 139 resource: limits.cpu 140 - name: ES_JAVA_OPTS 141 value: "-Djava.net.preferIPv4Stack=true -Xms{{ .Values.data.heapSize }} -Xmx{{ .Values.data.heapSize }} {{ .Values.cluster.additionalJavaOpts }} {{ .Values.data.additionalJavaOpts }}" 142 {{- range $key, $value := .Values.cluster.env }} 143 - name: {{ $key }} 144 value: {{ $value | quote }} 145 {{- end }} 146 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 147 imagePullPolicy: {{ .Values.image.pullPolicy | quote }} 148 {{- if .Values.securityContext.enabled }} 149 securityContext: 150 runAsUser: {{ .Values.securityContext.runAsUser }} 151 {{- end }} 152 ports: 153 - containerPort: 9300 154 name: transport 155 {{ if .Values.data.exposeHttp }} 156 - containerPort: 9200 157 name: http 158 {{ end }} 159 resources: 160 {{ toYaml .Values.data.resources | indent 12 }} 161 readinessProbe: 162 {{ toYaml .Values.data.readinessProbe | indent 10 }} 163 volumeMounts: 164 - mountPath: /usr/share/elasticsearch/data 165 name: data 166 - mountPath: /usr/share/elasticsearch/config/elasticsearch.yml 167 name: config 168 subPath: elasticsearch.yml 169 {{- if .Values.cluster.plugins }} 170 - mountPath: /usr/share/elasticsearch/plugins/ 171 name: plugindir 172 {{- end }} 173 {{- if hasPrefix "2." .Values.appVersion }} 174 - mountPath: /usr/share/elasticsearch/config/logging.yml 175 name: config 176 subPath: logging.yml 177 {{- end }} 178 {{- if hasPrefix "5." .Values.appVersion }} 179 - mountPath: /usr/share/elasticsearch/config/log4j2.properties 180 name: config 181 subPath: log4j2.properties 182 {{- end }} 183 {{- if .Values.cluster.keystoreSecret }} 184 - name: keystore 185 mountPath: "/usr/share/elasticsearch/config/elasticsearch.keystore" 186 subPath: elasticsearch.keystore 187 readOnly: true 188 {{- end }} 189 {{- if or .Values.data.hooks.preStop .Values.data.hooks.drain.enabled }} 190 - name: config 191 mountPath: /data-pre-stop-hook.sh 192 subPath: data-pre-stop-hook.sh 193 {{- end }} 194 {{- if or .Values.data.hooks.postStart .Values.data.hooks.drain.enabled }} 195 - name: config 196 mountPath: /data-post-start-hook.sh 197 subPath: data-post-start-hook.sh 198 {{- end }} 199 {{- if or .Values.data.hooks.preStop .Values.data.hooks.postStart .Values.data.hooks.drain.enabled }} 200 lifecycle: 201 {{- if or .Values.data.hooks.preStop .Values.data.hooks.drain.enabled }} 202 preStop: 203 exec: 204 command: ["/bin/bash","/data-pre-stop-hook.sh"] 205 {{- end }} 206 {{- if or .Values.data.hooks.postStart .Values.data.hooks.drain.enabled }} 207 postStart: 208 exec: 209 command: ["/bin/bash","/data-post-start-hook.sh"] 210 {{- end }} 211 {{- end }} 212 terminationGracePeriodSeconds: {{ .Values.data.terminationGracePeriodSeconds }} 213 {{- if .Values.image.pullSecrets }} 214 imagePullSecrets: 215 {{- range $pullSecret := .Values.image.pullSecrets }} 216 - name: {{ $pullSecret }} 217 {{- end }} 218 {{- end }} 219 volumes: 220 - name: config 221 configMap: 222 name: {{ template "elasticsearch.fullname" . }} 223 {{- if .Values.cluster.plugins }} 224 - name: plugindir 225 emptyDir: {} 226 {{- end }} 227 {{- if .Values.cluster.keystoreSecret }} 228 - name: keystore 229 secret: 230 secretName: {{ .Values.cluster.keystoreSecret }} 231 {{- end }} 232 {{- if not .Values.data.persistence.enabled }} 233 - name: data 234 emptyDir: {} 235 {{- end }} 236 podManagementPolicy: {{ .Values.data.podManagementPolicy }} 237 updateStrategy: 238 type: {{ .Values.data.updateStrategy.type }} 239 {{- if .Values.data.persistence.enabled }} 240 volumeClaimTemplates: 241 - metadata: 242 name: {{ .Values.data.persistence.name }} 243 spec: 244 accessModes: 245 - {{ .Values.data.persistence.accessMode | quote }} 246 {{- if .Values.data.persistence.storageClass }} 247 {{- if (eq "-" .Values.data.persistence.storageClass) }} 248 storageClassName: "" 249 {{- else }} 250 storageClassName: "{{ .Values.data.persistence.storageClass }}" 251 {{- end }} 252 {{- end }} 253 resources: 254 requests: 255 storage: "{{ .Values.data.persistence.size }}" 256 {{- end }}