apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "manticoresearch.serviceAccountName" . }}
  labels:
    {{- include "manticoresearch.labels" . | nindent 4 }}
  {{- with .Values.serviceAccount.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ include "manticoresearch.fullname" . }}-{{ .Release.Namespace }}
rules:
  - apiGroups: [ '' ]
    resources: [ 'nodes', 'configmaps', 'pods', 'services' ]
    verbs: [ "get", "watch", "list" ]
  - apiGroups: [ 'apps' ]
    resources: [ 'deployments', 'statefulsets' ]
    verbs: [ "get", "watch", "list" ]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ include "manticoresearch.fullname" . }}-{{ .Release.Namespace }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ include "manticoresearch.fullname" . }}-{{ .Release.Namespace }}
subjects:
  - kind: ServiceAccount
    namespace: {{ .Release.Namespace }}
    name: {{ include "manticoresearch.serviceAccountName" . }}
