{{- if .Values.services.projector.enabled }}
# Cluster-wide read on the kinds the projector cold-LISTS at startup.
# Mirrors lister.DefaultKinds — one rule per logical group so future
# additions are obvious.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ include "projector.fullname" . }}
  labels:
    {{- include "projector.labels" (dict "root" .) | nindent 4 }}
rules:
  - apiGroups: [""]
    resources: ["pods", "services", "configmaps", "secrets", "namespaces", "nodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apps"]
    resources: ["deployments", "statefulsets"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ include "projector.fullname" . }}
  labels:
    {{- include "projector.labels" (dict "root" .) | nindent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ include "projector.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ include "projector.fullname" . }}
    namespace: {{ .Release.Namespace }}
{{- end }}
