{{- if and .Values.prometheus.enabled .Values.rbac.create -}}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
kind: ClusterRole
metadata:
  name: {{ template "kube-prometheus.prometheus.fullname" . }}
  labels: {{- include "kube-prometheus.prometheus.labels" . | nindent 4 }}
rules:
  - apiGroups:
      - ""
    resources:
      - nodes/metrics
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - nodes
      - nodes/proxy
      - services
      - endpoints
      - pods
    verbs:
      - "get"
      - "list"
      - "watch"
  - apiGroups:
      - extensions
      - "networking.k8s.io"
    resources:
      - ingresses
    verbs:
      - get
      - list
      - watch
  - nonResourceURLs:
      - "/metrics"
    verbs:
      - "get"
{{- end }}
