Skip to content

Commit f864e8a

Browse files
authored
feat: network tags for autoprovisioned node pools (#1920)
1 parent 165446c commit f864e8a

File tree

29 files changed

+133
-7
lines changed

29 files changed

+133
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Then perform the following commands on the root folder:
200200
| network\_policy | Enable network policy addon | `bool` | `false` | no |
201201
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
202202
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
203+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
203204
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
204205
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
205206
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

autogen/main/cluster.tf.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,17 @@ resource "google_container_cluster" "primary" {
239239
}
240240
{% endif %}
241241

242+
{% if autopilot_cluster != true %}
243+
dynamic "node_pool_auto_config" {
244+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
245+
content {
246+
network_tags {
247+
tags = var.network_tags
248+
}
249+
}
250+
}
251+
{% endif %}
252+
242253
master_auth {
243254
client_certificate_config {
244255
issue_client_certificate = var.issue_client_certificate

autogen/main/variables.tf.tmpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,12 @@ variable "node_pools_oauth_scopes" {
306306
}
307307
{% endif %}
308308

309-
{% if autopilot_cluster %}
310309
variable "network_tags" {
311-
description = "(Optional, Beta) - List of network tags applied to auto-provisioned node pools."
310+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
312311
type = list(string)
313312
default = []
314313
}
315-
{% endif %}
314+
316315
variable "stub_domains" {
317316
type = map(list(string))
318317
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

cluster.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ resource "google_container_cluster" "primary" {
160160
}
161161
}
162162

163+
dynamic "node_pool_auto_config" {
164+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
165+
content {
166+
network_tags {
167+
tags = var.network_tags
168+
}
169+
}
170+
}
171+
163172
master_auth {
164173
client_certificate_config {
165174
issue_client_certificate = var.issue_client_certificate

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Then perform the following commands on the root folder:
121121
| name | The name of the cluster (required) | `string` | n/a | yes |
122122
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |
123123
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
124-
| network\_tags | (Optional, Beta) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
124+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
125125
| 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 |
126126
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
127127
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ resource "google_container_cluster" "primary" {
107107
}
108108
}
109109

110+
110111
master_auth {
111112
client_certificate_config {
112113
issue_client_certificate = var.issue_client_certificate

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ variable "enable_resource_consumption_export" {
174174

175175

176176
variable "network_tags" {
177-
description = "(Optional, Beta) - List of network tags applied to auto-provisioned node pools."
177+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
178178
type = list(string)
179179
default = []
180180
}
181+
181182
variable "stub_domains" {
182183
type = map(list(string))
183184
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Then perform the following commands on the root folder:
110110
| name | The name of the cluster (required) | `string` | n/a | yes |
111111
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |
112112
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
113-
| network\_tags | (Optional, Beta) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
113+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
114114
| 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 |
115115
| notification\_config\_topic | The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}. | `string` | `""` | no |
116116
| project\_id | The project ID to host the cluster in (required) | `string` | n/a | yes |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ resource "google_container_cluster" "primary" {
107107
}
108108
}
109109

110+
110111
master_auth {
111112
client_certificate_config {
112113
issue_client_certificate = var.issue_client_certificate

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ variable "enable_resource_consumption_export" {
174174

175175

176176
variable "network_tags" {
177-
description = "(Optional, Beta) - List of network tags applied to auto-provisioned node pools."
177+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
178178
type = list(string)
179179
default = []
180180
}
181+
181182
variable "stub_domains" {
182183
type = map(list(string))
183184
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ Then perform the following commands on the root folder:
250250
| network\_policy | Enable network policy addon | `bool` | `false` | no |
251251
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
252252
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
253+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
253254
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
254255
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
255256
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ resource "google_container_cluster" "primary" {
185185
}
186186
}
187187

188+
dynamic "node_pool_auto_config" {
189+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
190+
content {
191+
network_tags {
192+
tags = var.network_tags
193+
}
194+
}
195+
}
196+
188197
master_auth {
189198
client_certificate_config {
190199
issue_client_certificate = var.issue_client_certificate

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ variable "node_pools_oauth_scopes" {
300300
}
301301
}
302302

303+
variable "network_tags" {
304+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
305+
type = list(string)
306+
default = []
307+
}
308+
303309
variable "stub_domains" {
304310
type = map(list(string))
305311
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ Then perform the following commands on the root folder:
228228
| network\_policy | Enable network policy addon | `bool` | `false` | no |
229229
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
230230
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
231+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
231232
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
232233
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
233234
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

modules/beta-private-cluster/cluster.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ resource "google_container_cluster" "primary" {
185185
}
186186
}
187187

188+
dynamic "node_pool_auto_config" {
189+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
190+
content {
191+
network_tags {
192+
tags = var.network_tags
193+
}
194+
}
195+
}
196+
188197
master_auth {
189198
client_certificate_config {
190199
issue_client_certificate = var.issue_client_certificate

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ variable "node_pools_oauth_scopes" {
300300
}
301301
}
302302

303+
variable "network_tags" {
304+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
305+
type = list(string)
306+
default = []
307+
}
308+
303309
variable "stub_domains" {
304310
type = map(list(string))
305311
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

modules/beta-public-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ Then perform the following commands on the root folder:
239239
| network\_policy | Enable network policy addon | `bool` | `false` | no |
240240
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
241241
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
242+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
242243
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
243244
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
244245
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ resource "google_container_cluster" "primary" {
185185
}
186186
}
187187

188+
dynamic "node_pool_auto_config" {
189+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
190+
content {
191+
network_tags {
192+
tags = var.network_tags
193+
}
194+
}
195+
}
196+
188197
master_auth {
189198
client_certificate_config {
190199
issue_client_certificate = var.issue_client_certificate

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ variable "node_pools_oauth_scopes" {
300300
}
301301
}
302302

303+
variable "network_tags" {
304+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
305+
type = list(string)
306+
default = []
307+
}
308+
303309
variable "stub_domains" {
304310
type = map(list(string))
305311
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ Then perform the following commands on the root folder:
217217
| network\_policy | Enable network policy addon | `bool` | `false` | no |
218218
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
219219
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
220+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
220221
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
221222
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
222223
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

modules/beta-public-cluster/cluster.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ resource "google_container_cluster" "primary" {
185185
}
186186
}
187187

188+
dynamic "node_pool_auto_config" {
189+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
190+
content {
191+
network_tags {
192+
tags = var.network_tags
193+
}
194+
}
195+
}
196+
188197
master_auth {
189198
client_certificate_config {
190199
issue_client_certificate = var.issue_client_certificate

modules/beta-public-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ variable "node_pools_oauth_scopes" {
300300
}
301301
}
302302

303+
variable "network_tags" {
304+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
305+
type = list(string)
306+
default = []
307+
}
308+
303309
variable "stub_domains" {
304310
type = map(list(string))
305311
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ Then perform the following commands on the root folder:
233233
| network\_policy | Enable network policy addon | `bool` | `false` | no |
234234
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
235235
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
236+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
236237
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
237238
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
238239
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ resource "google_container_cluster" "primary" {
160160
}
161161
}
162162

163+
dynamic "node_pool_auto_config" {
164+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
165+
content {
166+
network_tags {
167+
tags = var.network_tags
168+
}
169+
}
170+
}
171+
163172
master_auth {
164173
client_certificate_config {
165174
issue_client_certificate = var.issue_client_certificate

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ variable "node_pools_oauth_scopes" {
300300
}
301301
}
302302

303+
variable "network_tags" {
304+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
305+
type = list(string)
306+
default = []
307+
}
308+
303309
variable "stub_domains" {
304310
type = map(list(string))
305311
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

modules/private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ Then perform the following commands on the root folder:
211211
| network\_policy | Enable network policy addon | `bool` | `false` | no |
212212
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
213213
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
214+
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
214215
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
215216
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
216217
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

modules/private-cluster/cluster.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ resource "google_container_cluster" "primary" {
160160
}
161161
}
162162

163+
dynamic "node_pool_auto_config" {
164+
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
165+
content {
166+
network_tags {
167+
tags = var.network_tags
168+
}
169+
}
170+
}
171+
163172
master_auth {
164173
client_certificate_config {
165174
issue_client_certificate = var.issue_client_certificate

modules/private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ variable "node_pools_oauth_scopes" {
300300
}
301301
}
302302

303+
variable "network_tags" {
304+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
305+
type = list(string)
306+
default = []
307+
}
308+
303309
variable "stub_domains" {
304310
type = map(list(string))
305311
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ variable "node_pools_oauth_scopes" {
300300
}
301301
}
302302

303+
variable "network_tags" {
304+
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
305+
type = list(string)
306+
default = []
307+
}
308+
303309
variable "stub_domains" {
304310
type = map(list(string))
305311
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"

0 commit comments

Comments
 (0)