Skip to content

Commit 2c82055

Browse files
authored
Merge pull request #5793 from zhzhuang-zju/register
minimize the RBAC permissions for the pull mode cluster
2 parents f6056f5 + af90640 commit 2c82055

File tree

11 files changed

+722
-496
lines changed

11 files changed

+722
-496
lines changed

artifacts/deploy/bootstrap-token-configuration.yaml

+60-256
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ data:
1313
kind: Config
1414
1515
---
16+
# Define a role with permission to get the cluster-info configmap
1617
apiVersion: rbac.authorization.k8s.io/v1
1718
kind: Role
1819
metadata:
@@ -31,6 +32,8 @@ rules:
3132
- get
3233

3334
---
35+
# An anonymous user can get `cluster-info` configmap, which is used to obtain the control plane API server's server
36+
# address and `certificate-authority-data` during the `karmadactl register` process.
3437
apiVersion: rbac.authorization.k8s.io/v1
3538
kind: RoleBinding
3639
metadata:
@@ -48,6 +51,8 @@ subjects:
4851
name: system:anonymous
4952

5053
---
54+
# Group `system:bootstrappers:karmada:default-cluster-token` is the user group of the bootstrap token
55+
# used by `karmadactl register` when registering a new pull mode cluster.
5156
apiVersion: rbac.authorization.k8s.io/v1
5257
kind: ClusterRoleBinding
5358
metadata:
@@ -64,6 +69,26 @@ subjects:
6469
name: system:bootstrappers:karmada:default-cluster-token
6570

6671
---
72+
# Define a ClusterRole with permissions to automatically approve the agent CSRs when the agentcsrapproving controller is enabled by karmada-controller-manager.
73+
apiVersion: rbac.authorization.k8s.io/v1
74+
kind: ClusterRole
75+
metadata:
76+
labels:
77+
karmada.io/bootstrapping: rbac-defaults
78+
name: system:karmada:certificatesigningrequest:autoapprover
79+
rules:
80+
- apiGroups:
81+
- certificates.k8s.io
82+
resources:
83+
- certificatesigningrequests/clusteragent
84+
verbs:
85+
- create
86+
87+
---
88+
# Group `system:bootstrappers:karmada:default-cluster-token` is the user group of the bootstrap token
89+
# used by `karmadactl register` when registering a new pull mode cluster.
90+
# When the `agentcsrapproving` controller is enabled by the karmada-controller-manager,
91+
# it can automatically approve the agent CSRs requested by the user group system:bootstrappers:karmada:default-cluster-token.
6792
apiVersion: rbac.authorization.k8s.io/v1
6893
kind: ClusterRoleBinding
6994
metadata:
@@ -73,13 +98,33 @@ metadata:
7398
roleRef:
7499
apiGroup: rbac.authorization.k8s.io
75100
kind: ClusterRole
76-
name: system:certificates.k8s.io:certificatesigningrequests:nodeclient
101+
name: system:karmada:certificatesigningrequest:autoapprover
77102
subjects:
78103
- apiGroup: rbac.authorization.k8s.io
79104
kind: Group
80105
name: system:bootstrappers:karmada:default-cluster-token
81106

82107
---
108+
# Define a ClusterRole with permissions to automatically approve the agent CSRs
109+
# where the user name and group of requester match those in the CSRs when the agentcsrapproving controller is enabled by karmada-controller-manager.
110+
apiVersion: rbac.authorization.k8s.io/v1
111+
kind: ClusterRole
112+
metadata:
113+
labels:
114+
karmada.io/bootstrapping: rbac-defaults
115+
name: system:karmada:certificatesigningrequest:selfautoapprover
116+
rules:
117+
- apiGroups:
118+
- certificates.k8s.io
119+
resources:
120+
- certificatesigningrequests/selfclusteragent
121+
verbs:
122+
- create
123+
124+
---
125+
# Group `system:karmada:agents` is the user group used by the karmada-agent to access the Karmada API server.
126+
# When the agentcsrapproving controller is enabled by the karmada-controller-manager, it can automatically approve
127+
# the agent CSRs(csr.Subject.CommonName = agent username) requested by the user group system:karmada:agents.
83128
apiVersion: rbac.authorization.k8s.io/v1
84129
kind: ClusterRoleBinding
85130
metadata:
@@ -89,280 +134,39 @@ metadata:
89134
roleRef:
90135
apiGroup: rbac.authorization.k8s.io
91136
kind: ClusterRole
92-
name: system:certificates.k8s.io:certificatesigningrequests:selfnodeclient
137+
name: system:karmada:certificatesigningrequest:selfautoapprover
93138
subjects:
94139
- apiGroup: rbac.authorization.k8s.io
95140
kind: Group
96-
name: system:nodes
141+
name: system:karmada:agents
97142

