From 382cb05762b6b072cbcf4943a661e4279d829071 Mon Sep 17 00:00:00 2001 From: Luigi Bitonti Date: Mon, 11 Dec 2023 17:10:49 +0100 Subject: [PATCH] Added missing parameters in kubelet and linux node conf --- modules/gke-nodepool/README.md | 22 +++++++++++----------- modules/gke-nodepool/main.tf | 6 ++++-- modules/gke-nodepool/variables.tf | 18 +++++++++++------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/modules/gke-nodepool/README.md b/modules/gke-nodepool/README.md index e7d2191132..e3a3f0a791 100644 --- a/modules/gke-nodepool/README.md +++ b/modules/gke-nodepool/README.md @@ -143,22 +143,22 @@ module "cluster-1-nodepool-gpu-1" { |---|---|:---:|:---:|:---:| | [cluster_name](variables.tf#L23) | Cluster name. | string | ✓ | | | [location](variables.tf#L41) | Cluster location. | string | ✓ | | -| [project_id](variables.tf#L166) | Cluster project id. | string | ✓ | | +| [project_id](variables.tf#L170) | 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 | | [labels](variables.tf#L34) | Kubernetes labels applied to each node. | map(string) | | {} | | [max_pods_per_node](variables.tf#L46) | Maximum number of pods per node. | number | | null | | [name](variables.tf#L52) | Optional nodepool name. | string | | null | -| [node_config](variables.tf#L58) | Node-level configuration. | object({…}) | | {…} | -| [node_count](variables.tf#L113) | 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#L125) | Node locations. | list(string) | | null | -| [nodepool_config](variables.tf#L131) | Nodepool-level configuration. | object({…}) | | null | -| [pod_range](variables.tf#L153) | Pod secondary range configuration. | object({…}) | | null | -| [reservation_affinity](variables.tf#L171) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | -| [service_account](variables.tf#L181) | 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#L192) | Sole tenant node group. | string | | null | -| [tags](variables.tf#L198) | Network tags applied to nodes. | list(string) | | null | -| [taints](variables.tf#L204) | Kubernetes taints applied to all nodes. | map(object({…})) | | {} | +| [node_config](variables.tf#L58) | Node-level configuration. | object({…}) | | {…} | +| [node_count](variables.tf#L117) | 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#L129) | Node locations. | list(string) | | null | +| [nodepool_config](variables.tf#L135) | Nodepool-level configuration. | object({…}) | | null | +| [pod_range](variables.tf#L157) | Pod secondary range configuration. | object({…}) | | null | +| [reservation_affinity](variables.tf#L175) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | +| [service_account](variables.tf#L185) | 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#L196) | Sole tenant node group. | string | | null | +| [tags](variables.tf#L202) | Network tags applied to nodes. | list(string) | | null | +| [taints](variables.tf#L208) | Kubernetes taints applied to all nodes. | map(object({…})) | | {} | ## Outputs diff --git a/modules/gke-nodepool/main.tf b/modules/gke-nodepool/main.tf index 20d4fcad16..7283cc8b66 100644 --- a/modules/gke-nodepool/main.tf +++ b/modules/gke-nodepool/main.tf @@ -201,12 +201,14 @@ resource "google_container_node_pool" "nodepool" { 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 } } dynamic "linux_node_config" { - for_each = var.node_config.linux_node_config_sysctls != null ? [""] : [] + for_each = var.node_config.linux_node_config != null ? [""] : [] content { - sysctls = var.node_config.linux_node_config_sysctls + sysctls = var.node_config.linux_node_config.sysctls + cgroup_mode = try(var.node_config.linux_node_config.cgroup_mode, "CGROUP_MODE_UNSPECIFIED") } } dynamic "reservation_affinity" { diff --git a/modules/gke-nodepool/variables.tf b/modules/gke-nodepool/variables.tf index caa735884c..10db6adb53 100644 --- a/modules/gke-nodepool/variables.tf +++ b/modules/gke-nodepool/variables.tf @@ -79,14 +79,18 @@ variable "node_config" { cpu_manager_policy = string cpu_cfs_quota = optional(bool) cpu_cfs_quota_period = optional(string) + pod_pids_limit = optional(number) })) - linux_node_config_sysctls = optional(map(string)) - local_ssd_count = optional(number) - machine_type = optional(string) - metadata = optional(map(string)) - min_cpu_platform = optional(string) - preemptible = optional(bool) - sandbox_config_gvisor = optional(bool) + linux_node_config = optional(object({ + sysctls = optional(map(string)) + cgroup_mode = optional(string) + })) + local_ssd_count = optional(number) + machine_type = optional(string) + metadata = optional(map(string)) + min_cpu_platform = optional(string) + preemptible = optional(bool) + sandbox_config_gvisor = optional(bool) shielded_instance_config = optional(object({ enable_integrity_monitoring = optional(bool) enable_secure_boot = optional(bool)