{{- if .Values.rbac.create }}
apiVersion: {{ template "rbac.apiVersion" . }}
kind: Role
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 }}
{{- if .Values.rbac.pspEnabled }}
rules:
- apiGroups:      ['extensions']
  resources:      ['podsecuritypolicies']
  verbs:          ['use']
  resourceNames:  [{{ template "prometheus-postgres-exporter.fullname" . }}]
{{- end }}
{{- end }}
