Skip to content

Commit

Permalink
minimize the RBAC permissions for the pull mode cluster
Browse files Browse the repository at this point in the history
Signed-off-by: zhzhuang-zju <m17799853869@163.com>
  • Loading branch information
zhzhuang-zju committed Nov 7, 2024
1 parent 0cc294f commit afd687a
Show file tree
Hide file tree
Showing 5 changed files with 524 additions and 293 deletions.
260 changes: 9 additions & 251 deletions artifacts/deploy/bootstrap-token-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,269 +86,27 @@ subjects:
name: system:nodes

---
# ClusterRole is not used for the connection between the karmada-agent and the control plane,
# but is used by karmadactl register to generate the RBAC resources required by the karmada-agent.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: system:karmada:agent
rules:
- apiGroups:
- cluster.karmada.io
resources:
- clusters
verbs:
- create
- get
- list
- watch
- delete
- apiGroups:
- cluster.karmada.io
resources:
- clusters/status
verbs:
- update
- apiGroups:
- work.karmada.io
resources:
- works
verbs:
- create
- get
- list
- watch
- update
- delete
- apiGroups:
- work.karmada.io
resources:
- works/status
verbs:
- patch
- update
- apiGroups:
- config.karmada.io
resources:
- resourceinterpreterwebhookconfigurations
- resourceinterpretercustomizations
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- create
- patch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- update
- apiGroups:
- certificates.k8s.io
resources:
- certificatesigningrequests
verbs:
- create
- get
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- update
- apiGroups: ['*']
resources: ['*']
verbs: ['*']

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:karmada:agent
name: system:karmada:agent-rbac-generator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:karmada:agent
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:nodes

# To ensure the agent has the minimal RBAC permissions, the ideal approach is to
# use different RBAC configurations for different agents of member clusters with pull mode.
# Below is the minimal set of RBAC permissions required for a single pull mode member cluster.
# Here are the definitions of the variables used:
#
# - clustername: the name of the member cluster.
# - cluster_namespace: the namespace where the member cluster secrets are stored, default to karmada-cluster.
#
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: ClusterRole
# metadata:
# name: system:karmada:agent
# rules:
# - apiGroups:
# - cluster.karmada.io
# resources:
# - clusters
# resourceNames:
# - {{clustername}}
# verbs:
# - create
# - get
# - delete
# - apiGroups:
# - cluster.karmada.io
# resources:
# - clusters
# verbs:
# - list
# - watch
# - apiGroups:
# - cluster.karmada.io
# resources:
# - clusters/status
# resourceNames:
# - {{clustername}}
# verbs:
# - update
# - apiGroups:
# - config.karmada.io
# resources:
# - resourceinterpreterwebhookconfigurations
# - resourceinterpretercustomizations
# verbs:
# - get
# - list
# - watch
# - apiGroups:
# - ""
# resources:
# - namespaces
# verbs:
# - get
# - apiGroups:
# - coordination.k8s.io
# resources:
# - leases
# verbs:
# - create
# - get
# - update
# - apiGroups:
# - certificates.k8s.io
# resources:
# - certificatesigningrequests
# verbs:
# - create
# - get
# - apiGroups:
# - ""
# resources:
# - events
# verbs:
# - create
# - patch
# - update
#
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: ClusterRoleBinding
# metadata:
# name: system:karmada:agent
# roleRef:
# apiGroup: rbac.authorization.k8s.io
# kind: ClusterRole
# name: system:karmada:agent
# subjects:
# - apiGroup: rbac.authorization.k8s.io
# kind: Group
# name: system:nodes
#
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: Role
# metadata:
# name: system:karmada:agent-secret
# namespace: "{{cluster_namespace}}"
# rules:
# - apiGroups:
# - ""
# resources:
# - secrets
# resourceNames:
# - {{clustername}}-impersonator
# - {{clustername}}
# verbs:
# - get
# - create
# - patch
#
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: RoleBinding
# metadata:
# name: system:karmada:agent-secret
# namespace: "{{cluster_namespace}}"
# roleRef:
# apiGroup: rbac.authorization.k8s.io
# kind: Role
# name: system:karmada:agent-secret
# subjects:
# - apiGroup: rbac.authorization.k8s.io
# kind: Group
# name: system:nodes
#
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: Role
# metadata:
# name: system:karmada:agent-work
# namespace: "karmada-es-{{clustername}}"
# rules:
# - apiGroups:
# - work.karmada.io
# resources:
# - works
# verbs:
# - create
# - get
# - list
# - watch
# - update
# - delete
# - apiGroups:
# - work.karmada.io
# resources:
# - works/status
# verbs:
# - patch
# - update
#
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: RoleBinding
# metadata:
# name: system:karmada:agent-work
# namespace: "karmada-es-{{clustername}}"
# roleRef:
# apiGroup: rbac.authorization.k8s.io
# kind: Role
# name: system:karmada:agent-work
# subjects:
# - apiGroup: rbac.authorization.k8s.io
# kind: Group
# name: system:nodes
- apiGroup: rbac.authorization.k8s.io
kind: User
name: system:node:agent-rbac-generator
Loading

0 comments on commit afd687a

Please sign in to comment.