98143
---
144+
# ClusterRole `system:karmada:agent-rbac-generator` is not used for the connection between the karmada-agent and the control plane,
145+
# but is used by karmadactl register to generate the RBAC resources required by the karmada-agent.
99146
apiVersion: rbac.authorization.k8s.io/v1
100147
kind: ClusterRole
101148
metadata:
102149
labels:
103150
karmada.io/bootstrapping: rbac-defaults
104-
name: system:karmada:agent
151+
name: system:karmada:agent-rbac-generator
105152
rules:
106-
- apiGroups:
107-
- cluster.karmada.io
108-
resources:
109-
- clusters
110-
verbs:
111-
- create
112-
- get
113-
- list
114-
- watch
115-
- delete
116-
- apiGroups:
117-
- cluster.karmada.io
118-
resources:
119-
- clusters/status
120-
verbs:
121-
- update
122-
- apiGroups:
123-
- work.karmada.io
124-
resources:
125-
- works
126-
verbs:
127-
- create
128-
- get
129-
- list
130-
- watch
131-
- update
132-
- delete
133-
- apiGroups:
134-
- work.karmada.io
135-
resources:
136-
- works/status
137-
verbs:
138-
- patch
139-
- update
140-
- apiGroups:
141-
- config.karmada.io
142-
resources:
143-
- resourceinterpreterwebhookconfigurations
144-
- resourceinterpretercustomizations
145-
verbs:
146-
- get
147-
- list
148-
- watch
149-
- apiGroups:
150-
- ""
151-
resources:
152-
- namespaces
153-
verbs:
154-
- get
155-
- apiGroups:
156-
- ""
157-
resources:
158-
- secrets
159-
verbs:
160-
- get
161-
- create
162-
- patch
163-
- apiGroups:
164-
- coordination.k8s.io
165-
resources:
166-
- leases
167-
verbs:
168-
- create
169-
- get
170-
- update
171-
- apiGroups:
172-
- certificates.k8s.io
173-
resources:
174-
- certificatesigningrequests
175-
verbs:
176-
- create
177-
- get
178-
- apiGroups:
179-
- ""
180-
resources:
181-
- events
182-
verbs:
183-
- create
184-
- patch
185-
- update
153+
- apiGroups: ['*']
154+
resources: ['*']
155+
verbs: ['*']
186156

