Search code examples
terraformterraform-provider-helm

terraform helm release and kyverno


I can not get version to work in helm_release for terraform against kyverno, I've tried "v1.7.4" and "1.74", when I leave it off it deploys v1.7.4, no problem. What's it expecting as an input so the version I use is locked? https://github.com/kyverno/kyverno/tree/v1.7.4

error :

chart "kyverno" version "v1.7.4" not found in https://kyverno.github.io/kyverno/ repository, same for "1.7.0"

resource "helm_release" "kyverno" {
  name       = "kyverno"
  chart      = "kyverno"
  repository = "https://kyverno.github.io/kyverno/"
  **# version          = "v1.7.4"**
  namespace        = "kyverno"
  create_namespace = true
  values = [
    file("./manifests/kyverno/helm/values.yaml")
  ]
  set {
    name  = "replicaCount"
    value = 1
  }
  set {
    name  = "namespace"
    value = "kyverno"
  }
}

Solution

  • You need to use the official Helm chart version, not the application version. The way you can verify that is by first installing the Helm repo locally:

    helm repo add kyverno https://kyverno.github.io/kyverno/
    

    And then searching the repo:

    > helm search repo kyverno
    NAME                        CHART VERSION   APP VERSION DESCRIPTION                                       
    kyverno/kyverno             v2.5.4          v1.7.4      Kubernetes Native Policy Management               
    kyverno/kyverno-crds        v2.0.3          v1.4.3      Kubernetes Native Policy Management CRDs          
    kyverno/kyverno-policies    v2.5.5          v1.7.3      Kubernetes Pod Security Standards implemented a...
    

    As you can see, you are actually looking for the chart version v2.5.4. The correct way to reference a chart version is without the v, so you want:

    resource "helm_release" "kyverno" {
      name             = "kyverno"
      chart            = "kyverno"
      repository       = "https://kyverno.github.io/kyverno/"
      version          = "2.5.4"
      namespace        = "kyverno"
      create_namespace = true
      values = [
        file("./manifests/kyverno/helm/values.yaml")
      ]
      set {
        name  = "replicaCount"
        value = 1
      }
      set {
        name  = "namespace"
        value = "kyverno"
      }
    }