Environment  环境

Rancher < v2.10.7, < v2.11.3  and Terraform provisioned GKE Cluster
Rancher < v2.10.7、< v2.11.3 和 Terraform 配置的 GKE 集群

 

 

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.
使用 Rancher2 Terraform 提供者管理 GKE 集群时,向现有集群添加节点池会触发整个集群的重建。使用 Rancher UI 或 Google Cloud Terraform 提供商时未观察到此行为。

 

Terraform plan output below shows that adding the node_pools block forces the replacement of the rancher2_cluster.gke_cluster resource
下面的 Terraform 规划输出显示,添加 node_pools 块会强制替换 rancher2_cluster.gke_cluster 资源

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>  # 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</code></span></span></span>

Note: Any configuration changes on existing nodepools or removing existing nodepools doesn't initiate cluster recreation
注意:对现有节点池进行任何配置更改或移除现有节点池都不会启动集群重建

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
该问题在 Rancher 版本 v2.10.7、v2.11.3 和 v2.12.0 以及 Rancher2 Terraform 提供者版本 v6.7.0、v7.3.0 和 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.
修复完成后,如输出所示,Terraform 检测到新增节点池,并对 rancher2_cluster.gke_cluster 进行原地修改。

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>  # 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.</code></span></span></span>

 

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.
Rancher2 Terraform 提供商缺乏管理单个节点池所需的细致控制。所以它把整个列表当作一个实体来处理。对 node_pools 列表的任何更改都被视为对现有配置的完全替换,导致整个集群的替换。

访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