Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
3 changes: 3 additions & 0 deletions examples/node_pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This example illustrates how to create a cluster with multiple custom node-pool

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| additional\_ip\_pod\_range | The secondary ip range to use for pods in the additional range | `any` | n/a | yes |
| additional\_ip\_pod\_range\_subnetwork | The subnetwork to host the additional pod range in | `any` | n/a | yes |
| cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) | <pre>object({<br> enabled = bool<br> autoscaling_profile = string<br> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({<br> resource_type = string<br> minimum = number<br> maximum = number<br> }))<br> auto_repair = bool<br> auto_upgrade = bool<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "autoscaling_profile": "BALANCED",<br> "enabled": false,<br> "gpu_resources": [],<br> "max_cpu_cores": 0,<br> "max_memory_gb": 0,<br> "min_cpu_cores": 0,<br> "min_memory_gb": 0<br>}</pre> | no |
| cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no |
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes |
Expand All @@ -22,6 +24,7 @@ This example illustrates how to create a cluster with multiple custom node-pool

| Name | Description |
|------|-------------|
| additional\_ip\_range\_pods | The secondary IP range used for pods in the additional range |
| ca\_certificate | n/a |
| client\_token | n/a |
| cluster\_name | Cluster name |
Expand Down
7 changes: 7 additions & 0 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ module "gke" {
logging_variant = "MAX_THROUGHPUT"
dns_allow_external_traffic = true

additional_ip_ranges_config = [
{
subnetwork = "projects/${var.project_id}/regions/${var.region}/subnetworks/${var.additional_ip_pod_range_subnetwork}"
pod_ipv4_range_names = [var.additional_ip_pod_range]
}
]

resource_manager_tags = {
"${var.project_id}/${google_tags_tag_key.key.short_name}" = google_tags_tag_value.value.short_name
}
Expand Down
5 changes: 5 additions & 0 deletions examples/node_pool/test_outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ output "ip_range_services" {
value = var.ip_range_services
}

output "additional_ip_range_pods" {
description = "The secondary IP range used for pods in the additional range"
value = var.additional_ip_pod_range
}

output "zones" {
description = "List of zones in which the cluster resides"
value = module.gke.zones
Expand Down
8 changes: 8 additions & 0 deletions examples/node_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ variable "ip_range_services" {
description = "The secondary ip range to use for services"
}

variable "additional_ip_pod_range_subnetwork" {
description = "The subnetwork to host the additional pod range in"
}

variable "additional_ip_pod_range" {
description = "The secondary ip range to use for pods in the additional range"
}

variable "compute_engine_service_account" {
description = "Service account to associate to the nodes in the cluster"
}
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-autopilot-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-autopilot-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
4 changes: 2 additions & 2 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ resource "google_container_cluster" "primary" {
dynamic "additional_ip_ranges_config" {
for_each = var.additional_ip_ranges_config
content {
subnetwork = var.additional_ip_ranges_config.subnetwork
pod_ipv4_range_names = var.additional_ip_ranges_config.pod_ipv4_range_names
subnetwork = additional_ip_ranges_config.value.subnetwork
pod_ipv4_range_names = additional_ip_ranges_config.value.pod_ipv4_range_names
}
}
stack_type = var.stack_type
Expand Down
20 changes: 11 additions & 9 deletions test/fixtures/node_pool/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ locals {
module "example" {
source = "../../../examples/node_pool"

project_id = var.project_ids[0]
cluster_name_suffix = "-${random_string.suffix.result}"
region = "europe-west4"
zones = ["europe-west4-b"]
network = google_compute_network.main.name
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
compute_engine_service_account = local.compute_engine_service_account
project_id = var.project_ids[0]
cluster_name_suffix = "-${random_string.suffix.result}"
region = "europe-west4"
zones = ["europe-west4-b"]
network = google_compute_network.main.name
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
additional_ip_pod_range_subnetwork = google_compute_subnetwork.secondary.name
additional_ip_pod_range = google_compute_subnetwork.secondary.secondary_ip_range[0].range_name
compute_engine_service_account = local.compute_engine_service_account

cluster_autoscaling = {
enabled = true
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/node_pool/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ resource "google_compute_subnetwork" "main" {
ip_cidr_range = "172.16.0.0/18"
}
}

resource "google_compute_subnetwork" "secondary" {
name = "cft-gke-test-2-${random_string.suffix.result}"
ip_cidr_range = "10.1.0.0/17"
region = "europe-west4"
network = google_compute_network.main.self_link

secondary_ip_range {
range_name = "test2"
ip_cidr_range = "172.18.0.0/18"
}
}
5 changes: 5 additions & 0 deletions test/fixtures/node_pool/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ output "ip_range_services" {
value = google_compute_subnetwork.main.secondary_ip_range[1].range_name
}

output "additional_ip_range_pods" {
description = "The secondary IP range used for pods in the additional range"
value = google_compute_subnetwork.main.secondary_ip_range[2].range_name
}

output "zones" {
description = "List of zones in which the cluster resides"
value = module.example.zones
Expand Down
8 changes: 7 additions & 1 deletion test/integration/node_pool/testdata/TestNodePool.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@
"servicesIpv4CidrBlock": "192.168.64.0/18",
"servicesSecondaryRangeName": "cft-gke-test-services-RANDOM_STRING",
"stackType": "IPV4",
"useIpAliases": true
"useIpAliases": true,
"additionalIpRangesConfigs": [
{
"subnetwork": "projects/PROJECT_ID/regions/europe-west4/subnetworks/cft-gke-test-2-RANDOM_STRING",
"podIpv4RangeNames": ["test2"]
}
]
},
"labelFingerprint": "78cdf2f6",
"legacyAbac": {},
Expand Down