Skip to content

Commit be9f297

Browse files
Support singProcessOOMKill in node_kubelet_config (#14704) (#23844)
[upstream:6dbdb9514e1f0150276fda1a97e96e2b6a36138e] Signed-off-by: Modular Magician <[email protected]>
1 parent d2f7586 commit be9f297

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

.changelog/14704.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
container: added `node_config.kubelet_config.single_process_oom_kill` field to `google_container_node_pool` and `google_container_cluster` resources
3+
```

google/services/container/node_config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ func schemaNodeConfig() *schema.Schema {
637637
Description: `Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods.`,
638638
Elem: &schema.Schema{Type: schema.TypeString},
639639
},
640+
"single_process_oom_kill": {
641+
Type: schema.TypeBool,
642+
Optional: true,
643+
Description: `Defines whether to enable single process OOM killer.`,
644+
},
640645
},
641646
},
642647
},
@@ -1425,6 +1430,9 @@ func expandKubeletConfig(v interface{}) *container.NodeKubeletConfig {
14251430
kConfig.AllowedUnsafeSysctls[i] = s.(string)
14261431
}
14271432
}
1433+
if singleProcessOomKill, ok := cfg["single_process_oom_kill"]; ok {
1434+
kConfig.SingleProcessOomKill = singleProcessOomKill.(bool)
1435+
}
14281436
return kConfig
14291437
}
14301438

@@ -1982,6 +1990,7 @@ func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface
19821990
"image_minimum_gc_age": c.ImageMinimumGcAge,
19831991
"image_maximum_gc_age": c.ImageMaximumGcAge,
19841992
"allowed_unsafe_sysctls": c.AllowedUnsafeSysctls,
1993+
"single_process_oom_kill": c.SingleProcessOomKill,
19851994
})
19861995
}
19871996
return result

google/services/container/resource_container_node_pool_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ func TestAccContainerNodePool_withKubeletConfig(t *testing.T) {
928928
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
929929
Steps: []resource.TestStep{
930930
{
931-
Config: testAccContainerNodePool_withKubeletConfig(cluster, np, "static", "100ms", networkName, subnetworkName, "TRUE", "100Mi", "1m", "10m", true, 2048, 10, 10, 85),
931+
Config: testAccContainerNodePool_withKubeletConfig(cluster, np, "static", "100ms", networkName, subnetworkName, "TRUE", "100Mi", "1m", "10m", true, true, 2048, 10, 10, 85),
932932
ConfigPlanChecks: resource.ConfigPlanChecks{
933933
PreApply: []plancheck.PlanCheck{
934934
acctest.ExpectNoDelete(),
@@ -937,6 +937,8 @@ func TestAccContainerNodePool_withKubeletConfig(t *testing.T) {
937937
Check: resource.ComposeTestCheckFunc(
938938
resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config",
939939
"node_config.0.kubelet_config.0.cpu_cfs_quota", "true"),
940+
resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config",
941+
"node_config.0.kubelet_config.0.single_process_oom_kill", "true"),
940942
resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config",
941943
"node_config.0.kubelet_config.0.insecure_kubelet_readonly_port_enabled", "TRUE"),
942944
resource.TestCheckResourceAttr("google_container_node_pool.with_kubelet_config",
@@ -963,7 +965,7 @@ func TestAccContainerNodePool_withKubeletConfig(t *testing.T) {
963965
ImportStateVerify: true,
964966
},
965967
{
966-
Config: testAccContainerNodePool_withKubeletConfig(cluster, np, "", "", networkName, subnetworkName, "FALSE", "200Mi", "30s", "", false, 1024, 5, 50, 80),
968+
Config: testAccContainerNodePool_withKubeletConfig(cluster, np, "", "", networkName, subnetworkName, "FALSE", "200Mi", "30s", "", false, true, 1024, 5, 50, 80),
967969
ConfigPlanChecks: resource.ConfigPlanChecks{
968970
PreApply: []plancheck.PlanCheck{
969971
acctest.ExpectNoDelete(),
@@ -1001,7 +1003,7 @@ func TestAccContainerNodePool_withInvalidKubeletCpuManagerPolicy(t *testing.T) {
10011003
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
10021004
Steps: []resource.TestStep{
10031005
{
1004-
Config: testAccContainerNodePool_withKubeletConfig(cluster, np, "dontexist", "100us", networkName, subnetworkName, "TRUE", "", "", "", false, 1024, 2, 70, 75),
1006+
Config: testAccContainerNodePool_withKubeletConfig(cluster, np, "dontexist", "100us", networkName, subnetworkName, "TRUE", "", "", "", false, true, 1024, 2, 70, 75),
10051007
ExpectError: regexp.MustCompile(`.*to be one of \["?static"? "?none"? "?"?\].*`),
10061008
},
10071009
},
@@ -3694,7 +3696,7 @@ resource "google_container_node_pool" "with_workload_metadata_config" {
36943696
`, projectID, cluster, networkName, subnetworkName, np)
36953697
}
36963698

