{{- if and .Values.kubeStateMetrics.enabled .Values.rbac.create -}}
{{- if .Values.podSecurityPolicy.enabled }}
apiVersion: {{ template "rbac.apiVersion" . }}
kind: ClusterRole
metadata:
  labels:
    {{- include "prometheus.kubeStateMetrics.labels" . | nindent 4 }}
  name: psp-{{ template "prometheus.kubeStateMetrics.fullname" . }}
rules:
- apiGroups: ['extensions']
  resources: ['podsecuritypolicies']
  verbs:     ['use']
  resourceNames:
  - {{ template "prometheus.kubeStateMetrics.fullname" . }}
{{- end }}
{{- end }}
