在创建 MIG 时配置有状态 IP 地址

在创建托管式实例组 (MIG) 时配置有状态 IP 地址。

深入探索

如需查看包含此代码示例的详细文档,请参阅以下内容:

代码示例

Terraform

如需了解如何应用或移除 Terraform 配置,请参阅基本 Terraform 命令。 如需了解详情,请参阅 Terraform 提供程序参考文档

resource "google_compute_region_instance_group_manager" "default" {
  name               = "example-group"
  base_instance_name = "node"
  target_size        = 3
  region             = "us-east1"

  version {
    instance_template = google_compute_instance_template.default.id
    name              = "primary"
  }
  update_policy {
    type                         = "OPPORTUNISTIC"
    minimal_action               = "REFRESH"
    instance_redistribution_type = "NONE"
    max_unavailable_fixed        = 3
  }
  stateful_internal_ip {
    interface_name = "nic0"
    delete_rule    = "ON_PERMANENT_INSTANCE_DELETION"
  }
  stateful_internal_ip {
    interface_name = "nic1"
    delete_rule    = "ON_PERMANENT_INSTANCE_DELETION"
  }
  stateful_external_ip {
    interface_name = "nic0"
    delete_rule    = "ON_PERMANENT_INSTANCE_DELETION"
  }
}

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器