helm-controller icon indicating copy to clipboard operation
helm-controller copied to clipboard

HelmRelease CRD OpenAPI Schema `values` property does not have a type defined

Open jknutson opened this issue 11 months ago • 3 comments

It appears that the HelmRelease CRD is missing the type: object field for the values field in the OpenAPI schema.

This does not cause issues with Flux that I have noticed, but when I create a KRO ResourceGraphDefinition, the ResourceGraphDefinition fails to sync due the values field not having a type defined.

I've confirmed that editing the CRD on my cluster resolves the issue, so I would like to make the necessary changes to the source.

actual:

...
              values:
                description: Values holds the values for this Helm release.
                x-kubernetes-preserve-unknown-fields: true
...

expected:

...
              values:
                description: Values holds the values for this Helm release.
                x-kubernetes-preserve-unknown-fields: true
                type: object
...

I did a little digging, and it seems kube-builder and/or controller-gen are used to generate the CRD.

I made the below change locally, but I am on a windows machine at the moment and have not had an opportunity to setup a local dev environment to test the change.

diff --git a/api/v2beta2/helmrelease_types.go b/api/v2beta2/helmrelease_types.go
index 89b9fef..fdc8f96 100644
--- a/api/v2beta2/helmrelease_types.go
+++ b/api/v2beta2/helmrelease_types.go
@@ -208,6 +208,7 @@ type HelmReleaseSpec struct {

        // Values holds the values for this Helm release.
        // +optional
+       // +kubebuilder:Type=string
        Values *apiextensionsv1.JSON `json:"values,omitempty"`

        // PostRenderers holds an array of Helm PostRenderers, which will be applied in order

I could be completely wrong here, but I'd love to help get this fixed so that I can avoid manually editing the CRD. Any guidance would be greatly appreciated!

jknutson avatar Feb 16 '25 16:02 jknutson

Hi @jknutson, I tried applying this git patch you showed and generate the manifests but kubebuilder doesn't generate the type field on the CRD :/

We also can't just add the field there since it goes away the next time we run make manifests.

You can patch the CRD at bootstrap time.

matheuscscp avatar Feb 18 '25 13:02 matheuscscp

I suggest asking the KRO maintainers to handle x-kubernetes-preserve-unknown-fields. This is not something specific to Flux, all controllers who have this attribute have no type specified, see cert-manager for example https://github.com/cert-manager/cert-manager/blob/7b43b7dd6711947b55eed5d2d0f4c3e5fe232b55/deploy/crds/crd-issuers.yaml#L711

stefanprodan avatar Feb 18 '25 13:02 stefanprodan

I've created an issue on the KRO repository

jknutson avatar Feb 19 '25 05:02 jknutson