Skip to content

Commit a8ea7c7

Browse files
feat: expose disable_default_snat in GA modules (#1336)
* fix: added snat code * fix: updated readme * fix: added snat variable * fix: whitespaces * fix readmebuild * fix: removed conditional beta code * removed beta variable * fix readme Co-authored-by: Andrew Peabody <[email protected]>
1 parent bfb5954 commit a8ea7c7

File tree

17 files changed

+41
-3
lines changed

17 files changed

+41
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Then perform the following commands on the root folder:
144144
| datapath\_provider | The desired datapath provider for this cluster. By default, `DATAPATH_PROVIDER_UNSPECIFIED` enables the IPTables-based kube-proxy implementation. `ADVANCED_DATAPATH` enables Dataplane-V2 feature. | `string` | `"DATAPATH_PROVIDER_UNSPECIFIED"` | no |
145145
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | `number` | `110` | no |
146146
| description | The description of the cluster | `string` | `""` | no |
147+
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |
147148
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | `bool` | `true` | no |
148149
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
149150
| enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | `bool` | `false` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ resource "google_container_cluster" "primary" {
6464

6565
subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"
6666

67-
{% if beta_cluster %}
6867
default_snat_status {
6968
disabled = var.disable_default_snat
7069
}
71-
{% endif %}
70+
7271
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
7372

7473
{% if beta_cluster and autopilot_cluster != true %}

autogen/main/variables.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,13 @@ variable "enable_confidential_nodes" {
474474
description = "An optional flag to enable confidential node config."
475475
default = false
476476
}
477+
{% endif %}
477478

478479
variable "disable_default_snat" {
479480
type = bool
480481
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
481482
default = false
482483
}
483-
{% endif %}
484484

485485
{% if beta_cluster %}
486486
variable "notification_config_topic" {

cluster.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ resource "google_container_cluster" "primary" {
5050

5151
subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"
5252

53+
default_snat_status {
54+
disabled = var.disable_default_snat
55+
}
56+
5357
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
5458

5559
logging_service = var.logging_service

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ resource "google_container_cluster" "primary" {
5151
default_snat_status {
5252
disabled = var.disable_default_snat
5353
}
54+
5455
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
5556

5657
logging_service = var.logging_service

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ resource "google_container_cluster" "primary" {
5151
default_snat_status {
5252
disabled = var.disable_default_snat
5353
}
54+
5455
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
5556

5657
logging_service = var.logging_service

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ resource "google_container_cluster" "primary" {
5959
default_snat_status {
6060
disabled = var.disable_default_snat
6161
}
62+
6263
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
6364

6465
dynamic "cluster_telemetry" {

modules/beta-private-cluster/cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ resource "google_container_cluster" "primary" {
5959
default_snat_status {
6060
disabled = var.disable_default_snat
6161
}
62+
6263
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
6364

6465
dynamic "cluster_telemetry" {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ resource "google_container_cluster" "primary" {
5959
default_snat_status {
6060
disabled = var.disable_default_snat
6161
}
62+
6263
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
6364

6465
dynamic "cluster_telemetry" {

modules/beta-public-cluster/cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ resource "google_container_cluster" "primary" {
5959
default_snat_status {
6060
disabled = var.disable_default_snat
6161
}
62+
6263
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
6364

6465
dynamic "cluster_telemetry" {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ Then perform the following commands on the root folder:
173173
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | `number` | `110` | no |
174174
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | `bool` | `false` | no |
175175
| description | The description of the cluster | `string` | `""` | no |
176+
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |
176177
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | `bool` | `true` | no |
177178
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
178179
| enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | `bool` | `false` | no |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ resource "google_container_cluster" "primary" {
5050

5151
subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"
5252

53+
default_snat_status {
54+
disabled = var.disable_default_snat
55+
}
56+
5357
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
5458

5559
logging_service = var.logging_service

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ variable "shadow_firewall_rules_priority" {
415415
}
416416

417417

418+
variable "disable_default_snat" {
419+
type = bool
420+
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
421+
default = false
422+
}
423+
418424
variable "network_policy" {
419425
type = bool
420426
description = "Enable network policy addon"

modules/private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Then perform the following commands on the root folder:
151151
| default\_max\_pods\_per\_node | The maximum number of pods to schedule per node | `number` | `110` | no |
152152
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | `bool` | `false` | no |
153153
| description | The description of the cluster | `string` | `""` | no |
154+
| disable\_default\_snat | Whether to disable the default SNAT to support the private use of public IP addresses | `bool` | `false` | no |
154155
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | `bool` | `true` | no |
155156
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
156157
| enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | `bool` | `false` | no |

modules/private-cluster/cluster.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ resource "google_container_cluster" "primary" {
5050

5151
subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"
5252

53+
default_snat_status {
54+
disabled = var.disable_default_snat
55+
}
56+
5357
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : null
5458

5559
logging_service = var.logging_service

modules/private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ variable "shadow_firewall_rules_priority" {
415415
}
416416

417417

418+
variable "disable_default_snat" {
419+
type = bool
420+
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
421+
default = false
422+
}
423+
418424
variable "network_policy" {
419425
type = bool
420426
description = "Enable network policy addon"

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ variable "shadow_firewall_rules_priority" {
391391
}
392392

393393

394+
variable "disable_default_snat" {
395+
type = bool
396+
description = "Whether to disable the default SNAT to support the private use of public IP addresses"
397+
default = false
398+
}
399+
394400
variable "network_policy" {
395401
type = bool
396402
description = "Enable network policy addon"

0 commit comments

Comments
 (0)