{{- if and .Values.curator.enabled .Values.curator.serviceAccount.create .Values.curator.rbac.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "elasticsearch.curator.serviceAccountName" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    role: curator
{{- end }}
{{- if .Values.data.serviceAccount.create }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "elasticsearch.data.serviceAccountName" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    role: data
{{- end }}
{{- if .Values.master.serviceAccount.create }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "elasticsearch.master.serviceAccountName" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    role: master
{{- end }}
{{- if .Values.coordinating.serviceAccount.create }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "elasticsearch.coordinating.serviceAccountName" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    role: coordinating-only
{{- end }}
{{- if and .Values.ingest.enabled .Values.ingest.serviceAccount.create }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "elasticsearch.ingest.serviceAccountName" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    role: ingest
{{- end }}
