Skip to content

Commit cebc213

Browse files
m0psMaksym Kursinbharathkkb
authored
feat!: Add support for additional pod secondary ranges at the cluster level (#1738)
Co-authored-by: Maksym Kursin <[email protected]> Co-authored-by: Bharath KKB <[email protected]>
1 parent b887cdb commit cebc213

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+158
-29
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Then perform the following commands on the root folder:
135135
| add\_cluster\_firewall\_rules | Create additional firewall rules | `bool` | `false` | no |
136136
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
137137
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
138+
| additional\_ip\_range\_pods | List of _names_ of the additional secondary subnet ip ranges to use for pods | `list(string)` | `[]` | no |
138139
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
139140
| 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> min_cpu_cores = number<br> max_cpu_cores = number<br> min_memory_gb = number<br> max_memory_gb = number<br> gpu_resources = list(object({ resource_type = string, minimum = number, maximum = number }))<br> auto_repair = bool<br> auto_upgrade = bool<br> disk_size = optional(number)<br> disk_type = optional(string)<br> })</pre> | <pre>{<br> "auto_repair": true,<br> "auto_upgrade": true,<br> "disk_size": 100,<br> "disk_type": "pd-standard",<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 |
140141
| cluster\_dns\_domain | The suffix used for all cluster service records. | `string` | `""` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ resource "google_container_cluster" "primary" {
337337
ip_allocation_policy {
338338
cluster_secondary_range_name = var.ip_range_pods
339339
services_secondary_range_name = var.ip_range_services
340+
dynamic "additional_pod_ranges_config" {
341+
for_each = length(var.additional_ip_range_pods) != 0 ? [1] : []
342+
content {
343+
pod_range_names = var.additional_ip_range_pods
344+
}
345+
}
340346
}
341347

342348
maintenance_policy {

autogen/main/main.tf.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ locals {
9090
cluster_subnet_cidr = var.add_cluster_firewall_rules ? data.google_compute_subnetwork.gke_subnetwork[0].ip_cidr_range : null
9191
cluster_alias_ranges_cidr = var.add_cluster_firewall_rules ? { for range in toset(data.google_compute_subnetwork.gke_subnetwork[0].secondary_ip_range) : range.range_name => range.ip_cidr_range } : {}
9292
{% if autopilot_cluster != true %}
93-
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for k, v in merge(local.node_pools, local.windows_node_pools): local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0] )) : []
93+
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for range in var.additional_ip_range_pods : local.cluster_alias_ranges_cidr[range] if length(range) > 0], [for k, v in merge(local.node_pools, local.windows_node_pools) : local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0])) : []
9494
{% else %}
95-
pod_all_ip_ranges = var.add_cluster_firewall_rules ? [local.cluster_alias_ranges_cidr[var.ip_range_pods]] : []
95+
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for range in var.additional_ip_range_pods : local.cluster_alias_ranges_cidr[range] if length(range) > 0])) : []
9696
{% endif %}
9797

9898
{% if autopilot_cluster != true %}

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ variable "ip_range_pods" {
139139
description = "The _name_ of the secondary subnet ip range to use for pods"
140140
}
141141

