-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
certificate expired and rotate #1621
Comments
Hi |
Certificates rotate automatically if they are <90 days from expiration when k3s is started. This has been the case since v0.10: #805 As long as you are patching and restarting your k3s infrastructure at least every couple months, you shouldn't run into expired certificates. |
@brandond |
Yes. Make sure you're running at least 0.10, and restart k3s. If the certs are less than 90 days from expiration they will be rotated when it starts. I don't believe there's a way to manually rotate them or make them valid for longer... other than poking at the files manually with a 3rd party tool like openssl of course. You're restarting your k3s nodes at least every couple months to apply OS patches, right? |
@brandond |
Since the question has been answered, maybe the issue can be closed. cc @liyongxian . |
Closing the issue. If there are further questions let us know and we can reopen if necessary. |
Hi @brandond , I did a test on VM, modify system time to the day before expired time ( < 90 days) and restart k3s, then checking cert info by using openssl command as following, found the cert has no change.
I tried reset the time several times even clean up the certs in
Could you please advise if there is any misunderstanding? Version: v1.17.5+k3s1 Thanks, |
@ethinx did you set the time into the future, start k3s, and then set it back again? According to the error, your cert was generated almost two years in the future and is not yet valid:
|
@brandond since I tried to clean up the certs under Make it simpler, I did a fresh install and test again as following, do I miss something here?
|
@ethinx Don't set the time forward while it's running. If you're going to test it that way, stop k3s before changing the system time. Also, make sure you've disabled any time sync daemons - ntpd, chrony, systemd-timesyncd, etc. |
Hi @brandond, It seems that not about the time sync daemons, even though I stop chronyd (I didn't notice it before), cert keep unchanged after I stop k3s -> set time to future -> start k3s. I think I find where the cert be cached, it's the The cert get updated after I remove the secret and local cache file Just have a glance on the code, seems that the local file certificate generation is different to the secret. Hope you could share more about it, as we don't have documents about this. |
I think you might be correct. @galal-hussein @erikwilson it looks like the kube-apiserver, kubelet, and auth-proxy certs all call through |
Reopening the issue based on comments it seems like we may want to investigate this further. |
Hi there, Following the Rancher 2.X installation instructions for Rancher on K3s, in this document: https://rancher.com/docs/rancher/v2.x/en/installation/k8s-install/kubernetes-rke/, we get to copying the kubectl config to a local machine to try to connect and we receive the following error: Unable to connect to the server: x509: certificate has expired or is not yet valid: current time 2020-06-24T14:40:08-05:00 is after 2017-10-24T21:09:52Z Any thoughts? Thanks! |
@ieugen please close it.I did it by changing k3s code and rebuild it. Thanks. |
@liyongxian I can't close it since I did not start the thread. |
Certificates are rotated if they are < 90 days from expiration.
Before expiration:
Update date
Confirm certs are rotated
|
Further testing: If the system date is set to after exipiration date, rotation works but certificate are not updated. Since the certificates being rotated by default within <90 of expiration should solve the issue. Suppose the expiration date is
and set the date to < 90 days to expire.
Certs are rotated and updated
Suppose date is set to after expire
Certificates are rotated but not updated
|
Refreshing the cert should force reissuance as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force reissuance as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force reissuance as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force reissuance as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force reissuance as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force reissuance as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force reissuance as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Second round of fixes for k3s-io#1621 Signed-off-by: Brad Davidson <[email protected]>
Second round of fixes for k3s-io#1621 Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force renewal as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force renewal as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Refreshing the cert should force renewal as opposed to returning early if the SANs aren't changing. This is currently breaking refresh of expired certs as per: k3s-io/k3s#1621 (comment) Signed-off-by: Brad Davidson <[email protected]>
Second round of fixes for k3s-io#1621 Signed-off-by: Brad Davidson <[email protected]>
Second round of fixes for k3s-io#1621 Signed-off-by: Brad Davidson <[email protected]>
Verified using K3s commit a2471a1. k3s-serving cert rotation succeeded.
Certs are rotated when date is manually set to <90 to expiration
|
same issue here.
|
similar issue here |
Anyone experiencing this issue should create a new issue and fill out the issue template with all the relevant information. Adding me-too comments on a closed issue makes it very difficult to track whether you're experiencing a regression, or are perhaps just not using a release where this is fixed. |
Hi
By default,k3s components' certificates is 1 year,those components include:kube-apiserver,scheduler,cloud-controller,K3s should rotate those certificates.
K3s version: v1.17.4+k3s1
A clear and concise description of what you want to happen.
The components' certificates expire,k3s will not work.
Thanks.
The text was updated successfully, but these errors were encountered: