Skip to content

Commit 5f11c0f

Browse files
4.0 - Fully remove workload_metadata_config.node_metadata (#5346) (#10400)
Signed-off-by: Modular Magician <[email protected]>
1 parent c3e765b commit 5f11c0f

File tree

4 files changed

+7
-98
lines changed

4 files changed

+7
-98
lines changed

.changelog/5346.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:breaking-change
2+
container: removed `workload_metadata_configuration.node_metadata` in favor of `workload_metadata_configuration.mode` in `google_container_cluster`
3+
```

google/node_config.go

+2-18
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ func schemaNodeConfig() *schema.Schema {
231231
},
232232
},
233233

234-
// Note that ExactlyOneOf can't be set because this schema is reused by
235-
// two different resources.
236234
"workload_metadata_config": {
237235
Computed: true,
238236
Type: schema.TypeList,
@@ -241,18 +239,9 @@ func schemaNodeConfig() *schema.Schema {
241239
Description: `The workload metadata configuration for this node.`,
242240
Elem: &schema.Resource{
243241
Schema: map[string]*schema.Schema{
244-
"node_metadata": {
245-
Type: schema.TypeString,
246-
Optional: true,
247-
Computed: true,
248-
Deprecated: "Deprecated in favor of mode.",
249-
ValidateFunc: validation.StringInSlice([]string{"UNSPECIFIED", "SECURE", "EXPOSE", "GKE_METADATA_SERVER"}, false),
250-
Description: `NodeMetadata is the configuration for how to expose metadata to the workloads running on the node.`,
251-
},
252242
"mode": {
253243
Type: schema.TypeString,
254-
Optional: true,
255-
Computed: true,
244+
Required: true,
256245
ValidateFunc: validation.StringInSlice([]string{"MODE_UNSPECIFIED", "GCE_METADATA", "GKE_METADATA"}, false),
257246
Description: `Mode is the configuration for how to expose metadata to workloads running on the node.`,
258247
},
@@ -407,10 +396,6 @@ func expandWorkloadMetadataConfig(v interface{}) *containerBeta.WorkloadMetadata
407396
wmc.Mode = v.(string)
408397
}
409398

410-
if v, ok := cfg["node_metadata"]; ok {
411-
wmc.NodeMetadata = v.(string)
412-
}
413-
414399
return wmc
415400
}
416401

@@ -485,8 +470,7 @@ func flattenWorkloadMetadataConfig(c *containerBeta.WorkloadMetadataConfig) []ma
485470
result := []map[string]interface{}{}
486471
if c != nil {
487472
result = append(result, map[string]interface{}{
488-
"mode": c.Mode,
489-
"node_metadata": c.NodeMetadata,
473+
"mode": c.Mode,
490474
})
491475
}
492476
return result

google/resource_container_node_pool_test.go

-71
Original file line numberDiff line numberDiff line change
@@ -230,45 +230,6 @@ func TestAccContainerNodePool_withWorkloadIdentityConfig(t *testing.T) {
230230
})
231231
}
232232

233-
func TestAccContainerNodePool_withWorkloadIdentityConfigDeprecated(t *testing.T) {
234-
t.Parallel()
235-
236-
cluster := fmt.Sprintf("tf-test-cluster-%s", randString(t, 10))
237-
np := fmt.Sprintf("tf-test-np-%s", randString(t, 10))
238-
239-
vcrTest(t, resource.TestCase{
240-
PreCheck: func() { testAccPreCheck(t) },
241-
Providers: testAccProviders,
242-
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
243-
Steps: []resource.TestStep{
244-
{
245-
Config: testAccContainerNodePool_withWorkloadMetadataConfigNodeMetadata(cluster, np),
246-
Check: resource.ComposeTestCheckFunc(
247-
resource.TestCheckResourceAttr("google_container_node_pool.with_workload_metadata_config",
248-
"node_config.0.workload_metadata_config.0.node_metadata", "SECURE"),
249-
),
250-
},
251-
{
252-
ResourceName: "google_container_node_pool.with_workload_metadata_config",
253-
ImportState: true,
254-
ImportStateVerify: true,
255-
},
256-
{
257-
Config: testAccContainerNodePool_withWorkloadMetadataConfig(cluster, np),
258-
Check: resource.ComposeTestCheckFunc(
259-
resource.TestCheckResourceAttr("google_container_node_pool.with_workload_metadata_config",
260-
"node_config.0.workload_metadata_config.0.mode", "GCE_METADATA"),
261-
),
262-
},
263-
{
264-
ResourceName: "google_container_node_pool.with_workload_metadata_config",
265-
ImportState: true,
266-
ImportStateVerify: true,
267-
},
268-
},
269-
})
270-
}
271-
272233
func TestAccContainerNodePool_withUpgradeSettings(t *testing.T) {
273234
t.Parallel()
274235

@@ -1219,38 +1180,6 @@ resource "google_container_node_pool" "with_workload_metadata_config" {
12191180
`, cluster, np)
12201181
}
12211182

