From fff098a1e22d46ed9a609f738f854851a3d2cfb1 Mon Sep 17 00:00:00 2001 From: Anthony Hausman Date: Tue, 26 Mar 2024 15:44:08 +0100 Subject: [PATCH] feat(gke-cluster-standard): Improve `default_node_pool` variable setup --- modules/gke-cluster-standard/README.md | 40 +++++++++++------------ modules/gke-cluster-standard/variables.tf | 8 ++--- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/modules/gke-cluster-standard/README.md b/modules/gke-cluster-standard/README.md index c7b1c4edde..acc8f55171 100644 --- a/modules/gke-cluster-standard/README.md +++ b/modules/gke-cluster-standard/README.md @@ -310,28 +310,28 @@ module "cluster-1" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [location](variables.tf#L231) | Cluster zone or region. | string | ✓ | | -| [name](variables.tf#L366) | Cluster name. | string | ✓ | | -| [project_id](variables.tf#L402) | Cluster project id. | string | ✓ | | -| [vpc_config](variables.tf#L413) | VPC-level configuration. | object({…}) | ✓ | | +| [location](variables.tf#L229) | Cluster zone or region. | string | ✓ | | +| [name](variables.tf#L364) | Cluster name. | string | ✓ | | +| [project_id](variables.tf#L400) | Cluster project id. | string | ✓ | | +| [vpc_config](variables.tf#L411) | VPC-level configuration. | object({…}) | ✓ | | | [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | object({…}) | | {} | | [cluster_autoscaling](variables.tf#L38) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | object({…}) | | null | -| [default_node_pool](variables.tf#L116) | Enable default node-pool. | object({…}) | | {…} | -| [deletion_protection](variables.tf#L133) | Whether or not to allow Terraform to destroy the cluster. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the cluster will fail. | bool | | true | -| [description](variables.tf#L140) | Cluster description. | string | | null | -| [enable_addons](variables.tf#L146) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | -| [enable_features](variables.tf#L170) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | -| [issue_client_certificate](variables.tf#L219) | Enable issuing client certificate. | bool | | false | -| [labels](variables.tf#L225) | Cluster resource labels. | map(string) | | null | -| [logging_config](variables.tf#L236) | Logging configuration. | object({…}) | | {} | -| [maintenance_config](variables.tf#L257) | Maintenance window configuration. | object({…}) | | {…} | -| [max_pods_per_node](variables.tf#L280) | Maximum number of pods per node in this cluster. | number | | 110 | -| [min_master_version](variables.tf#L286) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | -| [monitoring_config](variables.tf#L292) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | -| [node_config](variables.tf#L371) | Node-level configuration. | object({…}) | | {} | -| [node_locations](variables.tf#L381) | Zones in which the cluster's nodes are located. | list(string) | | [] | -| [private_cluster_config](variables.tf#L388) | Private cluster configuration. | object({…}) | | null | -| [release_channel](variables.tf#L407) | Release channel for GKE upgrades. | string | | null | +| [default_node_pool](variables.tf#L116) | Enable default node-pool. | object({…}) | | {} | +| [deletion_protection](variables.tf#L131) | Whether or not to allow Terraform to destroy the cluster. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the cluster will fail. | bool | | true | +| [description](variables.tf#L138) | Cluster description. | string | | null | +| [enable_addons](variables.tf#L144) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | +| [enable_features](variables.tf#L168) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | +| [issue_client_certificate](variables.tf#L217) | Enable issuing client certificate. | bool | | false | +| [labels](variables.tf#L223) | Cluster resource labels. | map(string) | | null | +| [logging_config](variables.tf#L234) | Logging configuration. | object({…}) | | {} | +| [maintenance_config](variables.tf#L255) | Maintenance window configuration. | object({…}) | | {…} | +| [max_pods_per_node](variables.tf#L278) | Maximum number of pods per node in this cluster. | number | | 110 | +| [min_master_version](variables.tf#L284) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | +| [monitoring_config](variables.tf#L290) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | +| [node_config](variables.tf#L369) | Node-level configuration. | object({…}) | | {} | +| [node_locations](variables.tf#L379) | Zones in which the cluster's nodes are located. | list(string) | | [] | +| [private_cluster_config](variables.tf#L386) | Private cluster configuration. | object({…}) | | null | +| [release_channel](variables.tf#L405) | Release channel for GKE upgrades. | string | | null | ## Outputs diff --git a/modules/gke-cluster-standard/variables.tf b/modules/gke-cluster-standard/variables.tf index 6a52e85d1a..00ab1d8461 100644 --- a/modules/gke-cluster-standard/variables.tf +++ b/modules/gke-cluster-standard/variables.tf @@ -117,12 +117,10 @@ variable "default_node_pool" { description = "Enable default node-pool." type = object({ remove_pool = optional(bool, true) - initial_node_count = optional(number, null) + initial_node_count = optional(number) }) - default = { - remove_pool = true - initial_node_count = null - } + default = {} + nullable = false validation { condition = ((var.default_node_pool.remove_pool == true && var.default_node_pool.initial_node_count == null) || (var.default_node_pool.remove_pool == false && var.default_node_pool.initial_node_count != null))