{{- if and .Values.nodeExporter.enabled .Values.rbac.create }}
{{- if .Values.nodeExporter.podSecurityPolicy.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ template "prometheus.nodeExporter.fullname" . }}
  labels:
    {{- include "prometheus.nodeExporter.labels" . | nindent 4 }}
  namespace: {{ .Release.Namespace }}
roleRef:
  kind: Role
  name: {{ template "prometheus.nodeExporter.fullname" . }}
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: {{ template "prometheus.serviceAccountName.nodeExporter" . }}
  namespace: {{ .Release.Namespace }}
{{- end }}
{{- end }}
