Skip to content

Commit 116da0f

Browse files
committed
Restrict node access to cluster metadata service
1 parent 1d64f99 commit 116da0f

File tree

11 files changed

+56
-0
lines changed

11 files changed

+56
-0
lines changed

autogen/cluster_regional.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ resource "google_container_cluster" "primary" {
106106

107107
node_config {
108108
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
109+
{% if beta_cluster %}
110+
workload_metadata_config {
111+
node_metadata = "${var.node_metadata}"
112+
}
113+
{% endif %}
109114
}
110115
}
111116
{% if private_cluster %}
@@ -168,6 +173,12 @@ resource "google_container_node_pool" "pools" {
168173
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
169174
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
170175
}
176+
{% if beta_cluster %}
177+
178+
workload_metadata_config {
179+
node_metadata = "${var.node_metadata}"
180+
}
181+
{% endif %}
171182
}
172183

173184
lifecycle {

autogen/cluster_zonal.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ resource "google_container_node_pool" "zonal_pools" {
169169
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
170170
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
171171
}
172+
{% if beta_cluster %}
173+
174+
workload_metadata_config {
175+
node_metadata = "${var.node_metadata}"
176+
}
177+
{% endif %}
172178
}
173179

174180
lifecycle {

autogen/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ variable "pod_security_policy_config" {
300300
"enabled" = false
301301
}]
302302
}
303+
304+
variable "node_metadata" {
305+
description = "Specifies how node metadata is exposed to the workload running on the node"
306+
default = "UNSPECIFIED"
307+
}
303308
{% endif %}
304309

305310
variable "basic_auth_username" {

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
154154
| network\_policy | Enable network policy addon | string | `"false"` | no |
155155
| network\_policy\_provider | The network policy provider. | string | `"CALICO"` | no |
156156
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | string | `""` | no |
157+
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | string | `"UNSPECIFIED"` | no |
157158
| node\_pools | List of maps containing node pools | list | `<list>` | no |
158159
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
159160
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map | `<map>` | no |

modules/beta-private-cluster/cluster_regional.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ resource "google_container_cluster" "primary" {
102102

103103
node_config {
104104
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
105+
workload_metadata_config {
106+
node_metadata = "${var.node_metadata}"
107+
}
105108
}
106109
}
107110

@@ -160,6 +163,10 @@ resource "google_container_node_pool" "pools" {
160163
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
161164
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
162165
}
166+
167+
workload_metadata_config {
168+
node_metadata = "${var.node_metadata}"
169+
}
163170
}
164171

165172
lifecycle {

modules/beta-private-cluster/cluster_zonal.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ resource "google_container_node_pool" "zonal_pools" {
161161
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
162162
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
163163
}
164+
165+
workload_metadata_config {
166+
node_metadata = "${var.node_metadata}"
167+
}
164168
}
165169

166170
lifecycle {

modules/beta-private-cluster/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ variable "pod_security_policy_config" {
302302
}]
303303
}
304304

305+
variable "node_metadata" {
306+
description = "Specifies how node metadata is exposed to the workload running on the node"
307+
default = "UNSPECIFIED"
308+
}
309+
305310
variable "basic_auth_username" {
306311
description = "The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration."
307312
default = ""

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
145145
| network\_policy | Enable network policy addon | string | `"false"` | no |
146146
| network\_policy\_provider | The network policy provider. | string | `"CALICO"` | no |
147147
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | string | `""` | no |
148+
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | string | `"UNSPECIFIED"` | no |
148149
| node\_pools | List of maps containing node pools | list | `<list>` | no |
149150
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
150151
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map | `<map>` | no |

modules/beta-public-cluster/cluster_regional.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ resource "google_container_cluster" "primary" {
102102

103103
node_config {
104104
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
105+
workload_metadata_config {
106+
node_metadata = "${var.node_metadata}"
107+
}
105108
}
106109
}
107110

@@ -154,6 +157,10 @@ resource "google_container_node_pool" "pools" {
154157
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
155158
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
156159
}
160+
161+
workload_metadata_config {
162+
node_metadata = "${var.node_metadata}"
163+
}
157164
}
158165

159166
lifecycle {

modules/beta-public-cluster/cluster_zonal.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ resource "google_container_node_pool" "zonal_pools" {
155155
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
156156
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
157157
}
158+
159+
workload_metadata_config {
160+
node_metadata = "${var.node_metadata}"
161+
}
158162
}
159163

160164
lifecycle {

0 commit comments

Comments
 (0)