{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  name: {{ template "grafana.fullname" . }}
  labels:
    app: {{ template "grafana.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: {{ template "grafana.fullname" . }}
subjects:
- kind: ServiceAccount
  name: {{ template "grafana.serviceAccountName" . }}
{{- end -}}
