diff --git a/modules/gke-nodepool/README.md b/modules/gke-nodepool/README.md index 41338cfa..453fff8d 100644 --- a/modules/gke-nodepool/README.md +++ b/modules/gke-nodepool/README.md @@ -143,7 +143,7 @@ module "cluster-1-nodepool-gpu-1" { |---|---|:---:|:---:|:---:| | [cluster_name](variables.tf#L23) | Cluster name. | string | ✓ | | | [location](variables.tf#L48) | Cluster location. | string | ✓ | | -| [project_id](variables.tf#L177) | Cluster project id. | string | ✓ | | +| [project_id](variables.tf#L181) | 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) | | {} | @@ -153,13 +153,13 @@ module "cluster-1-nodepool-gpu-1" { | [node_config](variables.tf#L65) | Node-level configuration. | object({…}) | | {…} | | [node_count](variables.tf#L124) | 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#L136) | Node locations. | list(string) | | null | -| [nodepool_config](variables.tf#L142) | Nodepool-level configuration. | object({…}) | | null | -| [pod_range](variables.tf#L164) | Pod secondary range configuration. | object({…}) | | null | -| [reservation_affinity](variables.tf#L182) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | -| [service_account](variables.tf#L192) | 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#L203) | Sole tenant node group. | string | | null | -| [tags](variables.tf#L209) | Network tags applied to nodes. | list(string) | | null | -| [taints](variables.tf#L215) | Kubernetes taints applied to all nodes. | map(object({…})) | | {} | +| [nodepool_config](variables.tf#L142) | Nodepool-level configuration. | object({…}) | | null | +| [pod_range](variables.tf#L168) | Pod secondary range configuration. | object({…}) | | null | +| [reservation_affinity](variables.tf#L186) | Configuration of the desired reservation which instances could take capacity from. | object({…}) | | null | +| [service_account](variables.tf#L196) | 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#L207) | Sole tenant node group. | string | | null | +| [tags](variables.tf#L213) | Network tags applied to nodes. | list(string) | | null | +| [taints](variables.tf#L219) | Kubernetes taints applied to all nodes. | map(object({…})) | | {} | ## Outputs diff --git a/modules/gke-nodepool/main.tf b/modules/gke-nodepool/main.tf index 659dfc4b..b94ef697 100644 --- a/modules/gke-nodepool/main.tf +++ b/modules/gke-nodepool/main.tf @@ -77,7 +77,6 @@ resource "google_container_node_pool" "nodepool" { initial_node_count = var.node_count.initial node_count = var.node_count.current node_locations = var.node_locations - # placement_policy = var.nodepool_config.placement_policy dynamic "autoscaling" { for_each = ( @@ -129,6 +128,15 @@ resource "google_container_node_pool" "nodepool" { } } + dynamic "placement_policy" { + for_each = try(var.nodepool_config.placement_policy, null) != null ? [""] : [] + content { + type = var.nodepool_config.placement_policy.type + policy_name = var.nodepool_config.placement_policy.policy_name + tpu_topology = var.nodepool_config.placement_policy.tpu_topology + } + } + node_config { boot_disk_kms_key = var.node_config.boot_disk_kms_key disk_size_gb = var.node_config.disk_size_gb diff --git a/modules/gke-nodepool/variables.tf b/modules/gke-nodepool/variables.tf index 066390e4..c970c5b1 100644 --- a/modules/gke-nodepool/variables.tf +++ b/modules/gke-nodepool/variables.tf @@ -152,7 +152,11 @@ variable "nodepool_config" { auto_repair = optional(bool) auto_upgrade = optional(bool) })) - # placement_policy = optional(bool) + placement_policy = optional(object({ + type = string + policy_name = optional(string) + tpu_topology = optional(string) + })) upgrade_settings = optional(object({ max_surge = number max_unavailable = number