187157
---
158+
# User `system:karmada:agent:rbac-generator` is specifically used during the `karmadactl register` process to generate restricted RBAC resources for the `karmada-agent`.
188159
apiVersion: rbac.authorization.k8s.io/v1
189160
kind: ClusterRoleBinding
190161
metadata:
191162
labels:
192163
karmada.io/bootstrapping: rbac-defaults
193-
name: system:karmada:agent
164+
name: system:karmada:agent-rbac-generator
194165
roleRef:
195166
apiGroup: rbac.authorization.k8s.io
196167
kind: ClusterRole
197-
name: system:karmada:agent
168+
name: system:karmada:agent-rbac-generator
198169
subjects:
199-
- apiGroup: rbac.authorization.k8s.io
200-
kind: Group
201-
name: system:nodes
202-
203-
# To ensure the agent has the minimal RBAC permissions, the ideal approach is to
204-
# use different RBAC configurations for different agents of member clusters with pull mode.
205-
# Below is the minimal set of RBAC permissions required for a single pull mode member cluster.
206-
# Here are the definitions of the variables used:
207-
#
208-
# - clustername: the name of the member cluster.
209-
# - cluster_namespace: the namespace where the member cluster secrets are stored, default to karmada-cluster.
210-
#
211-
# ---
212-
# apiVersion: rbac.authorization.k8s.io/v1
213-
# kind: ClusterRole
214-
# metadata:
215-
# name: system:karmada:agent
216-
# rules:
217-
# - apiGroups:
218-
# - cluster.karmada.io
219-
# resources:
220-
# - clusters
221-
# resourceNames:
222-
# - {{clustername}}
223-
# verbs:
224-
# - create
225-
# - get
226-
# - delete
227-
# - apiGroups:
228-
# - cluster.karmada.io
229-
# resources:
230-
# - clusters
231-
# verbs:
232-
# - list
233-
# - watch
234-
# - apiGroups:
235-
# - cluster.karmada.io
236-
# resources:
237-
# - clusters/status
238-
# resourceNames:
239-
# - {{clustername}}
240-
# verbs:
241-
# - update
242-
# - apiGroups:
243-
# - config.karmada.io
244-
# resources:
245-
# - resourceinterpreterwebhookconfigurations
246-
# - resourceinterpretercustomizations
247-
# verbs:
248-
# - get
249-
# - list
250-
# - watch
251-
# - apiGroups:
252-
# - ""
253-
# resources:
254-
# - namespaces
255-
# verbs:
256-
# - get
257-
# - apiGroups:
258-
# - coordination.k8s.io
259-
# resources:
260-
# - leases
261-
# verbs:
262-
# - create
263-
# - get
264-
# - update
265-
# - apiGroups:
266-
# - certificates.k8s.io
267-
# resources:
268-
# - certificatesigningrequests
269-
# verbs:
270-
# - create
271-
# - get
272-
# - apiGroups:
273-
# - ""
274-
# resources:
275-
# - events
276-
# verbs:
277-
# - create
278-
# - patch
279-
# - update
280-
#
281-
# ---
282-
# apiVersion: rbac.authorization.k8s.io/v1
283-
# kind: ClusterRoleBinding
284-
# metadata:
285-
# name: system:karmada:agent
286-
# roleRef:
287-
# apiGroup: rbac.authorization.k8s.io
288-
# kind: ClusterRole
289-
# name: system:karmada:agent
290-
# subjects:
291-
# - apiGroup: rbac.authorization.k8s.io
292-
# kind: Group
293-
# name: system:nodes
294-
#
295-
# ---
296-
# apiVersion: rbac.authorization.k8s.io/v1
297-
# kind: Role
298-
# metadata:
299-
# name: system:karmada:agent-secret
300-
# namespace: "{{cluster_namespace}}"
301-
# rules:
302-
# - apiGroups:
303-
# - ""
304-
# resources:
305-
# - secrets
306-
# resourceNames:
307-
# - {{clustername}}-impersonator
308-
# - {{clustername}}
309-
# verbs:
310-
# - get
311-
# - create
312-
# - patch
313-
#
314-
# ---
315-
# apiVersion: rbac.authorization.k8s.io/v1
316-
# kind: RoleBinding
317-
# metadata:
318-
# name: system:karmada:agent-secret
319-
# namespace: "{{cluster_namespace}}"
320-
# roleRef:
321-
# apiGroup: rbac.authorization.k8s.io
322-
# kind: Role
323-
# name: system:karmada:agent-secret
324-
# subjects:
325-
# - apiGroup: rbac.authorization.k8s.io
326-
# kind: Group
327-
# name: system:nodes
328-
#
329-
# ---
330-
# apiVersion: rbac.authorization.k8s.io/v1
331-
# kind: Role
332-
# metadata:
333-
# name: system:karmada:agent-work
334-
# namespace: "karmada-es-{{clustername}}"
335-
# rules:
336-
# - apiGroups:
337-
# - work.karmada.io
338-
# resources:
339-
# - works
340-
# verbs:
341-
# - create
342-
# - get
343-
# - list
344-
# - watch
345-
# - update
346-
# - delete
347-
# - apiGroups:
348-
# - work.karmada.io
349-
# resources:
350-
# - works/status
351-
# verbs:
352-
# - patch
353-
# - update
354-
#
355-
# ---
356-
# apiVersion: rbac.authorization.k8s.io/v1
357-
# kind: RoleBinding
358-
# metadata:
359-
# name: system:karmada:agent-work
360-
# namespace: "karmada-es-{{clustername}}"
361-
# roleRef:
362-
# apiGroup: rbac.authorization.k8s.io
363-
# kind: Role
364-
# name: system:karmada:agent-work
365-
# subjects:
366-
# - apiGroup: rbac.authorization.k8s.io
367-
# kind: Group
368-
# name: system:nodes
170+
- apiGroup: rbac.authorization.k8s.io
171+
kind: User
172+
name: system:karmada:agent:rbac-generator

0 commit comments

Comments
 (0)