Skip to content

Commit

Permalink
feat: add optional private_endpoint_subnetwork variable in private su…
Browse files Browse the repository at this point in the history
…bmodules (#2009)
  • Loading branch information
pib authored Aug 2, 2024
1 parent b4f2e14 commit 7a2e9b8
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 36 deletions.
14 changes: 8 additions & 6 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,17 @@ resource "google_container_cluster" "primary" {
{% if private_cluster %}
dynamic "private_cluster_config" {
for_each = var.enable_private_nodes ? [{
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
private_endpoint_subnetwork = var.private_endpoint_subnetwork
}] : []

content {
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
private_endpoint_subnetwork = private_cluster_config.value.private_endpoint_subnetwork
dynamic "master_global_access_config" {
for_each = var.master_global_access_enabled ? [var.master_global_access_enabled] : []
content {
Expand Down
6 changes: 6 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ variable "master_ipv4_cidr_block" {
{% endif %}
}

variable "private_endpoint_subnetwork" {
type = string
description = "The subnetwork to use for the hosted master network."
default = null
}

variable "master_global_access_enabled" {
type = bool
description = "Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint."
Expand Down
1 change: 1 addition & 0 deletions modules/beta-autopilot-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
| private\_endpoint\_subnetwork | The subnetwork to use for the hosted master network. | `string` | `null` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
14 changes: 8 additions & 6 deletions modules/beta-autopilot-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,17 @@ resource "google_container_cluster" "primary" {

dynamic "private_cluster_config" {
for_each = var.enable_private_nodes ? [{
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
private_endpoint_subnetwork = var.private_endpoint_subnetwork
}] : []

content {
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
private_endpoint_subnetwork = private_cluster_config.value.private_endpoint_subnetwork
dynamic "master_global_access_config" {
for_each = var.master_global_access_enabled ? [var.master_global_access_enabled] : []
content {
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 @@ -288,6 +288,12 @@ variable "master_ipv4_cidr_block" {
default = null
}

variable "private_endpoint_subnetwork" {
type = string
description = "The subnetwork to use for the hosted master network."
default = null
}

variable "master_global_access_enabled" {
type = bool
description = "Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint."
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
| private\_endpoint\_subnetwork | The subnetwork to use for the hosted master network. | `string` | `null` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
14 changes: 8 additions & 6 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,17 @@ resource "google_container_cluster" "primary" {

dynamic "private_cluster_config" {
for_each = var.enable_private_nodes ? [{
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
private_endpoint_subnetwork = var.private_endpoint_subnetwork
}] : []

content {
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
private_endpoint_subnetwork = private_cluster_config.value.private_endpoint_subnetwork
dynamic "master_global_access_config" {
for_each = var.master_global_access_enabled ? [var.master_global_access_enabled] : []
content {
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 @@ -452,6 +452,12 @@ variable "master_ipv4_cidr_block" {
default = "10.0.0.0/28"
}

variable "private_endpoint_subnetwork" {
type = string
description = "The subnetwork to use for the hosted master network."
default = null
}

variable "master_global_access_enabled" {
type = bool
description = "Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint."
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
| private\_endpoint\_subnetwork | The subnetwork to use for the hosted master network. | `string` | `null` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
14 changes: 8 additions & 6 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,17 @@ resource "google_container_cluster" "primary" {

dynamic "private_cluster_config" {
for_each = var.enable_private_nodes ? [{
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
private_endpoint_subnetwork = var.private_endpoint_subnetwork
}] : []

content {
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
private_endpoint_subnetwork = private_cluster_config.value.private_endpoint_subnetwork
dynamic "master_global_access_config" {
for_each = var.master_global_access_enabled ? [var.master_global_access_enabled] : []
content {
Expand Down
6 changes: 6 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ variable "master_ipv4_cidr_block" {
default = "10.0.0.0/28"
}

variable "private_endpoint_subnetwork" {
type = string
description = "The subnetwork to use for the hosted master network."
default = null
}

variable "master_global_access_enabled" {
type = bool
description = "Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint."
Expand Down
1 change: 1 addition & 0 deletions modules/private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
| private\_endpoint\_subnetwork | The subnetwork to use for the hosted master network. | `string` | `null` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
14 changes: 8 additions & 6 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,17 @@ resource "google_container_cluster" "primary" {

dynamic "private_cluster_config" {
for_each = var.enable_private_nodes ? [{
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
private_endpoint_subnetwork = var.private_endpoint_subnetwork
}] : []

content {
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
private_endpoint_subnetwork = private_cluster_config.value.private_endpoint_subnetwork
dynamic "master_global_access_config" {
for_each = var.master_global_access_enabled ? [var.master_global_access_enabled] : []
content {
Expand Down
6 changes: 6 additions & 0 deletions modules/private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ variable "master_ipv4_cidr_block" {
default = "10.0.0.0/28"
}

variable "private_endpoint_subnetwork" {
type = string
description = "The subnetwork to use for the hosted master network."
default = null
}

variable "master_global_access_enabled" {
type = bool
description = "Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint."
Expand Down
1 change: 1 addition & 0 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ Then perform the following commands on the root folder:
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | `list(string)` | <pre>[<br> "10.0.0.0/8",<br> "172.16.0.0/12",<br> "192.168.0.0/16"<br>]</pre> | no |
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
| notification\_filter\_event\_type | Choose what type of notifications you want to receive. If no filters are applied, you'll receive all notification types. Can be used to filter what notifications are sent. Accepted values are UPGRADE\_AVAILABLE\_EVENT, UPGRADE\_EVENT, and SECURITY\_BULLETIN\_EVENT. | `list(string)` | `[]` | no |
| private\_endpoint\_subnetwork | The subnetwork to use for the hosted master network. | `string` | `null` | no |
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |
| region | The region to host the cluster in (optional if zonal cluster / required if regional) | `string` | `null` | no |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | `bool` | `true` | no |
Expand Down
14 changes: 8 additions & 6 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,17 @@ resource "google_container_cluster" "primary" {

dynamic "private_cluster_config" {
for_each = var.enable_private_nodes ? [{
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
enable_private_nodes = var.enable_private_nodes,
enable_private_endpoint = var.enable_private_endpoint
master_ipv4_cidr_block = var.master_ipv4_cidr_block
private_endpoint_subnetwork = var.private_endpoint_subnetwork
}] : []

content {
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
enable_private_endpoint = private_cluster_config.value.enable_private_endpoint
enable_private_nodes = private_cluster_config.value.enable_private_nodes
master_ipv4_cidr_block = private_cluster_config.value.master_ipv4_cidr_block
private_endpoint_subnetwork = private_cluster_config.value.private_endpoint_subnetwork
dynamic "master_global_access_config" {
for_each = var.master_global_access_enabled ? [var.master_global_access_enabled] : []
content {
Expand Down
6 changes: 6 additions & 0 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ variable "master_ipv4_cidr_block" {
default = "10.0.0.0/28"
}

variable "private_endpoint_subnetwork" {
type = string
description = "The subnetwork to use for the hosted master network."
default = null
}

variable "master_global_access_enabled" {
type = bool
description = "Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint."
Expand Down

0 comments on commit 7a2e9b8

Please sign in to comment.