open-feature / open-feature-operator

A Kubernetes feature flag operator
https://openfeature.dev
Apache License 2.0
164 stars 33 forks source link

Helm Chart: generate CRD templates in the CRDs folder to allow `--skip-crds` to skip CRDs #624

Closed estenrye closed 2 months ago

estenrye commented 2 months ago

Problem

I want to manage the Open-Feature-Operator CRDs separately because Terraform is dumb and needs the CRDs to be deployed on the cluster as an api resource before I can create Feature Flag manifests in a separate terraform project.

The 0.5.4 helm chart generates the CRD templates outside of the conventional crds folder in the chart. Because of this, helm install with the --skip-crds flag cannot omit the CRDs when deploying.

I am currently using the helm_release terraform resource to deploy the helm chart. I have a separate terraform project that deploys the CRDs. I get the following error because helm template does not produce the required annotations to allow me to deploy the helm chart. Because the helm chart does not generate the CRD templates in the crds folder, I cannot use the native --skip-crds option to not deploy them in the helm chart.

https://github.com/estenrye/cd-homelab/commit/fd30721c31dda9a780101e5280e91bcb65631efe

I get the following error when I try to deploy the chart.

helm_release.open_feature_operator: Still creating... [10s elapsed]
╷
│ Error: Unable to continue with install: CustomResourceDefinition "featureflags.core.openfeature.dev" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "open-feature"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "open-feature"
│ 
│   with helm_release.open_feature_operator,
│   on open-feature-operator.tf line 7, in resource "helm_release" "open_feature_operator":
│    7: resource helm_release open_feature_operator {

Expected Behavior

When using terraform to deploy the helm chart and skip_crds = true CRD templates should not be in the final helm install output.

resource helm_release open_feature_operator {
  name = "open-feature"
  namespace = "open-feature"
  repository = "https://open-feature.github.io/open-feature-operator/"
  chart     = "open-feature-operator"
  version   = "0.5.4"
  create_namespace = true
  skip_crds = true
}

Documentation

Possible Solutions