apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kruise-state-metrics-role
rules:
  - apiGroups:
      - apps.kruise.io
    resources:
      - '*'
    verbs:
      - get
      - list
      - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kruise-state-metrics-rolebinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kruise-state-metrics-role
subjects:
  - kind: ServiceAccount
    name: {{ include "kruise-state-metrics.serviceAccountName" . }}
    namespace: {{ .Values.installation.namespace }}
---
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "kruise-state-metrics.serviceAccountName" . }}
  namespace: {{ .Values.installation.namespace }}
  labels:
    {{- include "kruise-state-metrics.labels" . | nindent 4 }}
  {{- with .Values.serviceAccount.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
{{- end }}
