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

Should we increase the default certificate duration to 18 months? #8620

Closed
vincepri opened this issue May 8, 2023 · 15 comments
Closed

Should we increase the default certificate duration to 18 months? #8620

vincepri opened this issue May 8, 2023 · 15 comments
Labels
triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@vincepri
Copy link
Member

vincepri commented May 8, 2023

We currently create cluster certificate that last 1 year, with the current upstream efforts to increase the support skew kubernetes/enhancements#3936, should we change the default certificate duration to allow more time for folks to upgrade their nodes?

DefaultCertDuration = time.Hour * 24 * 365

@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If CAPI contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label May 8, 2023
@sbueringer
Copy link
Member

sbueringer commented May 9, 2023

If I see correctly this duration is only used by KCP to generate the kubeconfig secret. Today we generate it with 1 year expiry and then regenerate it after 6 months.

I'm not sure how this is related with the support skew KEP.

If I understand your intent correctly we should probably open this issue for kubeadm instead so the hard-coded 1 year expiry that kubeadm uses (and we just inherit) is extended. This would give us a longer expiry of the certificates on machines and thus we can keep them around for longer.

@fabriziopandini
Copy link
Member

/triage accepted

Agree with @sbueringer, just adding that with automatic certificate rotation recently implemented also kubeadm expiration is not a big problem anymore

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 9, 2023
@sbueringer
Copy link
Member

sbueringer commented May 9, 2023

Adding on top of that. With the current default setup (core CAPI + KCP + CABPK) we only rotate control plane machines. Worker machines don't have to be rotated as they use a self-signed server certificate that is never validated (client certificate is rotated automatically).

As the skew KEP would allow us to only keep worker nodes longer extending the expiry in kubeadm is not necessary.

@neolit123
Copy link
Member

note that if this is an RSA cert paired with a 2048 key, expiration > 1 year would need a bigger key. e.g. 3072.

see
https://kubernetes.slack.com/archives/C019LFTGNQ3/p1683275607359709?thread_ts=1683235193.545829&cid=C019LFTGNQ3


off topic

cert serials must be in the 1,max range

serial, err := rand.Int(rand.Reader, new(big.Int).SetInt64(math.MaxInt64))

see
kubernetes/kubernetes#117791

@fabriziopandini
Copy link
Member

I'm leaning towards closing here, giving that cert duration is driven by kubeadm and in CAPI we now have automatic certificate renewal

@fabriziopandini
Copy link
Member

@sbueringer @vincepri
opinions
(if not, we should probably move the issue to kubeadm)

@sbueringer
Copy link
Member

sbueringer commented Jan 22, 2024

Agree, if there is still interest in seeing this implemented we need a change in kubeadm first (and thus we need an issue over there)

@Levi080513
Copy link
Contributor

Can we support configuration of DefaultCertDuration?
Users may use the kubeconfig generated by CAPI as the basis for the upper-layer management system to access the workload cluster. The current default validity period seems a bit short.

@sbueringer
Copy link
Member

I think the scope of this issue is the certificates on the Machines, not the kubeconfig we generate.
(otherwise "should we change the default certificate duration to allow more time for folks to upgrade their nodes?" wouldn't make sense)

@fabriziopandini
Copy link
Member

Users may use the kubeconfig generated by CAPI as the basis for the upper-layer management system to access the workload cluster.

I would advise avoiding to re-use the kubeconfig generated by CAPI for other services (or for users).
Instead, you should create a new certificate, with a dedicated identity, and scope it down it permission to what is strictly required.

@Levi080513
Copy link
Contributor

I think the scope of this issue is the certificates on the Machines, not the kubeconfig we generate. (otherwise "should we change the default certificate duration to allow more time for folks to upgrade their nodes?" wouldn't make sense)

Yes, sorry for responding to other questions.

@Levi080513
Copy link
Contributor

Users may use the kubeconfig generated by CAPI as the basis for the upper-layer management system to access the workload cluster.

I would advise avoiding to re-use the kubeconfig generated by CAPI for other services (or for users). Instead, you should create a new certificate, with a dedicated identity, and scope it down it permission to what is strictly required.

Thanks for the reply, this is very helpful to me.

@fabriziopandini
Copy link
Member

/close

because:

  • changing cert duration requires changes in kubeadm first, starting by increasing key length
  • we answered to question about the cert in the generated kubeconfig file

@k8s-ci-robot
Copy link
Contributor

@fabriziopandini: Closing this issue.

In response to this:

/close

because:

  • changing cert duration requires changes in kubeadm first, starting by increasing key length
  • we answered to question about the cert in the generated kubeconfig file

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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

6 participants