Skip to content

Commit 2f412bb

Browse files
laurentgrangeauLaurent Grangeauapeabody
authored
feat: add a flag to allow access through Google Cloud public IP addresses (#2078)
Co-authored-by: Laurent Grangeau <[email protected]> Co-authored-by: Andrew Peabody <[email protected]>
1 parent caa194f commit 2f412bb

File tree

30 files changed

+90
-10
lines changed

30 files changed

+90
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Then perform the following commands on the root folder:
182182
| fleet\_project | (Optional) Register the cluster with the fleet in this project. | `string` | `null` | no |
183183
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | `null` | no |
184184
| gce\_pd\_csi\_driver | Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | `bool` | `true` | no |
185+
| gcp\_public\_cidrs\_access\_enabled | Allow access through Google Cloud public IP addresses | `bool` | `null` | no |
185186
| gcs\_fuse\_csi\_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | `bool` | `false` | no |
186187
| gke\_backup\_agent\_config | Whether Backup for GKE agent is enabled for this cluster. | `bool` | `false` | no |
187188
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ resource "google_container_cluster" "primary" {
257257
enable_autopilot = true
258258
{% endif %}
259259
dynamic "master_authorized_networks_config" {
260-
for_each = {% if private_cluster %}var.enable_private_endpoint || {% endif %}length(var.master_authorized_networks) > 0 ? [true] : []
260+
for_each = {% if private_cluster %}var.enable_private_endpoint || {% endif %}var.gcp_public_cidrs_access_enabled != null || length(var.master_authorized_networks) > 0 ? [true] : []
261261
content {
262+
gcp_public_cidrs_access_enabled = var.gcp_public_cidrs_access_enabled
262263
dynamic "cidr_blocks" {
263264
for_each = var.master_authorized_networks
264265
content {

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ variable "master_authorized_networks" {
7878
default = []
7979
}
8080

81+
variable "gcp_public_cidrs_access_enabled" {
82+
type = bool
83+
description = "Allow access through Google Cloud public IP addresses"
84+
default = null
85+
}
86+
8187
variable "enable_vertical_pod_autoscaling" {
8288
type = bool
8389
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"

cluster.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ resource "google_container_cluster" "primary" {
190190
enable_cilium_clusterwide_network_policy = var.enable_cilium_clusterwide_network_policy
191191

192192
dynamic "master_authorized_networks_config" {
193-
for_each = length(var.master_authorized_networks) > 0 ? [true] : []
193+
for_each = var.gcp_public_cidrs_access_enabled != null || length(var.master_authorized_networks) > 0 ? [true] : []
194194
content {
195+
gcp_public_cidrs_access_enabled = var.gcp_public_cidrs_access_enabled
195196
dynamic "cidr_blocks" {
196197
for_each = var.master_authorized_networks
197198
content {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Then perform the following commands on the root folder:
107107
| fleet\_project | (Optional) Register the cluster with the fleet in this project. | `string` | `null` | no |
108108
| fleet\_project\_grant\_service\_agent | (Optional) Grant the fleet project service identity the `roles/gkehub.serviceAgent` and `roles/gkehub.crossProjectServiceAgent` roles. | `bool` | `false` | no |
109109
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | `null` | no |
110+
| gcp\_public\_cidrs\_access\_enabled | Allow access through Google Cloud public IP addresses | `bool` | `null` | no |
110111
| gcs\_fuse\_csi\_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | `bool` | `false` | no |
111112
| gke\_backup\_agent\_config | Whether Backup for GKE agent is enabled for this cluster. | `bool` | `false` | no |
112113
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ resource "google_container_cluster" "primary" {
106106
enable_fqdn_network_policy = var.enable_fqdn_network_policy
107107
enable_autopilot = true
108108
dynamic "master_authorized_networks_config" {
109-
for_each = var.enable_private_endpoint || length(var.master_authorized_networks) > 0 ? [true] : []
109+
for_each = var.enable_private_endpoint || var.gcp_public_cidrs_access_enabled != null || length(var.master_authorized_networks) > 0 ? [true] : []
110110
content {
111+
gcp_public_cidrs_access_enabled = var.gcp_public_cidrs_access_enabled
111112
dynamic "cidr_blocks" {
112113
for_each = var.master_authorized_networks
113114
content {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ variable "master_authorized_networks" {
7878
default = []
7979
}
8080

81+
variable "gcp_public_cidrs_access_enabled" {
82+
type = bool
83+
description = "Allow access through Google Cloud public IP addresses"
84+
default = null
85+
}
86+
8187
variable "enable_vertical_pod_autoscaling" {
8288
type = bool
8389
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Then perform the following commands on the root folder:
9898
| fleet\_project | (Optional) Register the cluster with the fleet in this project. | `string` | `null` | no |
9999
| fleet\_project\_grant\_service\_agent | (Optional) Grant the fleet project service identity the `roles/gkehub.serviceAgent` and `roles/gkehub.crossProjectServiceAgent` roles. | `bool` | `false` | no |
100100
| gateway\_api\_channel | The gateway api channel of this cluster. Accepted values are `CHANNEL_STANDARD` and `CHANNEL_DISABLED`. | `string` | `null` | no |
101+
| gcp\_public\_cidrs\_access\_enabled | Allow access through Google Cloud public IP addresses | `bool` | `null` | no |
101102
| gcs\_fuse\_csi\_driver | Whether GCE FUSE CSI driver is enabled for this cluster. | `bool` | `false` | no |
102103
| gke\_backup\_agent\_config | Whether Backup for GKE agent is enabled for this cluster. | `bool` | `false` | no |
103104
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer and artifactregistry.reader roles. | `bool` | `false` | no |

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ resource "google_container_cluster" "primary" {
106106
enable_fqdn_network_policy = var.enable_fqdn_network_policy
107107
enable_autopilot = true
108108
dynamic "master_authorized_networks_config" {
109-
for_each = length(var.master_authorized_networks) > 0 ? [true] : []
109+
for_each = var.gcp_public_cidrs_access_enabled != null || length(var.master_authorized_networks) > 0 ? [true] : []
110110
content {
111+
gcp_public_cidrs_access_enabled = var.gcp_public_cidrs_access_enabled
111112
dynamic "cidr_blocks" {
112113
for_each = var.master_authorized_networks
113114
content {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ variable "master_authorized_networks" {
7878
default = []
7979
}
8080

81+
variable "gcp_public_cidrs_access_enabled" {
82+
type = bool
83+
description = "Allow access through Google Cloud public IP addresses"
84+
default = null
85+
}
86+
8187
variable "enable_vertical_pod_autoscaling" {
8288
type = bool
8389
description = "Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it"

0 commit comments

Comments
 (0)