fluxcd / helm-controller

The GitOps Toolkit Helm reconciler, for declarative Helming
https://fluxcd.io
Apache License 2.0
398 stars 157 forks source link

Backward compatibility of helm-controller #927

Closed max-allan-cgr closed 3 months ago

max-allan-cgr commented 4 months ago

Hi,

If I deploy Flux version 2beta1 and try to use the latest helm-controller, I get an error about v2beta2, which suggests to me the backward compatibility is not quite right. It could be something completely different though!

kubectl create namespace flux
helm repo add fluxcd https://fluxcd-community.github.io/helm-charts
helm upgrade -i flux fluxcd/flux2 --version v2.11.1 -n flux
kubectl -n flux edit deployment helm-controller

Replace the image with fluxcd/helm-controller:v0.37.4-helm3140 and check the logs of the new pod:

kubectl logs -n flux helm-controller-5c4c789dbc-6xbxx                   
{"level":"error","ts":"2024-03-28T12:58:17.228Z","logger":"setup","msg":"unable to create controller","controller":"HelmRelease","error":"no matches for kind \"HelmRelease\" in version \"helm.toolkit.fluxcd.io/v2beta2\""}

This could be a bug with the helm chart, but the charts work well with all components at the same API version. And I experience a similar error with cgr.dev/chainguard/flux-helm-controller:latest

{"level":"error","ts":"2024-03-28T12:52:25.218Z","logger":"setup","msg":"unable to create controller","controller":"HelmRelease","error":"failed to get API group resources: unable to retrieve the complete list of server APIs: helm.toolkit.fluxcd.io/v2beta2: the server could not find the requested resource"}

(Obviously not your image, but looks to be implemented slightly differently and getting very nearly the same error.)

In the release notes: https://github.com/fluxcd/helm-controller/blob/v0.37.0/CHANGELOG.md

It says:

The upgrade is backwards compatible, and the controller will continue to reconcile HelmRelease resources of the v2beta1 API without requiring any changes. The v2beta1 API will be removed after 6 months.

We're only about 3.5 months from 12/12/23.

souleb commented 4 months ago

It seems that the new crd is not available. Can you try kubectl api-resources --api-group=helm.toolkit.fluxcd.io

max-allan-cgr commented 4 months ago
 kubectl api-resources --api-group=helm.toolkit.fluxcd.io
NAME           SHORTNAMES   APIVERSION                       NAMESPACED   KIND
helmreleases   hr           helm.toolkit.fluxcd.io/v2beta1   true         HelmRelease

As I would expect from deploying v2beta1

souleb commented 4 months ago

The error is about the new controller installation failing because it cannot find the right crd. You can install the crd with version v1beta2 by running make install from this repo.

souleb commented 3 months ago

can we close this issue @max-allan-cgr ?

max-allan-cgr commented 3 months ago

If you think "controller will continue to reconcile HelmRelease resources of the v2beta1 API without requiring any changes" is the same as "install make, download code from github, run make to create the new version of the API" then sure, why not?

Maybe I'm misunderstanding something. Put simply: I was running code at v1 and upgraded code to v2 and v2 claims to be backwardly compatible with v1 objects. But it doesn't work without v2 objects, so isn't compatible.

stefanprodan commented 3 months ago

Kubernetes objects (aka custom resources) require a schema (aka custom resource definitions), compatibility in Kubernetes is between object versions only when the schema contains all versions. You can't update a Kubernetes controller without updating the CRDs.