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
{{ message }}
Repository navigation
Remove CABundle from CRDs if the cert is invalid #800
Starting with Kubernetes 1.31, CRDs which have an invalid cert as the value of spec.conversion.webhook.clientConfig.caBundle are being rejected by the API. Since there are lots of CRDs with a dummy value for caBundle, these will fail to be reconciled even if cert-manager is configured to update the bundle to a valid one. To avoid this type of conflict, we should validate the bundle in the same way Kubernetes does it, and if the validation fails we need to remove the field from the SSA patch.
Question: Can people just remove the caBundle field with the dummy value from their manifests? Would that have an implication on cert-manager asynchronously adding the valid CA in the field?
If it's possible to just remove the field with the dummy value and cert-manager will still work, why should we go in the opposite direction of k8s? k8s decided to be more strict about this and ship this breaking change, why should we be lenient? To encourage people to keep their configuration in a state that k8s does not accept? I don't think it's worth adding this super edge case to the SSA code.
Good questions - I think there is value in removing an invalid bundle from the SSA code so that cert manager can inject a valid one. My understanding (which could be off) is that by removing the bundle we can let the CRD be applied - and then cert-manager can inject a valid bundle.
But it does raise a good point that maybe it should fail, and not be more lenient, forcing people to patch the values to something valid earlier. I did not consider that - and was just working on the issue @stefanprodan opened.
Actually I haven't tested this myself, but if we can remove the field during Flux apply, I'd be inclined to believe that users can remove the fields from their manifests, so it doesn't even reach Flux. If that's not the case (for some reason I can't imagine), then maybe we are actually fixing something serious here. But if just removing the field from YAML is enough, I'd prefer not to handle this in Flux. Flux cannot assume the existence of cert-manager, it would be like removing an optional field from a manifest just because it has an invalid value. In this specific case, people are usually running cert-manager, but from the k8s perspective an invalid CA data is just invalid. I don't think it's Flux's place to deal with a breakage in k8s.
That makes sense. I think a use case example could be a vendor helmchart that has a lot of CRDs containing invalid bundles. That still doesn't explain why flux should be more lenient than kubernetes.
100% - though some may be slow to be updated, or you may want to run an earlier version of the chart for some reason. (I am not saying this is flux's) problem necessarily.
There are tones of controllers generated with older versions of kubebuilder that set the caBundle, removing it on our side helps Flux users, this is a UX improvement.
Activity
dgunzy commentedon Jun 25, 2025
@stefanprodan - I put up a PR for this - let me know if there is a different approach to take.
matheuscscp commentedon Jun 25, 2025
Question: Can people just remove the
caBundlefield with the dummy value from their manifests? Would that have an implication on cert-manager asynchronously adding the valid CA in the field?matheuscscp commentedon Jun 25, 2025
If it's possible to just remove the field with the dummy value and cert-manager will still work, why should we go in the opposite direction of k8s? k8s decided to be more strict about this and ship this breaking change, why should we be lenient? To encourage people to keep their configuration in a state that k8s does not accept? I don't think it's worth adding this super edge case to the SSA code.
dgunzy commentedon Jun 25, 2025
Good questions - I think there is value in removing an invalid bundle from the SSA code so that cert manager can inject a valid one. My understanding (which could be off) is that by removing the bundle we can let the CRD be applied - and then cert-manager can inject a valid bundle.
But it does raise a good point that maybe it should fail, and not be more lenient, forcing people to patch the values to something valid earlier. I did not consider that - and was just working on the issue @stefanprodan opened.
matheuscscp commentedon Jun 25, 2025
Actually I haven't tested this myself, but if we can remove the field during Flux apply, I'd be inclined to believe that users can remove the fields from their manifests, so it doesn't even reach Flux. If that's not the case (for some reason I can't imagine), then maybe we are actually fixing something serious here. But if just removing the field from YAML is enough, I'd prefer not to handle this in Flux. Flux cannot assume the existence of cert-manager, it would be like removing an optional field from a manifest just because it has an invalid value. In this specific case, people are usually running cert-manager, but from the k8s perspective an invalid CA data is just invalid. I don't think it's Flux's place to deal with a breakage in k8s.
dgunzy commentedon Jun 25, 2025
That makes sense. I think a use case example could be a vendor helmchart that has a lot of CRDs containing invalid bundles. That still doesn't explain why flux should be more lenient than kubernetes.
matheuscscp commentedon Jun 25, 2025
The vendor chart needs an update, right?
dgunzy commentedon Jun 25, 2025
100% - though some may be slow to be updated, or you may want to run an earlier version of the chart for some reason. (I am not saying this is flux's) problem necessarily.
stefanprodan commentedon Jun 26, 2025
There are tones of controllers generated with older versions of kubebuilder that set the caBundle, removing it on our side helps Flux users, this is a UX improvement.
matheuscscp commentedon Jun 26, 2025
Ok, Stefan made me see things clearly now 😁 I'm fine getting this in