无法删除后端服务正在使用的实例组
我正在使用terraform来管理GKE群集设置。我想更新工作节点的实例大小,这将重新创建google_container_node_popl,即删除现有实例组并为节点池重新创建新的实例组。但是由于出现以下错误,导致此步骤失败,因为与GCP LB后端连接的旧实例组在重新创建节点池时不会通过地形分离。
google_container_node_pool.new_container_cluster_node_pool.0: Error waiting for deleting GKE NodePool:
(1) Google Compute Engine: The instance_template resource 'projects/XXX-XXX-XXXX/global/instanceTemplates/gke-XXX-XXX-us-west-XXXXXX-53369325' is already being used by 'projects/XXXX-XXXX-XXXXX/zones/us-west1-b/instanceGroupManagers/gke-XXXXX-XXXX-us-west-XXXXX-XXXXX-us-west-53369325-grp'
最后,我们必须从GCP LB后端手动删除实例组条目,计划并再次应用以使用新实例类型重新创建节点池。
resource "google_compute_backend_service" "default" {
project = "${var.project}"
count = "${length(var.backend_params)}"
name = "${var.name}-backend-${count.index}"
port_name = "${element(split(",", element(var.backend_params, count.index)), 1)}"
protocol = "${var.backend_protocol}"
timeout_sec = "${element(split(",", element(var.backend_params, count.index)), 3)}"
backend = ["${var.backends["${count.index}"]}"]
health_checks = ["${element(google_compute_health_check.default-tcp.*.self_link, count.index)}"]
security_policy = "${var.security_policy}"
enable_cdn = "${var.cdn}"
}
Input variable ( getting the instance groups URL from GKE module)
backends = {
"0" = [
# Have to use "element" because of nested lists
{
group = "${replace(element(module.gke.node_pool_instance_group_urls[0],0), "Manager", "")}",
balancing_mode = "${var.lb_balancing_mode}",
max_rate = "${var.lb_max_rate}",
max_utilization = "${var.lb_max_utilization}"
},
{
group = "${replace(element(module.gke.node_pool_instance_group_urls[0],1), "Manager", "")}",
balancing_mode = "${var.lb_balancing_mode}",
max_rate = "${var.lb_max_rate}",
max_utilization = "${var.lb_max_utilization}"
},
{
group = "${replace(element(module.gke.node_pool_instance_group_urls[0],2), "Manager", "")}",
balancing_mode = "${var.lb_balancing_mode}",
max_rate = "${var.lb_max_rate}",
max_utilization = "${var.lb_max_utilization}"
},
{
group = "${replace(element(module.gke.node_pool_instance_group_urls[1],0), "Manager", "")}",
balancing_mode = "${var.lb_balancing_mode}",
max_rate = "${var.lb_max_rate}",
max_utilization = "${var.lb_max_utilization}"
},
{
group = "${replace(element(module.gke.node_pool_instance_group_urls[1],1), "Manager", "")}",
balancing_mode = "${var.lb_balancing_mode}",
max_rate = "${var.lb_max_rate}",
max_utilization = "${var.lb_max_utilization}"
},
{
group = "${replace(element(module.gke.node_pool_instance_group_urls[1],2), "Manager", "")}",
balancing_mode = "${var.lb_balancing_mode}",
max_rate = "${var.lb_max_rate}",
max_utilization = "${var.lb_max_utilization}"
}
],
首先,terraform将在重新创建GKE节点池时从GCP LB后端设置中分离当前实例组。