3697-
func testAccContainerNodePool_withKubeletConfig(cluster, np, policy, period, networkName, subnetworkName, insecureKubeletReadonlyPortEnabled, containerLogMaxSize, imageMinimumGcAge, imageMaximumGcAge string, quota bool, podPidsLimit, containerLogMaxFiles, imageGcLowThresholdPercent, imageGcHighThresholdPercent int) string {
3699+
func testAccContainerNodePool_withKubeletConfig(cluster, np, policy, period, networkName, subnetworkName, insecureKubeletReadonlyPortEnabled, containerLogMaxSize, imageMinimumGcAge, imageMaximumGcAge string, quota, singleProcessOomKill bool, podPidsLimit, containerLogMaxFiles, imageGcLowThresholdPercent, imageGcHighThresholdPercent int) string {
36983700
return fmt.Sprintf(`
36993701
data "google_container_engine_versions" "central1a" {
37003702
location = "us-central1-a"
@@ -3732,6 +3734,7 @@ resource "google_container_node_pool" "with_kubelet_config" {
37323734
image_minimum_gc_age = %q
37333735
image_maximum_gc_age = %q
37343736
allowed_unsafe_sysctls = ["kernel.shm*", "kernel.msg*", "kernel.sem", "fs.mqueue.*", "net.*"]
3737+
single_process_oom_kill = %v
37353738
}
37363739
oauth_scopes = [
37373740
"https://www.googleapis.com/auth/logging.write",
@@ -3740,7 +3743,7 @@ resource "google_container_node_pool" "with_kubelet_config" {
37403743
logging_variant = "DEFAULT"
37413744
}
37423745
}
3743-
`, cluster, networkName, subnetworkName, np, policy, quota, period, insecureKubeletReadonlyPortEnabled, podPidsLimit, containerLogMaxSize, containerLogMaxFiles, imageGcLowThresholdPercent, imageGcHighThresholdPercent, imageMinimumGcAge, imageMaximumGcAge)
3746+
`, cluster, networkName, subnetworkName, np, policy, quota, period, insecureKubeletReadonlyPortEnabled, podPidsLimit, containerLogMaxSize, containerLogMaxFiles, imageGcLowThresholdPercent, imageGcHighThresholdPercent, imageMinimumGcAge, imageMaximumGcAge, singleProcessOomKill)
37443747
}
37453748

37463749
func testAccContainerNodePool_withLinuxNodeConfig(cluster, np, tcpMem, networkName, subnetworkName string) string {

website/docs/r/container_cluster.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,8 @@ such as `"300ms"`. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m",
14971497

14981498
* `allowed_unsafe_sysctls` - (Optional) Defines a comma-separated allowlist of unsafe sysctls or sysctl patterns which can be set on the Pods. The allowed sysctl groups are `kernel.shm*`, `kernel.msg*`, `kernel.sem`, `fs.mqueue.*`, and `net.*`.
14991499

1500+
* `single_process_oom_kill` - (Optional) Defines whether to enable single process OOM killer. If true, the processes in the container will be OOM killed individually instead of as a group.
1501+
15001502
<a name="nested_linux_node_config"></a>The `linux_node_config` block supports:
15011503

15021504
* `sysctls` - (Optional) The Linux kernel parameters to be applied to the nodes

0 commit comments

Comments
 (0)