{{- if and .Values.serviceAccount.create .Values.rbac.create }}
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ template "master.fullname" . }}
  labels:
    app: "{{ template "mariadb.name" . }}"
    chart: "{{ template "mariadb.chart" . }}"
    release: "{{ .Release.Name | quote }}"
    heritage: "{{ .Release.Service | quote }}"
subjects:
- kind: ServiceAccount
  name: {{ template "mariadb.serviceAccountName" . }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: {{ template "master.fullname" . }}
{{- end }}
