{{- if and .Values.nodeExporter.enabled .Values.rbac.create }}
{{- if .Values.nodeExporter.podSecurityPolicy.enabled }}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
  name: {{ template "prometheus.nodeExporter.fullname" . }}
  labels:
    {{- include "prometheus.nodeExporter.labels" . | nindent 4 }}
  namespace: {{ .Release.Namespace }}
rules:
- apiGroups: ['extensions']
  resources: ['podsecuritypolicies']
  verbs:     ['use']
  resourceNames:
  - {{ template "prometheus.nodeExporter.fullname" . }}
{{- end }}
{{- end }}
