# Copyright Contributors to the Open Cluster Management project

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: open-cluster-management:clusterlifecycle-state-metrics
rules:
# Allow hub to manage configmap for leader selection
- apiGroups:
  - ""
  resources:
  - configmaps
  verbs:
  - create
  - update
  - get
  - delete
# Allow hub to monitor and update status of csr
- apiGroups: ["hive.openshift.io"]
  resources: ["clusterdeployments"]
  verbs: ["get"]
- apiGroups: ["cluster.open-cluster-management.io"]
  resources: ["managedclusters"]
  verbs: ["get","list","watch"]
# Allow to query the CVO on the Hub Cluster to get the ClusterId
- apiGroups: ["config.openshift.io"]
  resources: ["clusterversions"]
  verbs: ["get"]  
- apiGroups: ["authentication.k8s.io"]
  resources: ["tokenreviews"]
  verbs: ["create"]
- apiGroups: [""]
  resources: ["pods","services","endpoints"]
  verbs: ["get","list","watch"]
- apiGroups: ["authorization.k8s.io"]
  resources: ["subjectaccessreviews"]
  verbs: ["create"]
- nonResourceURLs: ["/metrics"]
  verbs: ["get"]