【发布时间】:2021-10-29 10:56:23
【问题描述】:
我已在 Google Cloud Platform (GCP) 项目 ($GCP_PROJECT_NAME) 中成功创建了 Google Kubernetes Engine (GKE) 集群 ($GKE_CLUSTER_NAME):
gcloud container clusters list \
--format="value(name)" \
--project=$GCP_PROJECT_NAME
#=>
. . .
$GKE_CLUSTER_NAME
. . .
使用节点池$GKE_NODE_POOL:
gcloud container node-pools list \
--cluster=$GKE_CLUSTER_NAME \
--format="value(name)" \
--zone=$GKE_CLUSTER_ZONE
#=>
$GKE_NODE_POOL
我正在检查这个配置。使用 Terraform 使用以下container_node_pool.tf 进入 SCM:
resource "google_container_node_pool" ". . ." {
autoscaling {
max_node_count = "3"
min_node_count = "3"
}
. . .
initial_node_count = "3"
. . .
}
我确认上面的 Terraform 配置与当前在 $GKE_CLUSTER_NAME 和 $GCP_PROJECT_NAME 内部运行的 $GKE_NODE_POOL 匹配:
terraform plan
#=>
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
如果我想更改$GKE_NODE_POOL:
resource "google_container_node_pool" ". . ." {
autoscaling {
max_node_count = "4"
min_node_count = "4"
}
. . .
initial_node_count = "4"
. . .
}
并将$GKE_NODE_POOL 中nodes 的数量从3 缩放到4,我在尝试plan 时得到以下输出:
terraform plan
#=>
. . .
Plan: 1 to add, 0 to change, 1 to destroy.
. . .
如何在不破坏然后重新创建资源的情况下更新$GKE_NODE_POOL?
【问题讨论】:
标签: google-cloud-platform terraform google-kubernetes-engine terraform-provider-gcp infrastructure-as-code