You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
get_or_create_k8s_certificate clamps maxCertificateLifetime to (caCertificateLifetime - caCertificateRetirementDuration) / 4.
That is good in general, bad when someone brings their own CA as secret operator never looks at the actual CA that is provided. It just looks at what is in the CR:
That clamps to 174d . But we have no idea what's really in the CA.
If it has 200 days left:
above 174 days remaining: works
174 down to 139: flip-flops, because jitter puts each cert somewhere in 139-174d and only some of them still fit
below 139: every mount fails
That is not great.
It only happens when autoGenerate is false, but still....
Scope
Calculate the clamp by looking at the CA in the Secret that expires last
Keep it a hard failure where no CA covers now + restartBuffer
Warning Event and/or condition on the Pod when the cert had to be shortened because of the CA's remaining lifetime?
Open question....do we do this elsewhere? Easy to do? I think it'd be good.
Note
This next bit is complicated and I'm not 100% sure it is all correct. I think it makes sense but I have a nagging feeling that something is still off. It is 100% written by hand but I'm not sure if the new steps 3 & 4 are correct to be honest. So many edge cases.
When a pod mounts a TLS volume, NodePublishVolume builds the backend for that SecretClass.
For autoTls that is TlsGenerate::get_or_create_k8s_certificate, which does, in this order:
safe_max_cert_lifetime = (caCertificateLifetime - caCertificateRetirementDuration) / 4, from the CR fields
max_cert_lifetime = min(maxCertificateLifetime, safe_max_cert_lifetime). This is the clamp.
ca::Manager::load_or_create, which reads the CA certificates from the Secret
We need to load the CAs (step 3) before computing the clamp (step 2), and additionally bound it (the max cert lifetime) by the remaining lifetime (not_after - now, minus caCertificateRetirementDuration) of the CA that expires last. This way we never create certificates that can outlive the last expiring CA.
ca::Manager::load_or_create, reads the CA certificates from the Secret
safe_max_cert_lifetime = (caCertificateLifetime - caCertificateRetirementDuration) / 4, from the CR, unchanged
ca_bound = not_after(CA that expires last) - now - caCertificateRetirementDuration, from the loaded certificates. This is new.
Do we even still need safe_max_cert_lifetime? I believe it makes sure that all Pods can still talk to each other even if some already have a new CA and others don't but 🤯
Open questions
Check the existing warnings whether they are correctly calculated and/or whether we want something new
Event or Pod condition or both? An Event per mount is noisy on a large StatefulSet, otoh we might want noisy in this case?
get_or_create_k8s_certificateclampsmaxCertificateLifetimeto(caCertificateLifetime - caCertificateRetirementDuration) / 4.That is good in general, bad when someone brings their own CA as secret operator never looks at the actual CA that is provided. It just looks at what is in the CR:
maxCertificateLifetime = (700 - 1) / 4 = 174(or 175, not sure, doesn't matter here)That clamps to 174d . But we have no idea what's really in the CA.
If it has 200 days left:
That is not great.
It only happens when
autoGenerateisfalse, but still....Scope
now + restartBufferNote
This next bit is complicated and I'm not 100% sure it is all correct. I think it makes sense but I have a nagging feeling that something is still off. It is 100% written by hand but I'm not sure if the new steps 3 & 4 are correct to be honest. So many edge cases.
When a pod mounts a TLS volume,
NodePublishVolumebuilds the backend for that SecretClass.For autoTls that is
TlsGenerate::get_or_create_k8s_certificate, which does, in this order:We need to load the CAs (step 3) before computing the clamp (step 2), and additionally bound it (the max cert lifetime) by the remaining lifetime (not_after - now, minus caCertificateRetirementDuration) of the CA that expires last. This way we never create certificates that can outlive the last expiring CA.
Note
Do we even still need
safe_max_cert_lifetime? I believe it makes sure that all Pods can still talk to each other even if some already have a new CA and others don't but 🤯Open questions
Out of scope
Expected effort
1-2 days. If it takes longer, stop and flag it.