diff --git a/mmv1/third_party/terraform/services/container/node_config.go.tmpl b/mmv1/third_party/terraform/services/container/node_config.go.tmpl index d1d218fcc13b..8892bfba189b 100644 --- a/mmv1/third_party/terraform/services/container/node_config.go.tmpl +++ b/mmv1/third_party/terraform/services/container/node_config.go.tmpl @@ -861,6 +861,18 @@ func schemaNodeConfig() *schema.Schema { Optional: true, Description: `Defines the maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met.`, }, + "shutdown_grace_period_seconds": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntInSlice([]int{0, 30, 120}), + Description: `Total duration in seconds that the node delays shutting down in order to gracefully terminate Pods. Only valid for Spot VMs. Allowed values: 0, 30, 120. Set to 0 to disable graceful node shutdown.`, + }, + "shutdown_grace_period_critical_pods_seconds": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(0, 120), + Description: `Duration in seconds (0-120) reserved for terminating critical pods during graceful node shutdown. Only valid for Spot VMs, and only meaningful when shutdown_grace_period_seconds is set. Must be less than or equal to shutdown_grace_period_seconds.`, + }, "eviction_soft": { Type: schema.TypeList, Optional: true, @@ -1990,6 +2002,12 @@ func expandKubeletConfig(v interface{}) *container.NodeKubeletConfig { if evictionMaxPodGracePeriodSeconds, ok := cfg["eviction_max_pod_grace_period_seconds"]; ok { kConfig.EvictionMaxPodGracePeriodSeconds = int64(evictionMaxPodGracePeriodSeconds.(int)) } + if shutdownGracePeriodSeconds, ok := cfg["shutdown_grace_period_seconds"]; ok { + kConfig.ShutdownGracePeriodSeconds = int64(shutdownGracePeriodSeconds.(int)) + } + if shutdownGracePeriodCriticalPodsSeconds, ok := cfg["shutdown_grace_period_critical_pods_seconds"]; ok { + kConfig.ShutdownGracePeriodCriticalPodsSeconds = int64(shutdownGracePeriodCriticalPodsSeconds.(int)) + } if v, ok := cfg["eviction_soft"]; ok && len(v.([]interface{})) > 0 { es := v.([]interface{})[0].(map[string]interface{}) evictionSoft := &container.EvictionSignals{} @@ -3170,6 +3188,8 @@ func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface "single_process_oom_kill": c.SingleProcessOomKill, "max_parallel_image_pulls": c.MaxParallelImagePulls, "eviction_max_pod_grace_period_seconds": c.EvictionMaxPodGracePeriodSeconds, + "shutdown_grace_period_seconds": c.ShutdownGracePeriodSeconds, + "shutdown_grace_period_critical_pods_seconds": c.ShutdownGracePeriodCriticalPodsSeconds, "eviction_soft": flattenEvictionSignals(c.EvictionSoft), "eviction_soft_grace_period": flattenEvictionGracePeriod(c.EvictionSoftGracePeriod), "eviction_minimum_reclaim": flattenEvictionMinimumReclaim(c.EvictionMinimumReclaim), 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 c38aa7663a12..d4a7aed6d753 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 @@ -915,7 +915,11 @@ func TestAccContainerNodePool_withKubeletConfig(t *testing.T) { resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config", "node_config.0.kubelet_config.0.topology_manager.0.policy", "best-effort"), resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config", - "node_config.0.kubelet_config.0.topology_manager.0.scope", "pod"), + "node_config.0.kubelet_config.0.topology_manager.0.scope", "pod"), + resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config", + "node_config.0.kubelet_config.0.shutdown_grace_period_seconds", "120"), + resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config", + "node_config.0.kubelet_config.0.shutdown_grace_period_critical_pods_seconds", "15"), // resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config", // "node_config.0.kubelet_config.0.allowed_unsafe_sysctls.0", "kernel.shm*"), ), @@ -4091,6 +4095,8 @@ resource "google_container_node_pool" "with_kubelet_config" { single_process_oom_kill = %v max_parallel_image_pulls = 5 eviction_max_pod_grace_period_seconds = 200 + shutdown_grace_period_seconds = 120 + shutdown_grace_period_critical_pods_seconds = 15 eviction_soft { memory_available = "100Mi" nodefs_available = "50%%" diff --git a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown index 44786a63bf46..78dcad938fbe 100644 --- a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown @@ -1604,6 +1604,10 @@ those in the Guaranteed QoS class, by influencing NUMA affinity. Structure is [d * `eviction_max_pod_grace_period_seconds` - (Optional) Defines the maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met. The integer must be positive and not exceed 300. +* `shutdown_grace_period_seconds` - (Optional) Total duration in seconds that the node delays shutting down in order to gracefully terminate Pods. Only valid for Spot VMs. Allowed values: `0`, `30`, `120`. Set to `0` to disable graceful node shutdown. See the [graceful node shutdown documentation](https://kubernetes.io/docs/concepts/cluster-administration/node-shutdown/) for more details. + +* `shutdown_grace_period_critical_pods_seconds` - (Optional) Duration in seconds (`0` to `120`) reserved for terminating critical pods during graceful node shutdown. Only valid for Spot VMs, and only meaningful when `shutdown_grace_period_seconds` is set. Must be less than or equal to `shutdown_grace_period_seconds`. + * `eviction_soft` - (Optional) Defines a map of signal names to quantities or percentage that defines soft eviction thresholds. Structure is [documented below](#nested_eviction_soft). * `eviction_soft_grace_period` - (Optional) Defines a map of signal names to durations that defines grace periods for soft eviction thresholds. Each soft eviction threshold must have a corresponding grace period. Structure is [documented below](#nested_eviction_soft_grace_period).