-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement karmadactl get
to support pull mode cluster
#1575
Conversation
Wow, nice!!! |
cmd/agent/app/agent.go
Outdated
// create a ClusterRole in cluster. | ||
clusterRole := &rbacv1.ClusterRole{} | ||
clusterRole.Name = names.GenerateRoleName(impersonationSA.Name) | ||
clusterRole.Rules = clusterPolicyRules | ||
if _, err = ensureClusterRoleExist(clusterKubeClient, clusterRole); err != nil { | ||
return nil, err | ||
} | ||
|
||
// create a ClusterRoleBinding in cluster. | ||
clusterRoleBinding := &rbacv1.ClusterRoleBinding{} | ||
clusterRoleBinding.Name = clusterRole.Name | ||
clusterRoleBinding.Subjects = buildRoleBindingSubjects(impersonationSA.Name, impersonationSA.Namespace) | ||
clusterRoleBinding.RoleRef = buildClusterRoleReference(clusterRole.Name) | ||
if _, err = ensureClusterRoleBindingExist(clusterKubeClient, clusterRoleBinding); err != nil { | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have create ClusterRole karmada-impersonator
and ClusterRoleBinding karmada-impersonator
for pull mode cluster, perhaps we do not need to create those rbac resource.
# kubectl --kubeconfig /root/.kube/members.config --context member3 get clusterrole | grep karmada-impersonator
karmada-impersonator 2022-04-01T08:02:54Z
# kubectl --kubeconfig /root/.kube/members.config --context member3 get clusterrolebinding | grep karmada-impersonator
karmada-impersonator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see where to create these rbac, and let me see again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XiShanYongYe-Chang I still can't find the exact location that create rbac for Pull cluster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look here: pkg/controllers/unifiedauth/unified_auth_controller.go
unified-auth-controller
will create impersonator rbac for all cluster(include pull mode).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this controller(unified-auth-controller
) need to be registered in agent
component? Or directly manipulate PULL mode clusters in karmada-controller-manager
component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unified-auth-controller
will create work
with clusterrole/clusterrolebinding
for all cluster:
karmada/pkg/controllers/unifiedauth/unified_auth_controller.go
Lines 122 to 132 in 7a1e96e
// step5: sync clusterrole to cluster for impersonation | |
if err := c.buildImpersonationClusterRole(cluster, rules); err != nil { | |
klog.Errorf("failed to sync impersonate clusterrole to cluster(%s): %v", cluster.Name, err) | |
return err | |
} | |
// step6: sync clusterrolebinding to cluster for impersonation | |
if err := c.buildImpersonationClusterRoleBinding(cluster); err != nil { | |
klog.Errorf("failed to sync impersonate clusterrolebinding to cluster(%s): %v", cluster.Name, err) | |
return err | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed it.
Signed-off-by: lonelyCZ <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job!
/lgtm
Test ok:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: lonelyCZ [email protected]
What type of PR is this?
/kind feature
What this PR does / why we need it:
Implement
karmadactl get
to support pull mode cluster through aggregated-apiserver.Which issue(s) this PR fixes:
Fixes #1091
Special notes for your reviewer:
Does this PR introduce a user-facing change?: