Skip to content
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

propagate Secret of type kubernetes.io/service-account-token #4766

Merged

Conversation

a7i
Copy link
Contributor

@a7i a7i commented Mar 28, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:
Prior to kubernetes 1.24, Kubernetes controller-manager automatically created a Secret (with a long-lived token). Starting with 1.24, in order to create a Secret with long-lived token, you have to manually create a Secret and link it to the Service Account. Karmada currently doesn't support propagating this Secret as it is explicitly disabled.

Which issue(s) this PR fixes:
Fixes #4752

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Yes

karmada-controller-manager: propagate `Secret` of type `kubernetes.io/service-account-token`

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 28, 2024
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 28, 2024
@a7i a7i force-pushed the propagate-service-account-token-secrets branch 2 times, most recently from 8a696f2 to ae9f508 Compare March 28, 2024 03:53
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 35.00000% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 51.79%. Comparing base (ff7322a) to head (ae9f508).

Files Patch % Lines
pkg/resourceinterpreter/default/native/retain.go 35.00% 9 Missing and 4 partials ⚠️

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4766   +/-   ##
=======================================
  Coverage   51.79%   51.79%           
=======================================
  Files         250      250           
  Lines       24991    25004   +13     
=======================================
+ Hits        12945    12952    +7     
- Misses      11337    11339    +2     
- Partials      709      713    +4     
Flag Coverage Δ
unittests 51.79% <35.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, you provided a new perspective.

However, this comment #4752 (comment) also reminded me that is your change backward compatible with k8s versions below v1.24?

Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@XiShanYongYe-Chang
Copy link
Member

You can add the component name karmada-controller-manager to the release-note.

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retain logic is modified in the current PR. However, retain is used when resources in member clusters are updated. If resources are created, will the UID and token information in the secret on the control plane be carried to the member cluster?

@XiShanYongYe-Chang
Copy link
Member

The retain logic is modified in the current PR. However, retain is used when resources in member clusters are updated. If resources are created, will the UID and token information in the secret on the control plane be carried to the member cluster?

Kindly ping @a7i

@a7i
Copy link
Contributor Author

a7i commented Apr 8, 2024

@XiShanYongYe-Chang Yes it will but we observed in our case that the member cluster kube-controller-manager will fix up the values and get ignored by karmada on update.

Is there a "global" level ignore for CREATE as well?

@XiShanYongYe-Chang
Copy link
Member

Maybe we can do it in the karmada-webhook:

err = prune.RemoveIrrelevantField(workloadObj, prune.RemoveJobTTLSeconds)

@a7i
Copy link
Contributor Author

a7i commented Apr 9, 2024

@XiShanYongYe-Chang done, I kept as two separate commits for easier review. Happy to rebase and squash if needed.

@XiShanYongYe-Chang
Copy link
Member

It occurs a lint error:

pkg/resourceinterpreter/default/native/prune/prune.go:33:1: cyclomatic complexity 18 of func `RemoveIrrelevantField` is high (> 15) (gocyclo)

@a7i
Copy link
Contributor Author

a7i commented Apr 9, 2024

@XiShanYongYe-Chang let me take a stab at refactoring this function in a separate PR and I'll come back to this after that's reviewed/merged

@XiShanYongYe-Chang
Copy link
Member

Hi @a7i, CI errors may prevent PRs from being merged.

@a7i
Copy link
Contributor Author

a7i commented Apr 9, 2024

Hi @a7i, CI errors may prevent PRs from being merged.

I understand, hence why I'm suggesting to put a hold on this PR, until we refactor this function first (in a separate PR).

@XiShanYongYe-Chang
Copy link
Member

I understand, hence why I'm suggesting to put a hold on this PR, until we refactor this function first (in a separate PR).

Thanks @a7i, I got it :)

@XiShanYongYe-Chang
Copy link
Member

Hi @a7i , now we can go on this PR.

@a7i a7i force-pushed the propagate-service-account-token-secrets branch 2 times, most recently from a56a8d9 to 81ff0aa Compare April 10, 2024 15:24
Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice~

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 11, 2024
@@ -101,10 +102,77 @@ func Test_retainK8sWorkloadReplicas(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
got, err := retainWorkloadReplicas(tt.args.desired, tt.args.observed)
if (err != nil) != tt.wantErr {
t.Errorf("reflectPodDisruptionBudgetStatus() error = %v, wantErr %v", err, tt.wantErr)
t.Errorf("retainWorkloadReplicas() error = %v, wantErr %v", err, tt.wantErr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch. thanks.

@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 11, 2024
@RainbowMango
Copy link
Member

LGTM
Thanks for your quick response!

But would you mind squash commits?

@a7i
Copy link
Contributor Author

a7i commented Apr 11, 2024

LGTM Thanks for your quick response!

But would you mind squash commits?

I do not mind at all! Was keeping them separate for easier review

@a7i a7i force-pushed the propagate-service-account-token-secrets branch from a12498f to 7dbfc9f Compare April 11, 2024 13:45
@RainbowMango
Copy link
Member

haha, your code is so clear that I don't have to review it by commits~

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 11, 2024
@karmada-bot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2024
@RainbowMango
Copy link
Member

gonna heading home now, good morning to you

@a7i
Copy link
Contributor Author

a7i commented Apr 11, 2024

gonna heading home now, good morning to you

long day! I appreciate the thorough review and all the great feedback 🎉

@RainbowMango
Copy link
Member

I really really hope people like you join us in maintaining this project, can we get started from the org membership?

@karmada-bot karmada-bot merged commit da7689f into karmada-io:master Apr 11, 2024
12 checks passed
@a7i a7i deleted the propagate-service-account-token-secrets branch April 11, 2024 17:19
@a7i
Copy link
Contributor Author

a7i commented Apr 19, 2024

Hi @RainbowMango and @XiShanYongYe-Chang I hope you would consider sponsoring me ❤️

karmada-io/community#68

@a7i
Copy link
Contributor Author

a7i commented Apr 19, 2024

I have verified that my sponsors are from different member companies

perhaps @chaunceyjiang would consider 🙇🏼

@RainbowMango
Copy link
Member

Hi @RainbowMango and @XiShanYongYe-Chang I hope you would consider sponsoring me ❤️

definitly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propagate Service Account Token Secret
6 participants