apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  creationTimestamp: null
  name: {{ include "hub-net-controller-manager.fullname" . }}-role
rules:
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - create
  - get
  - list
  - update
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - create
  - get
  - list
  - update
  - watch
  - patch
- apiGroups:
  - discovery.k8s.io
  resources:
  - endpointslices
  verbs:
  - create
  - delete
  - get
  - patch
  - update
  - list
  - watch
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - endpointsliceexports
  verbs:
  - create
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - endpointsliceimports
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - internalserviceexports
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - internalserviceexports/finalizers
  verbs:
  - update
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - internalserviceexports/status
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - internalserviceimports
  verbs:
  - get
  - list
  - watch
  - update
  - patch
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - internalserviceimports/status
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - serviceimports
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - serviceimports/finalizers
  verbs:
  - update
- apiGroups:
  - networking.fleet.azure.com
  resources:
  - serviceimports/status
  verbs:
  - get
  - patch
  - update
- apiGroups:
    - cluster.kubernetes-fleet.io
  resources:
    - memberclusters
  verbs:
    - get
    - list
    - watch
{{- if .Values.enableTrafficManagerFeature }}
- apiGroups:
    - networking.fleet.azure.com
  resources:
    - trafficmanagerbackends
  verbs:
    - create
    - delete
    - get
    - list
    - patch
    - update
    - watch
- apiGroups:
    - networking.fleet.azure.com
  resources:
    - trafficmanagerbackends/finalizers
  verbs:
    - update
- apiGroups:
    - networking.fleet.azure.com
  resources:
    - trafficmanagerbackends/status
  verbs:
    - get
    - patch
    - update
- apiGroups:
    - networking.fleet.azure.com
  resources:
    - trafficmanagerprofiles
  verbs:
    - create
    - delete
    - get
    - list
    - patch
    - update
    - watch
- apiGroups:
    - networking.fleet.azure.com
  resources:
    - trafficmanagerprofiles/finalizers
  verbs:
    - update
- apiGroups:
    - networking.fleet.azure.com
  resources:
    - trafficmanagerprofiles/status
  verbs:
    - get
    - patch
    - update
{{- end }}
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ include "hub-net-controller-manager.fullname" . }}-role-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ include "hub-net-controller-manager.fullname" . }}-role
subjects:
  - kind: ServiceAccount
    name: {{ include "hub-net-controller-manager.fullname" . }}-sa
    namespace: {{ .Values.fleetSystemNamespace }}
