-
Notifications
You must be signed in to change notification settings - Fork 1.4k
✨ Add CertificateValidityPeriod and CACertificateValidityPeriod to KubeadmConfig #12335
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
/hold Added CertificateValidityPeriod to KubeadmConfig if the changes (especially conversions) are in right direction will do the similar changes for CACertificateValidityPeriod as well. @sbueringer Please let me know your opinion. Thanks. |
@@ -207,6 +207,11 @@ type ClusterConfiguration struct { | |||
// +kubebuilder:validation:MinLength=1 | |||
// +kubebuilder:validation:MaxLength=63 | |||
ClusterName string `json:"clusterName,omitempty"` | |||
|
|||
// CertificateValidityPeriod specifies the validity period for a non-CA certificate generated by kubeadm. | |||
// Default value: 8760h (365 days * 24 hours = 1 year) |
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.
Just copied the Default value from kubeadm, Should we add a logic to add default value or is it implicitly taken care by kubeadm and remove it from here?
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 question. I definitely want to document the default value here and I don't want to default directly on the API via OpenAPI defaulting or mutating webhook. So that we still know what the user set (if they set it)
I think maybe we just let kubeadm default it, but no strong opinion
@fabriziopandini WDYT?
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.
Talked to Fabrizio, I'll suggest the full godoc comments after the next review
86bbf38
to
58d06f0
Compare
58d06f0
to
ea0faae
Compare
Added both the fields, Need to make changes to honor those fields while generating CA. |
@Karthik-K-N Sorry can you rebase again? I think now we got all PRs merged for now. I'll look into the PR afterwards |
75aca66
to
29ee524
Compare
No issues, Thanks, I just rebased the PR, I have added both the fields with their conversions, I will just try to work on how to use these fields while generating certificate |
/hold cancel Ready for initial review, UT is pending |
/test pull-cluster-api-verify-main |
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.
Thank you for working on this
obj.CertificateValidityPeriod = nil | ||
|
||
if obj.CertificateValidityPeriod != nil { | ||
obj.CertificateValidityPeriod = ptr.To[metav1.Duration](metav1.Duration{Duration: time.Duration(c.Int31()) * time.Second}) |
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.
This can be changed to time.Days when we change the fields on the v1beta2 api to *Days
Please check if max of c.Int31() * time.Days is already more than max of Duration. Then we don't have to do anything here.
We only had to add this for other cases because it was possible to have a Duration which was to high to be converted to Seconds int32
obj.CertificateValidityPeriod = nil | ||
|
||
if obj.CertificateValidityPeriod != nil { | ||
obj.CertificateValidityPeriod = ptr.To[metav1.Duration](metav1.Duration{Duration: time.Duration(c.Int31()%24) * time.Hour * 24}) |
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.
Since there is no built in methods in time package to use time.Days(), I was facing round trip errors while converting hours to Days back and forth due to round off of minute field.
So added this way to always get whole hours rather than in minutes.
Please suggest if there are any better ways to handle this.
Address all the review comments, The PR is ready for next review. Thanks. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What this PR does / why we need it:
Adds CertificateValidityPeriod and CACertificateValidityPeriod to KubeadmConfig
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #12289
/area provider/bootstrap-kubeadm