---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: cloud-controller-manager
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: system:cloud-controller-manager
rules:
- apiGroups:
  - ""
  resources:
  - nodes
  verbs:
  - '*'

- apiGroups:
  - ""
  resources:
  - nodes/status
  verbs:
  - patch

- apiGroups:
  - ""
  resources:
  - services
  verbs:
  - list
  - watch
  - patch

- apiGroups:
  - ""
  resources:
  - services/status
  verbs:
  - update

- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - create
  - patch
  - update

# For leader election
- apiGroups:
  - ""
  resources:
  - endpoints
  verbs:
  - create

- apiGroups:
  - ""
  resources:
  - endpoints
  resourceNames:
  - "cloud-controller-manager"
  verbs:
  - get
  - list
  - watch
  - update

- apiGroups:
  - ""
  resources:
  - configmaps
  verbs:
  - create

- apiGroups:
  - ""
  resources:
  - configmaps
  resourceNames:
  - "cloud-controller-manager"
  verbs:
  - get
  - update

- apiGroups:
  - ""
  resources:
  - serviceaccounts
  verbs:
  - create
- apiGroups:
  - ""
  resources:
  - secrets
  verbs:
  - get
  - list

# For the PVL
- apiGroups:
  - ""
  resources:
  - persistentvolumes
  verbs:
  - list
  - watch
  - patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: oci-cloud-controller-manager
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:cloud-controller-manager
subjects:
- kind: ServiceAccount
  name: cloud-controller-manager
  namespace: kube-system
