为Pod和服务配置Terraform GKE插件IP范围

时间:2019-02-05 11:14:04

标签: google-cloud-platform terraform google-kubernetes-engine

我正在尝试使用Terraform Module for GKE,但不确定如何配置属性ip_range_podsip_range_services

具体来说,我不确定它们如何得出这些值:

  ip_range_pods              = "us-central1-01-gke-01-pods"
  ip_range_services          = "us-central1-01-gke-01-services"

1 个答案:

答案 0 :(得分:3)

ip_range_podsip_range_services映射到google_container_cluster资源的ip_allocation_policy cluster_secondary_range_namecluster_secondary_range_name属性,如{{ 3}}:

resource "google_container_cluster" "zonal_primary" {
  # ...

  ip_allocation_policy {
    cluster_secondary_range_name  = "${var.ip_range_pods}"
    services_secondary_range_name = "${var.ip_range_services}"
  }
}

这些必须是子网中现有的范围,例如the module source创建的范围:

resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" {
  name          = "test-subnetwork"
  ip_cidr_range = "10.2.0.0/16"
  region        = "us-central1"
  network       = "${google_compute_network.custom-test.self_link}"
  secondary_ip_range {
    range_name    = "tf-test-secondary-range-update1"
    ip_cidr_range = "192.168.10.0/24"
  }
}

resource "google_compute_network" "custom-test" {
  name                    = "test-network"
  auto_create_subnetworks = false
}