civo/terraform-provider-civo

[BUG] Changing `kubernetes_version` after creation for civo_kubernetes_cluster does nothing

Closed this issue · 5 comments

Description

Issue

Changing kubernetes_version after creation for civo_kubernetes_cluster does nothing

provider "civo" {
  region = "LON1"
}




data "civo_size" "xsmall" {
    filter {
        key = "type"
        values = ["kubernetes"]
    }

    sort {
        key = "ram"
        direction = "asc"
    }
}

resource "civo_kubernetes_cluster" "my-cluster" {
    name = "my-cluster"
  #  kubernetes_version = "1.29.2+k3s1" # uncomment after creation

    firewall_id = civo_firewall.my-firewall.id
    pools {
        label = "front-end" // Optional
        size = element(data.civo_size.xsmall.sizes, 0).name
        node_count = 2
    }
}

Acceptance criteria

  • We support changing the Kubernetes version after creation, hence updating this field must modify the resource accordingly

Screenshots

No response

Additional information

No response

Hi @uzaxirr,

I tried solving this issue. If you allow, I would like to share my approach.

@Praveen005
sure go ahead and raise a PR

For this,

I commented out, the following:

if !d.HasChange("pools") {
return resourceKubernetesClusterRead(ctx, d, m)
}

Reason:

If I keep this part as is, update won't go through, unless you have made changes to the pools attribute.
which is not the case here.

Also, we will update the config and remove the return statement.

if d.HasChange("kubernetes_version") {
// config.KubernetesVersion = d.Get("kubernetes_version").(string)
// config.Region = apiClient.Region
return diag.Errorf("[ERR] Kubernetes version upgrade (%q attribute) is not supported yet", "kubernetes_version")
}

I tested it, and it does upgrade the version.

One caveat: Downgrading of version doesn't go through, and needs to handled on the API side.

@Praveen005 looks good can you raise a PR for this
make sure to attach relevant screenshots

Sure. Doing right away.