142+
variable "additional_ip_range_pods" {
143+
type = list(string)
144+
description = "List of _names_ of the additional secondary subnet ip ranges to use for pods"
145+
default = []
146+
}
147+
142148
variable "ip_range_services" {
143149
type = string
144150
description = "The _name_ of the secondary subnet range to use for services"

autogen/main/versions.tf.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ terraform {
2424
required_providers {
2525
google = {
2626
source = "hashicorp/google"
27-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
27+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
2828
}
2929
google-beta = {
3030
source = "hashicorp/google-beta"
31-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
31+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
3232
}
3333
kubernetes = {
3434
source = "hashicorp/kubernetes"
@@ -46,7 +46,7 @@ terraform {
4646
required_providers {
4747
google = {
4848
source = "hashicorp/google"
49-
version = ">= 4.51.0, < 5.0, !=4.65.0, !=4.65.1"
49+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
5050
}
5151
kubernetes = {
5252
source = "hashicorp/kubernetes"

cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ resource "google_container_cluster" "primary" {
220220
ip_allocation_policy {
221221
cluster_secondary_range_name = var.ip_range_pods
222222
services_secondary_range_name = var.ip_range_services
223+
dynamic "additional_pod_ranges_config" {
224+
for_each = length(var.additional_ip_range_pods) != 0 ? [1] : []
225+
content {
226+
pod_range_names = var.additional_ip_range_pods
227+
}
228+
}
223229
}
224230

225231
maintenance_policy {

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ locals {
7979

8080
cluster_subnet_cidr = var.add_cluster_firewall_rules ? data.google_compute_subnetwork.gke_subnetwork[0].ip_cidr_range : null
8181
cluster_alias_ranges_cidr = var.add_cluster_firewall_rules ? { for range in toset(data.google_compute_subnetwork.gke_subnetwork[0].secondary_ip_range) : range.range_name => range.ip_cidr_range } : {}
82-
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for k, v in merge(local.node_pools, local.windows_node_pools) : local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0])) : []
82+
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for range in var.additional_ip_range_pods : local.cluster_alias_ranges_cidr[range] if length(range) > 0], [for k, v in merge(local.node_pools, local.windows_node_pools) : local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0])) : []
8383

8484
cluster_network_policy = var.network_policy ? [{
8585
enabled = true

modules/beta-autopilot-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Then perform the following commands on the root folder:
7474
| add\_cluster\_firewall\_rules | Create additional firewall rules | `bool` | `false` | no |
7575
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
7676
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
77+
| additional\_ip\_range\_pods | List of _names_ of the additional secondary subnet ip ranges to use for pods | `list(string)` | `[]` | no |
7778
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
7879
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `string` | `null` | no |
7980
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no |

modules/beta-autopilot-private-cluster/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ resource "google_container_cluster" "primary" {
138138
ip_allocation_policy {
139139
cluster_secondary_range_name = var.ip_range_pods
140140
services_secondary_range_name = var.ip_range_services
141+
dynamic "additional_pod_ranges_config" {
142+
for_each = length(var.additional_ip_range_pods) != 0 ? [1] : []
143+
content {
144+
pod_range_names = var.additional_ip_range_pods
145+
}
146+
}
141147
}
142148

143149
maintenance_policy {

modules/beta-autopilot-private-cluster/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ locals {
6262

6363
cluster_subnet_cidr = var.add_cluster_firewall_rules ? data.google_compute_subnetwork.gke_subnetwork[0].ip_cidr_range : null
6464
cluster_alias_ranges_cidr = var.add_cluster_firewall_rules ? { for range in toset(data.google_compute_subnetwork.gke_subnetwork[0].secondary_ip_range) : range.range_name => range.ip_cidr_range } : {}
65-
pod_all_ip_ranges = var.add_cluster_firewall_rules ? [local.cluster_alias_ranges_cidr[var.ip_range_pods]] : []
65+
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for range in var.additional_ip_range_pods : local.cluster_alias_ranges_cidr[range] if length(range) > 0])) : []
6666

6767

6868
cluster_authenticator_security_group = var.authenticator_security_group == null ? [] : [{

modules/beta-autopilot-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ variable "ip_range_pods" {
131131
description = "The _name_ of the secondary subnet ip range to use for pods"
132132
}
133133

134+
variable "additional_ip_range_pods" {
135+
type = list(string)
136+
description = "List of _names_ of the additional secondary subnet ip ranges to use for pods"
137+
default = []
138+
}
139+
134140
variable "ip_range_services" {
135141
type = string
136142
description = "The _name_ of the secondary subnet range to use for services"

modules/beta-autopilot-private-cluster/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ terraform {
2121
required_providers {
2222
google = {
2323
source = "hashicorp/google"
24-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
24+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
2525
}
2626
google-beta = {
2727
source = "hashicorp/google-beta"
28-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
28+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
2929
}
3030
kubernetes = {
3131
source = "hashicorp/kubernetes"

modules/beta-autopilot-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Then perform the following commands on the root folder:
6868
| add\_cluster\_firewall\_rules | Create additional firewall rules | `bool` | `false` | no |
6969
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
7070
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
71+
| additional\_ip\_range\_pods | List of _names_ of the additional secondary subnet ip ranges to use for pods | `list(string)` | `[]` | no |
7172
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
7273
| cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `string` | `null` | no |
7374
| cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no |

modules/beta-autopilot-public-cluster/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ resource "google_container_cluster" "primary" {
138138
ip_allocation_policy {
139139
cluster_secondary_range_name = var.ip_range_pods
140140
services_secondary_range_name = var.ip_range_services
141+
dynamic "additional_pod_ranges_config" {
142+
for_each = length(var.additional_ip_range_pods) != 0 ? [1] : []
143+
content {
144+
pod_range_names = var.additional_ip_range_pods
145+
}
146+
}
141147
}
142148

143149
maintenance_policy {

modules/beta-autopilot-public-cluster/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ locals {
6262

6363
cluster_subnet_cidr = var.add_cluster_firewall_rules ? data.google_compute_subnetwork.gke_subnetwork[0].ip_cidr_range : null
6464
cluster_alias_ranges_cidr = var.add_cluster_firewall_rules ? { for range in toset(data.google_compute_subnetwork.gke_subnetwork[0].secondary_ip_range) : range.range_name => range.ip_cidr_range } : {}
65-
pod_all_ip_ranges = var.add_cluster_firewall_rules ? [local.cluster_alias_ranges_cidr[var.ip_range_pods]] : []
65+
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for range in var.additional_ip_range_pods : local.cluster_alias_ranges_cidr[range] if length(range) > 0])) : []
6666

6767

6868
cluster_authenticator_security_group = var.authenticator_security_group == null ? [] : [{

modules/beta-autopilot-public-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ variable "ip_range_pods" {
131131
description = "The _name_ of the secondary subnet ip range to use for pods"
132132
}
133133

134+
variable "additional_ip_range_pods" {
135+
type = list(string)
136+
description = "List of _names_ of the additional secondary subnet ip ranges to use for pods"
137+
default = []
138+
}
139+
134140
variable "ip_range_services" {
135141
type = string
136142
description = "The _name_ of the secondary subnet range to use for services"

modules/beta-autopilot-public-cluster/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ terraform {
2121
required_providers {
2222
google = {
2323
source = "hashicorp/google"
24-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
24+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
2525
}
2626
google-beta = {
2727
source = "hashicorp/google-beta"
28-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
28+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
2929
}
3030
kubernetes = {
3131
source = "hashicorp/kubernetes"

modules/beta-private-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Then perform the following commands on the root folder:
167167
| add\_cluster\_firewall\_rules | Create additional firewall rules | `bool` | `false` | no |
168168
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
169169
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
170+
| additional\_ip\_range\_pods | List of _names_ of the additional secondary subnet ip ranges to use for pods | `list(string)` | `[]` | no |
170171
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
171172
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
172173
| cloudrun\_load\_balancer\_type | (Beta) Configure the Cloud Run load balancer type. External by default. Set to `LOAD_BALANCER_TYPE_INTERNAL` to configure as an internal load balancer. | `string` | `""` | no |

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ resource "google_container_cluster" "primary" {
277277
ip_allocation_policy {
278278
cluster_secondary_range_name = var.ip_range_pods
279279
services_secondary_range_name = var.ip_range_services
280+
dynamic "additional_pod_ranges_config" {
281+
for_each = length(var.additional_ip_range_pods) != 0 ? [1] : []
282+
content {
283+
pod_range_names = var.additional_ip_range_pods
284+
}
285+
}
280286
}
281287

282288
maintenance_policy {

modules/beta-private-cluster-update-variant/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ locals {
7979

8080
cluster_subnet_cidr = var.add_cluster_firewall_rules ? data.google_compute_subnetwork.gke_subnetwork[0].ip_cidr_range : null
8181
cluster_alias_ranges_cidr = var.add_cluster_firewall_rules ? { for range in toset(data.google_compute_subnetwork.gke_subnetwork[0].secondary_ip_range) : range.range_name => range.ip_cidr_range } : {}
82-
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for k, v in merge(local.node_pools, local.windows_node_pools) : local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0])) : []
82+
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for range in var.additional_ip_range_pods : local.cluster_alias_ranges_cidr[range] if length(range) > 0], [for k, v in merge(local.node_pools, local.windows_node_pools) : local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0])) : []
8383

8484
cluster_network_policy = var.network_policy ? [{
8585
enabled = true

modules/beta-private-cluster-update-variant/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ variable "ip_range_pods" {
137137
description = "The _name_ of the secondary subnet ip range to use for pods"
138138
}
139139

140+
variable "additional_ip_range_pods" {
141+
type = list(string)
142+
description = "List of _names_ of the additional secondary subnet ip ranges to use for pods"
143+
default = []
144+
}
145+
140146
variable "ip_range_services" {
141147
type = string
142148
description = "The _name_ of the secondary subnet range to use for services"

modules/beta-private-cluster-update-variant/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ terraform {
2121
required_providers {
2222
google = {
2323
source = "hashicorp/google"
24-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
24+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
2525
}
2626
google-beta = {
2727
source = "hashicorp/google-beta"
28-
version = ">= 4.76.0, < 5.0, !=4.65.0, !=4.65.1"
28+
version = ">= 4.80.0, < 5.0, !=4.65.0, !=4.65.1"
2929
}
3030
kubernetes = {
3131
source = "hashicorp/kubernetes"

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ Then perform the following commands on the root folder:
145145
| add\_cluster\_firewall\_rules | Create additional firewall rules | `bool` | `false` | no |
146146
| add\_master\_webhook\_firewall\_rules | Create master\_webhook firewall rules for ports defined in `firewall_inbound_ports` | `bool` | `false` | no |
147147
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
148+
| additional\_ip\_range\_pods | List of _names_ of the additional secondary subnet ip ranges to use for pods | `list(string)` | `[]` | no |
148149
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |
149150
| cloudrun | (Beta) Enable CloudRun addon | `bool` | `false` | no |
150151
| cloudrun\_load\_balancer\_type | (Beta) Configure the Cloud Run load balancer type. External by default. Set to `LOAD_BALANCER_TYPE_INTERNAL` to configure as an internal load balancer. | `string` | `""` | no |

modules/beta-private-cluster/cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ resource "google_container_cluster" "primary" {
277277
ip_allocation_policy {
278278
cluster_secondary_range_name = var.ip_range_pods
279279
services_secondary_range_name = var.ip_range_services
280+
dynamic "additional_pod_ranges_config" {
281+
for_each = length(var.additional_ip_range_pods) != 0 ? [1] : []
282+
content {
283+
pod_range_names = var.additional_ip_range_pods
284+
}
285+
}
280286
}
281287

282288
maintenance_policy {

modules/beta-private-cluster/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ locals {
7979

8080
cluster_subnet_cidr = var.add_cluster_firewall_rules ? data.google_compute_subnetwork.gke_subnetwork[0].ip_cidr_range : null
8181
cluster_alias_ranges_cidr = var.add_cluster_firewall_rules ? { for range in toset(data.google_compute_subnetwork.gke_subnetwork[0].secondary_ip_range) : range.range_name => range.ip_cidr_range } : {}
82-
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for k, v in merge(local.node_pools, local.windows_node_pools) : local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0])) : []
82+
pod_all_ip_ranges = var.add_cluster_firewall_rules ? compact(concat([local.cluster_alias_ranges_cidr[var.ip_range_pods]], [for range in var.additional_ip_range_pods : local.cluster_alias_ranges_cidr[range] if length(range) > 0], [for k, v in merge(local.node_pools, local.windows_node_pools) : local.cluster_alias_ranges_cidr[v.pod_range] if length(lookup(v, "pod_range", "")) > 0])) : []
8383

8484
cluster_network_policy = var.network_policy ? [{
8585
enabled = true

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ variable "ip_range_pods" {
137137
description = "The _name_ of the secondary subnet ip range to use for pods"
138138
}
139139

140+
variable "additional_ip_range_pods" {
141+
type = list(string)
142+
description = "List of _names_ of the additional secondary subnet ip ranges to use for pods"
143+
default = []
144+
}
145+
140146
variable "ip_range_services" {
141147
type = string
142148
description = "The _name_ of the secondary subnet range to use for services"

0 commit comments

Comments
 (0)