Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for hugepages_config #2223

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ Then perform the following commands on the root folder:
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
| 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 |
| node\_pools\_hugepage\_size\_1g | Map of strings containing hugepage size 1g config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
| node\_pools\_hugepage\_size\_2m | Map of strings containing hugepage size 2m node config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
| 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 |
| 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 |
| 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 |
Expand Down
19 changes: 18 additions & 1 deletion autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,11 @@ resource "google_container_node_pool" "windows_pools" {
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]],
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : {cgroup = local.node_pools_cgroup_mode[each.value["name"]]}
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] },
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
Expand All @@ -1120,6 +1124,19 @@ resource "google_container_node_pool" "windows_pools" {
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
)
cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]]
dynamic "hugepages_config" {
for_each = length(merge(
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])

hugepage_size_1g = coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"])
}
}
}
}
{% endif %}
Expand Down
22 changes: 22 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,28 @@ variable "node_pools_cgroup_mode" {
default-node-pool = ""
}
}

variable "node_pools_hugepage_size_2m" {
type = map(string)
description = "Map of strings containing hugepage size 2m node config by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = ""
default-node-pool = ""
}
}

variable "node_pools_hugepage_size_1g" {
type = map(string)
description = "Map of strings containing hugepage size 1g config by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = ""
default-node-pool = ""
}
}
{% endif %}

variable "enable_cost_allocation" {
Expand Down
34 changes: 26 additions & 8 deletions autogen/main/variables_defaults.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,32 @@ locals {
),
var.node_pools_linux_node_configs_sysctls
)
node_pools_cgroup_mode = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_cgroup_mode
node_pools_cgroup_mode = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_cgroup_mode
)
node_pools_hugepage_size_2m = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_hugepage_size_2m
)
node_pools_hugepage_size_1g = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_hugepage_size_1g
)
}
{% endif %}
19 changes: 18 additions & 1 deletion cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,11 @@ resource "google_container_node_pool" "pools" {
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]],
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] }
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] },
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
Expand All @@ -813,6 +817,19 @@ resource "google_container_node_pool" "pools" {
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
)
cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]]
dynamic "hugepages_config" {
for_each = length(merge(
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])
hugepage_size_1g = coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"])
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ Then perform the following commands on the root folder:
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
| 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 |
| node\_pools\_hugepage\_size\_1g | Map of strings containing hugepage size 1g config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
| node\_pools\_hugepage\_size\_2m | Map of strings containing hugepage size 2m node config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
| 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 |
| 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 |
| 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 |
Expand Down
19 changes: 18 additions & 1 deletion modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,11 @@ resource "google_container_node_pool" "pools" {
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]],
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] }
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] },
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
Expand All @@ -984,6 +988,19 @@ resource "google_container_node_pool" "pools" {
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
)
cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]]
dynamic "hugepages_config" {
for_each = length(merge(
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])
hugepage_size_1g = coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"])
}
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,28 @@ variable "node_pools_cgroup_mode" {
}
}

variable "node_pools_hugepage_size_2m" {
type = map(string)
description = "Map of strings containing hugepage size 2m node config by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = ""
default-node-pool = ""
}
}

variable "node_pools_hugepage_size_1g" {
type = map(string)
description = "Map of strings containing hugepage size 1g config by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = ""
default-node-pool = ""
}
}

variable "enable_cost_allocation" {
type = bool
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,22 @@ locals {
),
var.node_pools_cgroup_mode
)
node_pools_hugepage_size_2m = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_hugepage_size_2m
)
node_pools_hugepage_size_1g = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_hugepage_size_1g
)
}
2 changes: 2 additions & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ Then perform the following commands on the root folder:
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
| 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 |
| node\_pools\_hugepage\_size\_1g | Map of strings containing hugepage size 1g config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
| node\_pools\_hugepage\_size\_2m | Map of strings containing hugepage size 2m node config by node-pool name | `map(string)` | <pre>{<br> "all": "",<br> "default-node-pool": ""<br>}</pre> | no |
| 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 |
| 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 |
| 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 |
Expand Down
19 changes: 18 additions & 1 deletion modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,11 @@ resource "google_container_node_pool" "pools" {
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]],
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] }
local.node_pools_cgroup_mode[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_cgroup_mode[each.value["name"]] },
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
Expand All @@ -903,6 +907,19 @@ resource "google_container_node_pool" "pools" {
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
)
cgroup_mode = local.node_pools_cgroup_mode[each.value["name"]] == "" ? null : local.node_pools_cgroup_mode[each.value["name"]]
dynamic "hugepages_config" {
for_each = length(merge(
local.node_pools_hugepage_size_2m["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m["all"] },
local.node_pools_hugepage_size_2m[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_2m[each.value["name"]] },
local.node_pools_hugepage_size_1g["all"] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g["all"] },
local.node_pools_hugepage_size_1g[each.value["name"]] == "" ? {} : { cgroup = local.node_pools_hugepage_size_1g[each.value["name"]] },
)) != 0 ? [1] : []

content {
hugepage_size_2m = coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_2m[each.value["name"]], local.node_pools_hugepage_size_2m["all"])
hugepage_size_1g = coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"]) == "" ? null : coalesce(local.node_pools_hugepage_size_1g[each.value["name"]], local.node_pools_hugepage_size_1g["all"])
}
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,28 @@ variable "node_pools_cgroup_mode" {
}
}

variable "node_pools_hugepage_size_2m" {
type = map(string)
description = "Map of strings containing hugepage size 2m node config by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = ""
default-node-pool = ""
}
}

variable "node_pools_hugepage_size_1g" {
type = map(string)
description = "Map of strings containing hugepage size 1g config by node-pool name"

# Default is being set in variables_defaults.tf
default = {
all = ""
default-node-pool = ""
}
}

variable "enable_cost_allocation" {
type = bool
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
Expand Down
18 changes: 18 additions & 0 deletions modules/beta-private-cluster/variables_defaults.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,22 @@ locals {
),
var.node_pools_cgroup_mode
)
node_pools_hugepage_size_2m = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_hugepage_size_2m
)
node_pools_hugepage_size_1g = merge(
{ all = "" },
{ default-node-pool = "" },
zipmap(
[for node_pool in var.node_pools : node_pool["name"]],
[for node_pool in var.node_pools : ""]
),
var.node_pools_hugepage_size_1g
)
}
Loading
Loading