Files
charts/bitnami/elasticsearch/templates/data-statefulset.yaml

174 lines
6.6 KiB
YAML

apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: {{ template "elasticsearch.data.fullname" . }}
labels:
app: {{ template "elasticsearch.name" . }}
chart: {{ template "elasticsearch.chart" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
role: "data"
spec:
updateStrategy:
type: {{ .Values.data.updateStrategy.type }}
{{- if (eq "Recreate" .Values.data.updateStrategy.type) }}
rollingUpdate: null
{{- else if .Values.data.updateStrategy.rollingUpdatePartition }}
rollingUpdate:
partition: {{ .Values.data.updateStrategy.rollingUpdatePartition }}
{{- end }}
selector:
matchLabels:
app: {{ template "elasticsearch.name" . }}
release: {{ .Release.Name | quote }}
role: "data"
serviceName: "{{ template "elasticsearch.data.fullname" . }}"
replicas: {{ .Values.data.replicas }}
template:
metadata:
labels:
app: {{ template "elasticsearch.name" . }}
chart: {{ template "elasticsearch.chart" . }}
release: {{ .Release.Name | quote }}
role: "data"
{{- with .Values.data.podAnnotations }}
annotations:
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- include "elasticsearch.imagePullSecrets" . | nindent 6 }}
{{- if .Values.securityContext.enabled }}
securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- end }}
affinity:
{{- if eq .Values.data.antiAffinity "hard" }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: "kubernetes.io/hostname"
labelSelector:
matchLabels:
app: {{ template "elasticsearch.name" . }}
release: {{ .Release.Name | quote }}
role: "data"
{{- else if eq .Values.data.antiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app: {{ template "elasticsearch.name" . }}
release: {{ .Release.Name | quote }}
role: "data"
{{- end }}
{{- if .Values.data.nodeAffinity }}
{{ toYaml .Values.data.nodeAffinity | indent 8 }}
{{- end }}
initContainers:
{{- if .Values.sysctlImage.enabled }}
## Image that performs the sysctl operation to modify Kernel settings (needed sometimes to avoid boot errors)
- name: sysctl
image: {{ template "elasticsearch.sysctl.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
command: ['sh', '-c', 'install_packages systemd procps && sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536']
securityContext:
privileged: true
{{- end }}
{{- if and .Values.volumePermissions.enabled .Values.data.persistence.enabled }}
- name: volume-permissions
image: "{{ template "elasticsearch.volumePermissions.image" . }}"
imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }}
command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}", "/bitnami/elasticsearch/data"]
securityContext:
runAsUser: 0
resources: {{ toYaml .Values.volumePermissions.resources | nindent 10 }}
volumeMounts:
- name: data
mountPath: "/bitnami/elasticsearch/data"
{{- end }}
containers:
- name: "elasticsearch"
image: {{ template "elasticsearch.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env:
- name: ELASTICSEARCH_CLUSTER_NAME
value: {{ .Values.name | quote }}
- name: ELASTICSEARCH_CLUSTER_HOSTS
value: {{ template "elasticsearch.discovery.fullname" . }}
{{- if .Values.plugins }}
- name: ELASTICSEARCH_PLUGINS
value: {{ .Values.plugins | quote }}
{{- end }}
- name: ELASTICSEARCH_HEAP_SIZE
value: {{ .Values.data.heapSize | quote }}
- name: ELASTICSEARCH_IS_DEDICATED_NODE
value: "yes"
- name: ELASTICSEARCH_NODE_TYPE
value: "data"
ports:
- name: transport
containerPort: 9300
{{- if .Values.data.livenessProbe.enabled }}
livenessProbe:
initialDelaySeconds: {{ .Values.data.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.data.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.data.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.data.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.data.livenessProbe.failureThreshold }}
httpGet:
path: /_cluster/health?local=true
port: 9200
{{- end }}
{{- if .Values.data.readinessProbe.enabled }}
readinessProbe:
initialDelaySeconds: {{ .Values.data.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.data.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.data.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.data.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.data.livenessProbe.failureThreshold }}
httpGet:
path: /_cluster/health?local=true
port: 9200
{{- end }}
resources:
{{ toYaml .Values.data.resources | indent 10 }}
volumeMounts:
{{- if .Values.config }}
- mountPath: /opt/bitnami/elasticsearch/config/elasticsearch.yml
name: "config"
subPath: elasticsearch.yml
{{- end }}
- name: "data"
mountPath: "/bitnami/elasticsearch/data"
volumes:
{{- if .Values.config }}
- name: "config"
configMap:
name: {{ template "elasticsearch.fullname" . }}
{{- end }}
{{- if .Values.data.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: "data"
{{- if .Values.data.persistence.annotations }}
annotations:
{{ toYaml .Values.data.persistence.annotations | indent 8 }}
{{- end }}
spec:
accessModes:
{{ toYaml .Values.data.persistence.accessModes | indent 8 }}
{{ include "elasticsearch.data.storageClass" . }}
resources:
requests:
storage: {{ .Values.data.persistence.size | quote }}
{{- else }}
- name: "data"
emptyDir: {}
{{- end }}