{{/*
krply-server is a query API, materializer, and replay planner: it reads the
SQLite journal and, only when a replay is run, resolves the target cluster
through its own in-cluster configuration. It performs no listing or watching,
so its ServiceAccount needs no ClusterRole.

When you co-locate a `krply record` agent in this chart, bind the agent's
ServiceAccount to deploy/rbac/recorder-clusterrole.yaml instead; that role is
read-only get/list/watch on the MVP resources with no Secrets access.
*/}}
{{- if .Values.rbac.recorder.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ include "krply.fullname" . }}-recorder
  labels:
    {{- include "krply.labels" . | nindent 4 }}
rules:
  - apiGroups: [""]
    resources: ["namespaces", "configmaps", "services", "pods"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apps"]
    resources: ["deployments", "statefulsets", "daemonsets"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["node.k8s.io"]
    resources: ["runtimeclasses"]
    verbs: ["get", "list", "watch"]
{{- end }}
