Skip to content

feat(multi nic): support enabling multi networking #1721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
3 changes: 3 additions & 0 deletions modules/beta-autopilot-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ resource "google_container_cluster" "primary" {

networking_mode = "VPC_NATIVE"

enable_multi_networking = var.enable_multi_networking


protect_config {
workload_config {
audit_mode = var.workload_config_audit_mode
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-autopilot-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,9 @@ variable "timeouts" {
}
}

variable "enable_multi_networking" {
default = false
type = bool
description = "Enable multi NIC support."
}

2 changes: 2 additions & 0 deletions modules/beta-autopilot-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ resource "google_container_cluster" "primary" {

networking_mode = "VPC_NATIVE"

enable_multi_networking = var.enable_multi_networking

protect_config {
workload_config {
audit_mode = var.workload_config_audit_mode
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-autopilot-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,9 @@ variable "timeouts" {
}
}

variable "enable_multi_networking" {
default = false
type = bool
description = "Enable multi NIC support."
}

2 changes: 2 additions & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ resource "google_container_cluster" "primary" {

networking_mode = "VPC_NATIVE"

enable_multi_networking = var.enable_multi_networking

protect_config {
workload_config {
audit_mode = var.workload_config_audit_mode
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,9 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "enable_multi_networking" {
default = false
type = bool
description = "Enable multi NIC support."
}
20 changes: 17 additions & 3 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ resource "google_container_cluster" "primary" {

networking_mode = "VPC_NATIVE"

enable_multi_networking = var.enable_multi_networking

protect_config {
workload_config {
audit_mode = var.workload_config_audit_mode
Expand Down Expand Up @@ -501,15 +503,27 @@ 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)
type = lookup(placement_policy.value, "placement_policy", null)
policy_name = lookup(placement_policy.value, "placement_policy_resource_policy_name", 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
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", null)
}
}

network_config {
dynamic "additional_node_network_configs" {
for_each = {for idx, x in lookup(var.node_pools_additional_networks, each.value["name"], []) : idx => x}
iterator = additional_network
content {
network = additional_network.value.network_name
subnetwork = additional_network.value.subnetwork_name
}
}
}

Expand Down Expand Up @@ -734,7 +748,7 @@ resource "google_container_node_pool" "windows_pools" {
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
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", null)
}
}

Expand Down
37 changes: 30 additions & 7 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ variable "node_pools_labels" {
}
}

variable "node_pools_additional_networks" {
type = map(list(object({
network_name = string
subnetwork_name = string
})))
description = "Map of maps containing additional networks by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = []
default-node-pool = []
}
}

variable "node_pools_resource_labels" {
type = map(map(string))
description = "Map of maps containing resource labels by node-pool name"
Expand Down Expand Up @@ -496,7 +510,7 @@ variable "shadow_firewall_rules_log_config" {
metadata = string
})
description = "The log_config for shadow firewall rules. You can set this variable to `null` to disable logging."
default = {
default = {
metadata = "INCLUDE_ALL_METADATA"
}
}
Expand Down Expand Up @@ -581,10 +595,12 @@ variable "database_encryption" {
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
type = list(object({ state = string, key_name = string }))

default = [{
state = "DECRYPTED"
key_name = ""
}]
default = [
{
state = "DECRYPTED"
key_name = ""
}
]
}

variable "enable_shielded_nodes" {
Expand All @@ -605,7 +621,9 @@ variable "node_metadata" {
type = string

validation {
condition = contains(["GKE_METADATA", "GCE_METADATA", "UNSPECIFIED", "GKE_METADATA_SERVER", "EXPOSE"], var.node_metadata)
condition = contains([
"GKE_METADATA", "GCE_METADATA", "UNSPECIFIED", "GKE_METADATA_SERVER", "EXPOSE"
], var.node_metadata)
error_message = "The node_metadata value must be one of GKE_METADATA, GCE_METADATA, UNSPECIFIED, GKE_METADATA_SERVER or EXPOSE."
}
}
Expand Down Expand Up @@ -722,7 +740,6 @@ variable "enable_pod_security_policy" {
default = false
}


variable "enable_l4_ilb_subsetting" {
type = bool
description = "Enable L4 ILB Subsetting on the cluster"
Expand All @@ -746,3 +763,9 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "enable_multi_networking" {
default = false
type = bool
description = "Enable multi NIC support."
}
2 changes: 2 additions & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ resource "google_container_cluster" "primary" {

networking_mode = "VPC_NATIVE"

enable_multi_networking = var.enable_multi_networking

protect_config {
workload_config {
audit_mode = var.workload_config_audit_mode
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-public-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,9 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "enable_multi_networking" {
default = false
type = bool
description = "Enable multi NIC support."
}
16 changes: 15 additions & 1 deletion modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ resource "google_container_cluster" "primary" {

networking_mode = "VPC_NATIVE"

enable_multi_networking = var.enable_multi_networking

protect_config {
workload_config {
audit_mode = var.workload_config_audit_mode
Expand Down Expand Up @@ -482,7 +484,8 @@ 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)
type = lookup(placement_policy.value, "placement_policy", null)
policy_name = lookup(placement_policy.value, "placement_policy_resource_policy_name", null)
}
}

Expand All @@ -494,6 +497,17 @@ resource "google_container_node_pool" "pools" {
}
}

network_config {
dynamic "additional_node_network_configs" {
for_each = {for idx, x in lookup(var.node_pools_additional_networks, each.value["name"], []) : idx => x}
iterator = additional_network
content {
network = additional_network.value.network_name
subnetwork = additional_network.value.subnetwork_name
}
}
}

management {
auto_repair = lookup(each.value, "auto_repair", true)
auto_upgrade = lookup(each.value, "auto_upgrade", local.default_auto_upgrade)
Expand Down
36 changes: 30 additions & 6 deletions modules/beta-public-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ variable "node_pools_labels" {
}
}

variable "node_pools_additional_networks" {
type = map(list(object({
network_name = string
subnetwork_name = string
})))
description = "Map of maps containing additional networks by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = []
default-node-pool = []
}
}

variable "node_pools_resource_labels" {
type = map(map(string))
description = "Map of maps containing resource labels by node-pool name"
Expand Down Expand Up @@ -466,7 +480,7 @@ variable "shadow_firewall_rules_log_config" {
metadata = string
})
description = "The log_config for shadow firewall rules. You can set this variable to `null` to disable logging."
default = {
default = {
metadata = "INCLUDE_ALL_METADATA"
}
}
Expand Down Expand Up @@ -551,10 +565,12 @@ variable "database_encryption" {
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
type = list(object({ state = string, key_name = string }))

default = [{
state = "DECRYPTED"
key_name = ""
}]
default = [
{
state = "DECRYPTED"
key_name = ""
}
]
}

variable "enable_shielded_nodes" {
Expand All @@ -575,7 +591,9 @@ variable "node_metadata" {
type = string

validation {
condition = contains(["GKE_METADATA", "GCE_METADATA", "UNSPECIFIED", "GKE_METADATA_SERVER", "EXPOSE"], var.node_metadata)
condition = contains([
"GKE_METADATA", "GCE_METADATA", "UNSPECIFIED", "GKE_METADATA_SERVER", "EXPOSE"
], var.node_metadata)
error_message = "The node_metadata value must be one of GKE_METADATA, GCE_METADATA, UNSPECIFIED, GKE_METADATA_SERVER or EXPOSE."
}
}
Expand Down Expand Up @@ -716,3 +734,9 @@ variable "enable_identity_service" {
description = "Enable the Identity Service component, which allows customers to use external identity providers with the K8S API."
default = false
}

variable "enable_multi_networking" {
default = false
type = bool
description = "Enable multi NIC support."
}