Skip to content

Adding a node pool to an existing GKE cluster using Rancher2 Terraform provider causes full cluster recreation

Article Number: 000022152

Environment

Rancher < v2.10.7, < v2.11.3  and Terraform provisioned GKE Cluster

Situation

When using the Rancher2 Terraform provider to manage GKE clusters, adding a node pool to an existing cluster triggers the recreation of the entire cluster. This behavior is not observed when using the Rancher UI or the Google Cloud Terraform provider.

Terraform plan output below shows that adding the node_pools block forces the replacement of the rancher2_cluster.gke_cluster resource

  # rancher2_cluster.gke_cluster must be replaced
-/+ resource "rancher2_cluster" "gke_cluster" {
      ~ annotations                                                = {


          + node_pools {
              + initial_node_count  = 1
              + max_pods_constraint = 110
              + name                = "second-pool"
              + version             = "1.30.11-gke.1157000"

              + autoscaling (known after apply)

              + config (known after apply) # forces replacement

              + management (known after apply)

  # rancher2_cluster_sync.sync must be replaced
-/+ resource "rancher2_cluster_sync" "sync" {
      ~ cluster_id         = "c-jstj7" -> (known after apply) # forces replacement

Note: Any configuration changes on existing nodepools or removing existing nodepools doesn't initiate cluster recreation

Cause

The Rancher2 Terraform provider lacked the granular control necessary to manage individual node pools separately. So it treats the entire list as a single entity. Any change to the node_pools list was interpreted as a complete replacement of the existing configuration, leading to a full cluster replacement.

Resolution

The issue is resolved in the Rancher versions v2.10.7, v2.11.3 and v2.12.0, and Rancher2 Terraform provider versions v6.7.0, v7.3.0 and v8.0.0

Upgrade to these versions to avoid full cluster recreation when adding node pools.

After the fix is applied, as shown in the output, Terraform detects the addition of a new node pool and performs an in-place modification of the rancher2_cluster.gke_cluster.

  # rancher2_cluster.gke_cluster will be updated in-place
  ~ resource "rancher2_cluster" "gke_cluster" {
        id                         = "c-c7mg5"
        name                       = "gke-sh"

      ~ gke_config_v2 {
            name                     = "gke-sh"

          + node_pools {
              + initial_node_count  = 1
              + max_pods_constraint = 110
              + name                = "second-pool"
              + version             = "1.30.12-gke.1208000"

              + autoscaling (known after apply)

              + config (known after apply)

              + management (known after apply)
            }

rancher2_cluster.gke_cluster: Modifying... [id=c-c7mg5]
rancher2_cluster.gke_cluster: Modifications complete after 1s [id=c-c7mg5]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.