1222-
func testAccContainerNodePool_withWorkloadMetadataConfigNodeMetadata(cluster, np string) string {
1223-
return fmt.Sprintf(`
1224-
data "google_container_engine_versions" "central1a" {
1225-
location = "us-central1-a"
1226-
}
1227-
1228-
resource "google_container_cluster" "cluster" {
1229-
name = "%s"
1230-
location = "us-central1-a"
1231-
initial_node_count = 1
1232-
min_master_version = data.google_container_engine_versions.central1a.latest_master_version
1233-
}
1234-
1235-
resource "google_container_node_pool" "with_workload_metadata_config" {
1236-
name = "%s"
1237-
location = "us-central1-a"
1238-
cluster = google_container_cluster.cluster.name
1239-
initial_node_count = 1
1240-
node_config {
1241-
oauth_scopes = [
1242-
"https://www.googleapis.com/auth/logging.write",
1243-
"https://www.googleapis.com/auth/monitoring",
1244-
]
1245-
1246-
workload_metadata_config {
1247-
node_metadata = "SECURE"
1248-
}
1249-
}
1250-
}
1251-
`, cluster, np)
1252-
}
1253-
12541183
func testAccContainerNodePool_withWorkloadMetadataConfig_gkeMetadata(projectID, cluster, np string) string {
12551184
return fmt.Sprintf(`
12561185
data "google_project" "project" {

website/docs/r/container_cluster.html.markdown

+2-9
Original file line numberDiff line numberDiff line change
@@ -877,16 +877,9 @@ Enables monitoring and attestation of the boot integrity of the instance. The at
877877

878878
* `effect` (Required) Effect for taint. Accepted values are `NO_SCHEDULE`, `PREFER_NO_SCHEDULE`, and `NO_EXECUTE`.
879879

880-
<a name="nested_workload_metadata_config"></a>The `workload_metadata_config` must have exactly one of `node_metadata` (deprecated) or `mode` set. This block supports:
880+
<a name="nested_workload_metadata_config"></a>The `workload_metadata_config` block supports:
881881

882-
* `node_metadata` (Optional, Deprecated) How to expose the node metadata to the workload running on the node. This is deprecated in favor of `mode`
883-
Accepted values are:
884-
* UNSPECIFIED: Not Set
885-
* SECURE: Prevent workloads not in hostNetwork from accessing certain VM metadata, specifically kube-env, which contains Kubelet credentials, and the instance identity token. See [Metadata Concealment](https://cloud.google.com/kubernetes-engine/docs/how-to/metadata-proxy) documentation.
886-
* EXPOSE: Expose all VM metadata to pods.
887-
* GKE_METADATA_SERVER: Enables [workload identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) on the node.
888-
889-
* `mode` (Optional) How to expose the node metadata to the workload running on the node.
882+
* `mode` (Required) How to expose the node metadata to the workload running on the node.
890883
Accepted values are:
891884
* UNSPECIFIED: Not Set
892885
* GCE_METADATA: Expose all Compute Engine metadata to pods.

0 commit comments

Comments
 (0)