Skip to content

Commit 3fc4db4

Browse files
DrFaust92chicocvenancioapeabody
authored
feat(cluster.tf): add support for setting cgroup mode (#2001)
Co-authored-by: Chico Venancio <francisco@argyle.com> Co-authored-by: Andrew Peabody <andrewpeabody@google.com>
1 parent 65ccfa0 commit 3fc4db4

31 files changed

+183
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ Then perform the following commands on the root folder:
215215
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
216216
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
217217
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
218+
| node\_pools\_cgroup\_mode | Map of strings containing cgroup node config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
218219
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
219220
| node\_pools\_linux\_node\_configs\_sysctls | Map of maps containing linux node config sysctls by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
220221
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

autogen/main/cluster.tf.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,14 +1038,16 @@ resource "google_container_node_pool" "windows_pools" {
10381038
dynamic "linux_node_config" {
10391039
for_each = length(merge(
10401040
local.node_pools_linux_node_configs_sysctls["all"],
1041-
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
1041+
local.node_pools_linux_node_configs_sysctls[each.value["name"]],
1042+
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : {cgroup = local.node_pools_cgroup_mode[each.value["name"]]}
10421043
)) != 0 ? [1] : []
10431044

10441045
content {
10451046
sysctls = merge(
10461047
local.node_pools_linux_node_configs_sysctls["all"],
10471048
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
10481049
)
1050+
cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]]
10491051
}
10501052
}
10511053
{% endif %}

autogen/main/variables.tf.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ variable "node_pools_linux_node_configs_sysctls" {
226226
default-node-pool = {}
227227
}
228228
}
229+
variable "node_pools_cgroup_mode" {
230+
type = map(string)
231+
description = "Map of strings containing cgroup node config by node-pool name"
232+
233+
# Default is being set in variables_defaults.tf
234+
default = {
235+
all = ""
236+
default-node-pool = ""
237+
}
238+
}
229239
{% endif %}
230240

231241
variable "enable_cost_allocation" {

autogen/main/variables_defaults.tf.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,14 @@ locals {
128128
),
129129
var.node_pools_linux_node_configs_sysctls
130130
)
131+
node_pools_cgroup_mode = merge(
132+
{ all = "" },
133+
{ default-node-pool = "" },
134+
zipmap(
135+
[for node_pool in var.node_pools : node_pool["name"]],
136+
[for node_pool in var.node_pools : ""]
137+
),
138+
var.node_pools_cgroup_mode
139+
)
131140
}
132141
{% endif %}

cluster.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,14 +733,16 @@ resource "google_container_node_pool" "pools" {
733733
dynamic "linux_node_config" {
734734
for_each = length(merge(
735735
local.node_pools_linux_node_configs_sysctls["all"],
736-
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
736+
local.node_pools_linux_node_configs_sysctls[each.value["name"]],
737+
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] }
737738
)) != 0 ? [1] : []
738739

739740
content {
740741
sysctls = merge(
741742
local.node_pools_linux_node_configs_sysctls["all"],
742743
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
743744
)
745+
cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]]
744746
}
745747
}
746748

modules/beta-private-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ Then perform the following commands on the root folder:
263263
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
264264
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
265265
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
266+
| node\_pools\_cgroup\_mode | Map of strings containing cgroup node config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
266267
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
267268
| node\_pools\_linux\_node\_configs\_sysctls | Map of maps containing linux node config sysctls by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
268269
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,14 +911,16 @@ resource "google_container_node_pool" "pools" {
911911
dynamic "linux_node_config" {
912912
for_each = length(merge(
913913
local.node_pools_linux_node_configs_sysctls["all"],
914-
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
914+
local.node_pools_linux_node_configs_sysctls[each.value["name"]],
915+
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] }
915916
)) != 0 ? [1] : []
916917

917918
content {
918919
sysctls = merge(
919920
local.node_pools_linux_node_configs_sysctls["all"],
920921
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
921922
)
923+
cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]]
922924
}
923925
}
924926

modules/beta-private-cluster-update-variant/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ variable "node_pools_linux_node_configs_sysctls" {
223223
default-node-pool = {}
224224
}
225225
}
226+
variable "node_pools_cgroup_mode" {
227+
type = map(string)
228+
description = "Map of strings containing cgroup node config by node-pool name"
229+
230+
# Default is being set in variables_defaults.tf
231+
default = {
232+
all = ""
233+
default-node-pool = ""
234+
}
235+
}
226236

227237
variable "enable_cost_allocation" {
228238
type = bool

modules/beta-private-cluster-update-variant/variables_defaults.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,13 @@ locals {
127127
),
128128
var.node_pools_linux_node_configs_sysctls
129129
)
130+
node_pools_cgroup_mode = merge(
131+
{ all = "" },
132+
{ default-node-pool = "" },
133+
zipmap(
134+
[for node_pool in var.node_pools : node_pool["name"]],
135+
[for node_pool in var.node_pools : ""]
136+
),
137+
var.node_pools_cgroup_mode
138+
)
130139
}

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ Then perform the following commands on the root folder:
241241
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
242242
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
243243
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
244+
| node\_pools\_cgroup\_mode | Map of strings containing cgroup node config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
244245
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
245246
| node\_pools\_linux\_node\_configs\_sysctls | Map of maps containing linux node config sysctls by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
246247
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |

0 commit comments

Comments
 (0)