-
Notifications
You must be signed in to change notification settings - Fork 900
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 auto certificate rotation function for karmada-agent #2596
Implement auto certificate rotation function for karmada-agent #2596
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2596 +/- ##
==========================================
+ Coverage 27.48% 29.17% +1.69%
==========================================
Files 190 190
Lines 19061 19049 -12
==========================================
+ Hits 5239 5558 +319
+ Misses 13461 13140 -321
+ Partials 361 351 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
19115dc
to
3ec282f
Compare
Deploy
When the certificate is still valid and not to threshold, it is not rotated.
When the certificate is about to expire, it will be rotated.
When the certificate is expired, the current pod will be killed and to be restarted.
The number of restarts is increased by 1. The valid period of the certificate is generally 1 year, so the number of restarts will not to increase fastly.
|
3ec282f
to
b8525d3
Compare
/assign |
Hi @lonelyCZ Would you add an agenda to the community meeting and introduce this feature to us? I'm not familiar with the certificate rotation, it'll need some time for me to go through it. |
Sure, I will demostrate it at next Tuesday meeting. |
I will update a new version today. |
b8525d3
to
e705689
Compare
I have updated it. PTAL~ /assign @RainbowMango |
Working on it now. |
cmd/agent/app/agent.go
Outdated
@@ -205,6 +206,10 @@ func run(ctx context.Context, karmadaConfig karmadactl.KarmadaConfig, opts *opti | |||
return err | |||
} | |||
|
|||
if opts.EnableCertRotation { |
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.
Maybe we don't need the option to control the controller, why don't we take this as a disabled by default controller. How do you think?
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.
It is a good idea.
e705689
to
6d6bd8a
Compare
/cc @RainbowMango |
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.
Generally looks good now.
Just a small touch.
pkg/util/secret.go
Outdated
// Fix that resourceVersion should not be set on objects to be created | ||
secret.ResourceVersion = "" | ||
|
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.
The first issue I found is the CreateOrUpdateSecret
probably does not work as expected, I mean we expect it can fallback to Update
once encountering the AlreadyExist
error during creating, but since it doesn't take the latest resource version, so the Update
would fail again.
For example, the CreateOrUpdate implemented by controller-runtime, it always deep-copy the existing object(take latest resource version) and then make changes(mutate
) before try updation.
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.
but since it doesn't take the latest resource version, so the Update would fail again.
It seems not to happen.
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.
but since it doesn't take the latest resource version, so the
Update
would fail again
Yeah, Update
will fail because of old resourceVersion. Caller shall refetch the object and retry.
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.
It seems not to happen.
After client fetch the object, other client update it. Then update will fail.
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.
That's right. I created #2687 for tracking this.
Signed-off-by: lonelyCZ <531187475@qq.com>
Signed-off-by: lonelyCZ <531187475@qq.com>
6d6bd8a
to
241f722
Compare
/cc @RainbowMango |
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.
/lgtm
/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 531187475@qq.com
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Part of #2282
Special notes for your reviewer:
Does this PR introduce a user-facing change?: