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