hashicorp / terraform-provider-helm

Terraform Helm provider
https://www.terraform.io/docs/providers/helm/
Mozilla Public License 2.0
1.01k stars 371 forks source link

helm chart deployment resource being replaced instead of upgrade. #1498

Closed rgaduput closed 1 month ago

rgaduput commented 1 month ago

Terraform version, Kubernetes provider version and Kubernetes version

Terraform version: v1.4.6
Helm Provider version: v.2.10.0
Kubernetes version: 1.30
Kubernetes provider version: v2.21.0
Terragrunt version v0.45.15

Terraform configuration

resource "helm_release" "sm_infra" {
  repository          = "https://artifactory.com/artifactory/helm-virtual"

  chart     = "sm-infra"
  name      = "sm-infra"
  version   = var.sm_infra_version_full
  namespace = kubernetes_namespace.default.metadata[0].name
  values    = local.helm_values
  timeout   = local.helm_timeout
  depends_on = [
    kubernetes_manifest.openpolicy_defaultimageregistry_mutator,
    kubernetes_manifest.openpolicy_defaultimageregistry_init_mutator
  ]
}

Question

Hi, Using helm provider I am trying to upgrade the existing chart deployment to a new version, But for some reason the helm provider is considering replace (destroy and create) instead of normal helm upgrade. I do not see any issues with state file as such, I can see the resource exists in it and also when I do terragrunt plan without modifying the helm chart version it says that No changes. Your infrastructure matches the configuration. We have not changed any thing, same provider versions, namespace, deployment name etc.

resource in tf state

terragrunt state show helm_release.asec_common
# helm_release.asec_common:
resource "helm_release" "asec_common" {
    atomic                     = false
    chart                      = "sm-infra"
    cleanup_on_fail            = false
    create_namespace           = false
    dependency_update          = false
    disable_crd_hooks          = false
    disable_openapi_validation = false
    disable_webhooks           = false
    force_update               = false
    id                         = "sm-infra"
    lint                       = false
    max_history                = 0
    metadata                   = [
        {
            app_version = "1.0.0"
            chart       = "sm-infra"
            name        = "sm-infra"
            namespace   = "sm-infra"
            revision    = 2 
            values      = jsonencode( {.......} )
            version     = "1.2.561"
         }
     ]
    name                       = "sm-infra"
    namespace                  = "sm-infra"
    pass_credentials           = false
    recreate_pods              = false
    render_subchart_notes      = true
    replace                    = false
    repository                 = "https://artifactory.com/artifactory/helm-virtual"
    reset_values               = false
    reuse_values               = false
    skip_crds                  = false
    status                     = "deployed"
    timeout                    = 1800
    values                     = [
        (sensitive value),
        (sensitive value),
        (sensitive value),
        (sensitive value),
    ]
    verify                     = false
    version                    = "1.2.561"
    wait                       = true
    wait_for_jobs              = false

After changing the chart version to 40.1011.xxx

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  - destroy

Terraform will perform the following actions:

  # helm_release.asec_common will be destroyed
  # (because helm_release.asec_common is not in configuration)
  - resource "helm_release" "asec_common" {
      - atomic                     = false -> null                                                                                                                                                             
      - chart                      = "sm-infra" -> null     
...........
...........
# helm_release.sm_infra will be created
  + resource "helm_release" "sm_infra" {
      + atomic                     = false
      + chart                      = "sm-infra"
      + version                    = "40.1011.1119"
................

Any idea why does provider not considering the simple helm upgrade , appreciate if any one can share some info on this.

Thanks

rgaduput commented 1 month ago

as pointed out by drew in Slack channel there was some mistake from my side where resource name got changed which caused this.