---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: antrea-controller
rules:
  - apiGroups:
      - ""
    resources:
      - nodes
      - pods
      - namespaces
    verbs:
      - get
      - watch
      - list
  - apiGroups:
      - networking.k8s.io
    resources:
      - networkpolicies
    verbs:
      - get
      - watch
      - list
  - apiGroups:
      - clusterinformation.antrea.tanzu.vmware.com
    resources:
      - antreacontrollerinfos
    verbs:
      - get
      - create
      - update
      - delete
  - apiGroups:
      - clusterinformation.antrea.tanzu.vmware.com
    resources:
      - antreaagentinfos
    verbs:
      - list
      - delete
  - apiGroups:
      - authentication.k8s.io
    resources:
      - tokenreviews
    verbs:
      - create
  - apiGroups:
      - authorization.k8s.io
    resources:
      - subjectaccessreviews
    verbs:
      - create
  # This is the content of built-in role kube-system/extension-apiserver-authentication-reader.
  # But it doesn't have list/watch permission before K8s v1.17.0 so the extension apiserver (antrea-controller) will
  # have permission issue after bumping up apiserver library to a version that supports dynamic authentication.
  # See https://github.com/kubernetes/kubernetes/pull/85375
  # To support K8s clusters older than v1.17.0, we grant the required permissions directly instead of relying on
  # the extension-apiserver-authentication role.
  - apiGroups:
      - ""
    resourceNames:
      - extension-apiserver-authentication
    resources:
      - configmaps
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - configmaps
    resourceNames:
      - antrea-ca
    verbs:
      - get
      - update
  - apiGroups:
      - apiregistration.k8s.io
    resources:
      - apiservices
    resourceNames:
      - v1beta1.system.antrea.tanzu.vmware.com
      - v1beta1.networking.antrea.tanzu.vmware.com
    verbs:
      - get
      - update
  - apiGroups:
      - security.antrea.tanzu.vmware.com
    resources:
      - clusternetworkpolicies
      - networkpolicies
    verbs:
      - get
      - watch
      - list
  - apiGroups:
      - ops.antrea.tanzu.vmware.com
    resources:
      - traceflows
    verbs:
      - get
      - watch
      - list
      - update
      - patch
  - apiGroups:
      - core.antrea.tanzu.vmware.com
    resources:
      - externalentities
    verbs:
      - get
      - watch
      - list
