Skip to content

Commit

Permalink
feat: add support for pod_range in private cluster (#1803)
Browse files Browse the repository at this point in the history
Co-authored-by: Shubham Singh <[email protected]>
  • Loading branch information
shubhamkr619 and shubhamkr619 authored Nov 22, 2023
1 parent 493149d commit 9c62f1f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
2 changes: 0 additions & 2 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ resource "google_container_node_pool" "windows_pools" {
}
}

{% if beta_cluster %}
dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
Expand All @@ -733,7 +732,6 @@ resource "google_container_node_pool" "windows_pools" {
{% endif %}
}
}
{% endif %}

management {
auto_repair = lookup(each.value, "auto_repair", true)
Expand Down
28 changes: 28 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,20 @@ resource "google_container_node_pool" "pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
pod_range = lookup(network_config.value, "pod_range", null)
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", null)
}
}

management {
auto_repair = lookup(each.value, "auto_repair", true)
Expand Down Expand Up @@ -631,6 +645,20 @@ resource "google_container_node_pool" "windows_pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
pod_range = lookup(network_config.value, "pod_range", null)
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", null)
}
}

management {
auto_repair = lookup(each.value, "auto_repair", true)
Expand Down
28 changes: 28 additions & 0 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,20 @@ resource "google_container_node_pool" "pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
pod_range = lookup(network_config.value, "pod_range", null)
enable_private_nodes = var.enable_private_nodes
}
}

management {
auto_repair = lookup(each.value, "auto_repair", true)
Expand Down Expand Up @@ -726,6 +740,20 @@ resource "google_container_node_pool" "windows_pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
pod_range = lookup(network_config.value, "pod_range", null)
enable_private_nodes = var.enable_private_nodes
}
}

management {
auto_repair = lookup(each.value, "auto_repair", true)
Expand Down
28 changes: 28 additions & 0 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,20 @@ resource "google_container_node_pool" "pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
pod_range = lookup(network_config.value, "pod_range", null)
enable_private_nodes = var.enable_private_nodes
}
}

management {
auto_repair = lookup(each.value, "auto_repair", true)
Expand Down Expand Up @@ -650,6 +664,20 @@ resource "google_container_node_pool" "windows_pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
pod_range = lookup(network_config.value, "pod_range", null)
enable_private_nodes = var.enable_private_nodes
}
}

management {
auto_repair = lookup(each.value, "auto_repair", true)
Expand Down

0 comments on commit 9c62f1f

Please sign in to comment.