From 042c899b048c309ac87105b761008a31dc43f55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Sauv=C3=A8re?= Date: Fri, 25 Jul 2025 18:23:48 +0200 Subject: [PATCH] feat(gke-nodepool): add missing options in the `kubelet_config` (#3250) --- modules/gke-nodepool/README.md | 20 ++++++++++---------- modules/gke-nodepool/main.tf | 16 ++++++++++++---- modules/gke-nodepool/variables.tf | 16 ++++++++++++---- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/modules/gke-nodepool/README.md b/modules/gke-nodepool/README.md index bc526d497..b9bfc0af0 100644 --- a/modules/gke-nodepool/README.md +++ b/modules/gke-nodepool/README.md @@ -194,7 +194,7 @@ module "cluster-1-nodepool-dws" { |---|---|:---:|:---:|:---:| | [cluster_name](variables.tf#L23) | Cluster name. | string | ✓ | | | [location](variables.tf#L48) | Cluster location. | string | ✓ | | -| [project_id](variables.tf#L208) | Cluster project id. | string | ✓ | | +| [project_id](variables.tf#L216) | Cluster project id. | string | ✓ | | | [cluster_id](variables.tf#L17) | Cluster id. Optional, but providing cluster_id is recommended to prevent cluster misconfiguration in some of the edge cases. | string | | null | | [gke_version](variables.tf#L28) | Kubernetes nodes version. Ignored if auto_upgrade is set in management_config. | string | | null | | [k8s_labels](variables.tf#L34) | Kubernetes labels applied to each node. | map(string) | | {} | @@ -202,15 +202,15 @@ module "cluster-1-nodepool-dws" { | [max_pods_per_node](variables.tf#L53) | Maximum number of pods per node. | number | | null | | [name](variables.tf#L59) | Optional nodepool name. | string | | null | | [network_config](variables.tf#L65) | Network configuration. | object({…}) | | null | -| [node_config](variables.tf#L89) | Node-level configuration. | object({…}) | | {} | -| [node_count](variables.tf#L154) | Number of nodes per instance group. Initial value can only be changed by recreation, current is ignored when autoscaling is used. | object({…}) | | {…} | -| [node_locations](variables.tf#L166) | Node locations. | list(string) | | null | -| [nodepool_config](variables.tf#L172) | Nodepool-level configuration. | object({…}) | | null | -| [reservation_affinity](variables.tf#L213) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | -| [service_account](variables.tf#L223) | Nodepool service account. If this variable is set to null, the default GCE service account will be used. If set and email is null, a service account will be created. If scopes are null a default will be used. | object({…}) | | {} | -| [sole_tenant_nodegroup](variables.tf#L235) | Sole tenant node group. | string | | null | -| [tags](variables.tf#L241) | Network tags applied to nodes. | list(string) | | null | -| [taints](variables.tf#L247) | Kubernetes taints applied to all nodes. | map(object({…})) | | {} | +| [node_config](variables.tf#L89) | Node-level configuration. | object({…}) | | {} | +| [node_count](variables.tf#L162) | Number of nodes per instance group. Initial value can only be changed by recreation, current is ignored when autoscaling is used. | object({…}) | | {…} | +| [node_locations](variables.tf#L174) | Node locations. | list(string) | | null | +| [nodepool_config](variables.tf#L180) | Nodepool-level configuration. | object({…}) | | null | +| [reservation_affinity](variables.tf#L221) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | +| [service_account](variables.tf#L231) | Nodepool service account. If this variable is set to null, the default GCE service account will be used. If set and email is null, a service account will be created. If scopes are null a default will be used. | object({…}) | | {} | +| [sole_tenant_nodegroup](variables.tf#L243) | Sole tenant node group. | string | | null | +| [tags](variables.tf#L249) | Network tags applied to nodes. | list(string) | | null | +| [taints](variables.tf#L255) | Kubernetes taints applied to all nodes. | map(object({…})) | | {} | ## Outputs diff --git a/modules/gke-nodepool/main.tf b/modules/gke-nodepool/main.tf index ddd7489c8..21553f47c 100644 --- a/modules/gke-nodepool/main.tf +++ b/modules/gke-nodepool/main.tf @@ -261,10 +261,18 @@ resource "google_container_node_pool" "nodepool" { dynamic "kubelet_config" { for_each = var.node_config.kubelet_config != null ? [""] : [] content { - cpu_manager_policy = var.node_config.kubelet_config.cpu_manager_policy - cpu_cfs_quota = var.node_config.kubelet_config.cpu_cfs_quota - cpu_cfs_quota_period = var.node_config.kubelet_config.cpu_cfs_quota_period - pod_pids_limit = var.node_config.kubelet_config.pod_pids_limit + cpu_manager_policy = var.node_config.kubelet_config.cpu_manager_policy + cpu_cfs_quota = var.node_config.kubelet_config.cpu_cfs_quota + cpu_cfs_quota_period = var.node_config.kubelet_config.cpu_cfs_quota_period + insecure_kubelet_readonly_port_enabled = var.node_config.kubelet_config.insecure_kubelet_readonly_port_enabled + pod_pids_limit = var.node_config.kubelet_config.pod_pids_limit + container_log_max_size = var.node_config.kubelet_config.container_log_max_size + container_log_max_files = var.node_config.kubelet_config.container_log_max_files + image_gc_low_threshold_percent = var.node_config.kubelet_config.image_gc_low_threshold_percent + image_gc_high_threshold_percent = var.node_config.kubelet_config.image_gc_high_threshold_percent + image_minimum_gc_age = var.node_config.kubelet_config.image_minimum_gc_age + image_maximum_gc_age = var.node_config.kubelet_config.image_maximum_gc_age + allowed_unsafe_sysctls = var.node_config.kubelet_config.allowed_unsafe_sysctls } } dynamic "linux_node_config" { diff --git a/modules/gke-nodepool/variables.tf b/modules/gke-nodepool/variables.tf index 0c1aabbf0..5c2bdc13b 100644 --- a/modules/gke-nodepool/variables.tf +++ b/modules/gke-nodepool/variables.tf @@ -107,10 +107,18 @@ variable "node_config" { gvnic = optional(bool, false) image_type = optional(string) kubelet_config = optional(object({ - cpu_manager_policy = string - cpu_cfs_quota = optional(bool) - cpu_cfs_quota_period = optional(string) - pod_pids_limit = optional(number) + cpu_manager_policy = string + cpu_cfs_quota = optional(bool) + cpu_cfs_quota_period = optional(string) + insecure_kubelet_readonly_port_enabled = optional(string) + pod_pids_limit = optional(number) + container_log_max_size = optional(string) + container_log_max_files = optional(number) + image_gc_low_threshold_percent = optional(number) + image_gc_high_threshold_percent = optional(number) + image_minimum_gc_age = optional(string) + image_maximum_gc_age = optional(string) + allowed_unsafe_sysctls = optional(list(string), []) })) linux_node_config = optional(object({ sysctls = optional(map(string))