Skip to content

Remove CABundle from CRDs if the cert is invalid #800

Closed

Description

@stefanprodan

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.

Xref:

Activity

  1. added
    area/server-side-apply
    on Aug 14, 2024
  2. dgunzy commented on Jun 25, 2025

    @dgunzy
    Contributor

    @stefanprodan - I put up a PR for this - let me know if there is a different approach to take.

  3. matheuscscp commented on Jun 25, 2025

    @matheuscscp
    Member

    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?

  4. matheuscscp commented on Jun 25, 2025

    @matheuscscp
    Member

    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.

  5. dgunzy commented on Jun 25, 2025

    @dgunzy
    Contributor

    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.

  6. matheuscscp commented on Jun 25, 2025

    @matheuscscp
    Member

    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.

  7. dgunzy commented on Jun 25, 2025

    @dgunzy
    Contributor

    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.

  8. matheuscscp commented on Jun 25, 2025

    @matheuscscp
    Member

    The vendor chart needs an update, right?

  9. dgunzy commented on Jun 25, 2025

    @dgunzy
    Contributor

    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.

  10. stefanprodan commented on Jun 26, 2025

    @stefanprodan
    MemberAuthor

    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.

  11. matheuscscp commented on Jun 26, 2025

    @matheuscscp
    Member

    Ok, Stefan made me see things clearly now 😁 I'm fine getting this in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/server-side-apply

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions