Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions mmv1/third_party/terraform/services/container/node_config.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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*"),
),
Expand Down Expand Up @@ -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%%"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Loading