karmada icon indicating copy to clipboard operation
karmada copied to clipboard

Proposal: Cluster Authorization

Open everpeace opened this issue 1 year ago • 15 comments

What type of PR is this?

/kind design

What this PR does / why we need it:

This PR adds a simple design proposal of Cluster Authorization which can enforce that karmada-agents runs with least privilege in control plane as much as possible

Which issue(s) this PR fixes:

Ref #https://github.com/karmada-io/karmada/issues/4485#issuecomment-1905815180

Special notes for your reviewer:

This is a rough draft. I would be glad to have your active feedbacks.

Please also refer to my working POC: #4948

Does this PR introduce a user-facing change?:


everpeace avatar Jan 29 '24 05:01 everpeace

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To complete the pull request process, please assign garrybest after the PR has been reviewed. You can assign the PR to them by writing /assign @garrybest in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

karmada-bot avatar Jan 29 '24 05:01 karmada-bot

Thanks @everpeace cc @XiShanYongYe-Chang

RainbowMango avatar Jan 29 '24 08:01 RainbowMango

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (fa4d6d3) 51.93% compared to head (8ac9628) 51.92%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4593      +/-   ##
==========================================
- Coverage   51.93%   51.92%   -0.01%     
==========================================
  Files         248      248              
  Lines       24634    24634              
==========================================
- Hits        12793    12791       -2     
- Misses      11144    11145       +1     
- Partials      697      698       +1     
Flag Coverage Δ
unittests 51.92% <ø> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jan 29 '24 08:01 codecov-commenter

It seems that it needs to rely on the integration and release of https://github.com/kubernetes-sigs/controller-runtime/pull/2664 before it can continue to advance the current proposal.

Yes, my POC branch relies on the unmerged/unreleased code of controller-runtime. So, if we can't wait for controller-runtime, could we use pkg/util/lifted temporary??

everpeace avatar Jan 31 '24 11:01 everpeace

@everpeace thanks for your quick response!

Yes, my POC branch relies on the unmerged/unreleased code of controller-runtime. So, if we can't wait for controller-runtime, could we use pkg/util/lifted temporary??

Now we don't need to rush to decide how to do it specifically. We can let everyone take a look at this proposal first.

In addition, may I ask if you are currently using or planning to use Karmada?

XiShanYongYe-Chang avatar Feb 01 '24 03:02 XiShanYongYe-Chang

@XiShanYongYe-Chang

Now we don't need to rush to decide how to do it specifically. We can let everyone take a look at this proposal first.

Sure.

In addition, may I ask if you are currently using or planning to use Karmada?

Yeah, it's still pre-POC phase actually, though. I'm looking into Karmada to sync/distribute our custom resources (for ML training jobs) into multiple kubernetes clusters across multiple clouds, multiple regions, and on-prems. Particularly, on-prem clusters are managed independently by multiple project teams (not platform teams). So, that's(on-prem part) the reason why I want make karmada-agent with the least privilege in control plane.

Moreover, from the view point of ML training platform, I would like to introduce "Bring your own cluster" model into our platform. Thus, I will open an issue to make karmada-agent works only for selected namespaces in control plane as my next step.

everpeace avatar Feb 01 '24 04:02 everpeace

my POC branch depends on the controller-runtime PR which supports authorization webhook: https://github.com/kubernetes-sigs/controller-runtime/pull/2664

Hi @everpeace Is there any progress on this mission?

XiShanYongYe-Chang avatar Mar 01 '24 06:03 XiShanYongYe-Chang

Is there any progress on this mission?

Unfortunately no... Nobody gave a review on my PR(https://github.com/kubernetes-sigs/controller-runtime/pull/2664) in a month.

I'm wondering how to promote my PR in the controller-runtime community.

everpeace avatar Mar 01 '24 13:03 everpeace

In that case, should we consider using the alternative first?

XiShanYongYe-Chang avatar Mar 04 '24 02:03 XiShanYongYe-Chang

should we consider using the alternative first?

Do you mean Generating fine-grained RBAC entries for karmada-agent? Controlling agent authorization via RBAC is not clean and easy to be buggy (because Role/ClusterRole are resource name dependent). So, in my personal view, I would not recommend this alternative, honestly.

So, if we can't wait for controller-runtime, could we use pkg/util/lifted temporary??

could we use lifted temporarily?? Authroization webhooks are already supported in kube-apiserver. The problem is only in library (controller-runtime).

everpeace avatar Mar 04 '24 02:03 everpeace

Let's listen to @RainbowMango 's opinions.

XiShanYongYe-Chang avatar Mar 04 '24 03:03 XiShanYongYe-Chang

https://github.com/kubernetes-sigs/controller-runtime/pull/2664#issuecomment-2112618194 gave dismissive feedback, unfortunately. This means, my PR would not be merged into container-runtime. So, let me to put authorization webhook implementation inside of karmada.

everpeace avatar May 15 '24 14:05 everpeace

So, let me to put authorization webhook implementation inside of karmada.

I'm not sure if this implementation is appropriate in Karmada. Originally I wanted to use the features provided by upstream directly. Let me understand. Can we consider alternatives in parallel?

XiShanYongYe-Chang avatar May 16 '24 03:05 XiShanYongYe-Chang

Originally I wanted to use the features provided by upstream directly.

Yeah, I wanted it, too. But upstream would reject hosting aurhotization webhook implementation code in controller-runtime repo😿.

Can we consider alternatives in parallel?

Sure, absolutely. Let me update my POC branch first then. But, I would like to insist to authroization webhook solution instead of generating RBACs because RBAC solution is not clean and easy to regress when agent code was updated.

everpeace avatar May 16 '24 03:05 everpeace

@XiShanYongYe-Chang I updated my poc branch and opened a WIP PR just to make our discussion easier: #4948. I will close #4948 once this proposal agreed. Please take a look.

kubernetes authorization webhook handler which depends on controller-runtime is implemented in pkg/util/authorization_webhook package. see this commit: https://github.com/karmada-io/karmada/pull/4948/commits/a009de69f2181cbd8568bb053aaaa6502b1aec03.

everpeace avatar May 16 '24 04:05 everpeace