diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl
index 9fd3f210a2a1..b697441ba5b9 100644
--- a/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl
+++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool.go.tmpl
@@ -690,7 +690,41 @@ var schemaNodePool = map[string]*schema.Schema{
},
},
},
-
+
+ "maintenance_policy": {
+ Type: schema.TypeList,
+ Optional: true,
+ Description: `Maintenance policy for this NodePool.`,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "exclusion_until_end_of_support": {
+ Type: schema.TypeList,
+ Optional: true,
+ Description: `Maintenance exclusion until the end of support.`,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "enabled": {
+ Type: schema.TypeBool,
+ Optional: true,
+ Description: `Whether to enable the maintenance exclusion until the end of support for this NodePool.`,
+ },
+ "start_time": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `Start time of the maintenance exclusion.`,
+ },
+ "end_time": {
+ Type: schema.TypeString,
+ Computed: true,
+ Description: `End time of the maintenance exclusion.`,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+
}
type NodePoolInformation struct {
@@ -1311,6 +1345,19 @@ func expandNodePool(d *schema.ResourceData, prefix string) (*container.NodePool,
}
}
+ if v, ok := d.GetOk(prefix + "maintenance_policy"); ok {
+ maintenancePolicy := v.([]interface{})[0].(map[string]interface{})
+ if v, ok := maintenancePolicy["exclusion_until_end_of_support"]; ok && len(v.([]interface{})) > 0 {
+ np.MaintenancePolicy = &container.NodePoolMaintenancePolicy{
+ ExclusionUntilEndOfSupport: &container.ExclusionUntilEndOfSupport {},
+ }
+ exclusionUntilEndOfSupport := v.([]interface{})[0].(map[string]interface{})
+ if v, ok := exclusionUntilEndOfSupport["enabled"]; ok {
+ np.ExclusionUntilEndOfSupport.Enabled = v.(bool)
+ }
+ }
+ }
+
return np, nil
}
@@ -1383,6 +1430,30 @@ func flattenNodePoolNodeDrainConfig(ndc *container.NodeDrainConfig) []map[string
return []map[string]interface{}{nodeDrainConfig}
}
+func flattenExlusionUntilEndOfSupport(ex *container.ExclusionUntilEndOfSupport) []map[string]interface{} {
+ if ex == nil {
+ return nil
+ }
+ return []map[string]interface{}{
+ {
+ "enabled": ex.Enabled,
+ "start_time": ex.StartTime,
+ "end_time": ex.EndTime,
+ },
+ }
+}
+
+func flattenNodePoolMaintenancePolicy(mp *container.NodePoolMaintenancePolicy) []map[string]interface{} {
+ if mp == nil {
+ return nil
+ }
+
+ maintenancePolicy := make(map[string]interface{})
+
+ maintenancePolicy["exclusion_until_end_of_support"] = flattenExlusionUntilEndOfSupport(mp.ExclusionUntilEndOfSupport)
+ return []map[string]interface{}{maintenancePolicy}
+}
+
func flattenNodePool(d *schema.ResourceData, config *transport_tpg.Config, np *container.NodePool, prefix string) (map[string]interface{}, error) {
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
if err != nil {
@@ -1491,6 +1562,10 @@ func flattenNodePool(d *schema.ResourceData, config *transport_tpg.Config, np *c
nodePool["node_drain_config"] = flattenNodePoolNodeDrainConfig(np.NodeDrainConfig)
}
+ if np.MaintenancePolicy != nil {
+ nodePool["maintenance_policy"] = flattenNodePoolMaintenancePolicy(np.MaintenancePolicy)
+ }
+
return nodePool, nil
}
diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl b/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl
index d64e4d95ef91..df2766398b4e 100644
--- a/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl
+++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl
@@ -313,6 +313,7 @@ fields:
- field: 'node_config.workload_metadata_config.mode'
api_field: 'config.workloadMetadataConfig.mode'
- api_field: 'nodeDrainConfig.respectPdbDuringNodePoolDeletion'
+ - api_field: 'maintenancePolicy.exclusionUntilEndOfSupport.enabled'
- field: 'node_count'
provider_only: true
- field: 'node_locations'
diff --git a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.tmpl
index 9bdfacbdeb26..f947a3391b7f 100644
--- a/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.tmpl
+++ b/mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.tmpl
@@ -1626,6 +1626,34 @@ func TestAccContainerNodePool_withNodeDrainConfig(t *testing.T) {
})
}
+func TestAccContainerNodePool_withMaintenancePolicy(t *testing.T) {
+ t.Parallel()
+
+ cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
+ nodePool := fmt.Sprintf("tf-test-nodepool-%s", acctest.RandString(t, 10))
+ networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
+ subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
+
+ acctest.VcrTest(t, resource.TestCase{
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
+ CheckDestroy: testAccCheckContainerNodePoolDestroyProducer(t),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccContainerNodePool_withMaintenancePolicy(cluster, nodePool, networkName, subnetworkName),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("google_container_node_pool.np_with_maintenance_policy", "maintenance_policy.0.exclusion_until_end_of_support.0.enabled", "true"),
+ ),
+ },
+ {
+ ResourceName: "google_container_node_pool.np_with_maintenance_policy",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
+
func TestAccContainerNodePool_withNodeConfigScopeAlias(t *testing.T) {
t.Parallel()
@@ -4721,6 +4749,36 @@ resource "google_container_node_pool" "np_with_node_drain_config" {
`, cluster, networkName, subnetworkName, np)
}
+func testAccContainerNodePool_withMaintenancePolicy(cluster, np, networkName, subnetworkName string) string {
+ return fmt.Sprintf(`
+data "google_container_engine_versions" "central1a" {
+ location = "us-central1-a"
+}
+
+resource "google_container_cluster" "cluster" {
+ name = "%s"
+ location = "us-central1-a"
+ initial_node_count = 1
+ min_master_version = data.google_container_engine_versions.central1a.latest_master_version
+ deletion_protection = false
+ network = "%s"
+ subnetwork = "%s"
+}
+
+resource "google_container_node_pool" "np_with_maintenance_policy" {
+ name = "%s"
+ location = "us-central1-a"
+ cluster = google_container_cluster.cluster.name
+ initial_node_count = 1
+ maintenance_policy {
+ exclusion_until_end_of_support {
+ enabled = true
+ }
+ }
+}
+`, cluster, networkName, subnetworkName, np)
+}
+
func testAccContainerNodePool_version(cluster, np, networkName, subnetworkName string) string {
return fmt.Sprintf(`
data "google_container_engine_versions" "central1a" {
diff --git a/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown
index fcbabbf63a14..9201f30ef7bc 100644
--- a/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown
+++ b/mmv1/third_party/terraform/website/docs/r/container_node_pool.html.markdown
@@ -156,6 +156,8 @@ cluster.
* `node_drain_config` - (Optional) The node drain configuration of the pool. Structure is [documented below](#nested_node_drain_config).
+* `maintenance_policy` - (Optional) The maintenance policy of the pool. Structure is [documented below](#nested_maintenance_policy).
+
* `project` - (Optional) The ID of the project in which to create the node pool. If blank,
the provider-configured project will be used.
@@ -253,6 +255,10 @@ cluster.
* `respect_pdb_during_node_pool_deletion` - (Optional) Whether to respect PodDisruptionBudget policy during node pool deletion.
+The `maintenance_policy` block supports:
+
+* `exclusion_until_end_of_support` - (Optional) When enabled, the node pool will not be automatically upgraded by GKE until the node pool version's end of support date.
+
The `upgrade_settings` block supports:
* `max_surge` - (Optional) The number of additional nodes that can be added to the node pool during