apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: insights-operator-auth
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
roleRef:
  kind: ClusterRole
  name: system:auth-delegator
subjects:
- kind: ServiceAccount
  namespace: openshift-insights
  name: operator
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: insights-operator-auth
  namespace: kube-system
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
roleRef:
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
  namespace: openshift-insights
  name: operator
---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: insights-operator
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
rules:
# allow the operator to update cluster operator status
- apiGroups:
  - config.openshift.io
  resources:
  - clusteroperators
  resourceNames:
  - insights
  verbs:
  - get
  - watch
- apiGroups:
  - "config.openshift.io"
  resources:
  - clusteroperators
  verbs:
  - create
- apiGroups:
  - "config.openshift.io"
  resources:
  - clusteroperators/status
  resourceNames:
  - insights
  verbs:
  - get
  - update
  - patch
# allow the operator to retrieve prometheus metrics
- apiGroups:
  - ""
  resources:
  - namespaces
  verbs:
  - get

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: insights-operator
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
roleRef:
  kind: ClusterRole
  name: insights-operator
subjects:
- kind: ServiceAccount
  namespace: openshift-insights
  name: operator

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: insights-operator-gather
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
rules:
- apiGroups:
  - ""
  resources:
  - nodes
  verbs:
  - get
  - list
  - watch
- apiGroups:
    - ""
  resources:
    - events
  verbs:
    - list
- apiGroups:
    - imageregistry.operator.openshift.io
  resources:
    - configs
    - imagepruners
  verbs:
    - get
    - list
    - watch
- apiGroups:
  - ""
  resources:
  - nodes
  verbs:
  - proxy
- apiGroups:
  - ""
  resources:
  - nodes/log
  - nodes/metrics
  - nodes/proxy
  - nodes/stats
  verbs:
  - get
- apiGroups:
  - config.openshift.io
  resources:
  - "*"
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - policy
  resources:
  - poddisruptionbudgets
  verbs:
  - list
  - get
  - watch
- apiGroups:
    - machine.openshift.io
  resources:
    - machinesets
  verbs:
    - get
    - list
    - watch
- apiGroups:
    - operator.openshift.io
  resources:
    - "*"
  verbs:
    - get
    - list
    - watch
- apiGroups:
    - installers.datahub.sap.com
  resources:
    - "*"
  verbs:
    - get
    - list
    - watch 
- apiGroups:
    - operators.coreos.com
  resources:
    - "*"
  verbs:
    - get
    - list
    - watch      

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: insights-operator-gather
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
roleRef:
  kind: ClusterRole
  name: insights-operator-gather
subjects:
- kind: ServiceAccount
  namespace: openshift-insights
  name: gather

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: insights-operator-gather-reader
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
roleRef:
  kind: ClusterRole
  name: cluster-reader
subjects:
- kind: ServiceAccount
  namespace: openshift-insights
  name: gather

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: insights-operator
  namespace: openshift-config
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
rules:
- apiGroups:
  - ""
  resources:
  - secrets
  resourceNames:
  - pull-secret
  - support
  verbs:
  - get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: insights-operator
  namespace: openshift-config
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
roleRef:
  kind: Role
  name: insights-operator
subjects:
- kind: ServiceAccount
  name: operator
  namespace: openshift-insights

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: insights-operator
  namespace: openshift-insights
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
rules:
- apiGroups:
  - ""
  resources:
  - serviceaccounts
  resourceNames:
  - gather
  verbs:
  - impersonate
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: insights-operator
  namespace: openshift-insights
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/single-node-developer: "true"
roleRef:
  kind: Role
  name: insights-operator
subjects:
- kind: ServiceAccount
  name: operator
  namespace: openshift-insights
