From 3503e028ae5979f0b6b2a4eed145d766087760a3 Mon Sep 17 00:00:00 2001 From: luigi-bitonti <93377317+luigi-bitonti@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:40:28 +0200 Subject: [PATCH] Module autopilot bug fixes (#1746) * Removed unused variables and bug fix * Ran fmt * Fix README.md * Added comments to code --- modules/gke-cluster-autopilot/README.md | 34 +++++++++++----------- modules/gke-cluster-autopilot/main.tf | 6 ++-- modules/gke-cluster-autopilot/variables.tf | 15 +++------- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/modules/gke-cluster-autopilot/README.md b/modules/gke-cluster-autopilot/README.md index 3fa4f344..0baad308 100644 --- a/modules/gke-cluster-autopilot/README.md +++ b/modules/gke-cluster-autopilot/README.md @@ -206,26 +206,26 @@ module "cluster-1" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [location](variables.tf#L117) | Autopilot clusters are always regional. | string | ✓ | | -| [name](variables.tf#L194) | Cluster name. | string | ✓ | | -| [project_id](variables.tf#L220) | Cluster project ID. | string | ✓ | | -| [vpc_config](variables.tf#L249) | VPC-level configuration. | object({…}) | ✓ | | +| [location](variables.tf#L110) | Autopilot clusters are always regional. | string | ✓ | | +| [name](variables.tf#L187) | Cluster name. | string | ✓ | | +| [project_id](variables.tf#L213) | Cluster project ID. | string | ✓ | | +| [vpc_config](variables.tf#L242) | VPC-level configuration. | object({…}) | ✓ | | | [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | object({…}) | | {} | | [deletion_protection](variables.tf#L37) | 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#L44) | Cluster description. | string | | null | -| [enable_addons](variables.tf#L50) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | -| [enable_features](variables.tf#L71) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {} | -| [issue_client_certificate](variables.tf#L105) | Enable issuing client certificate. | bool | | false | -| [labels](variables.tf#L111) | Cluster resource labels. | map(string) | | null | -| [logging_config](variables.tf#L122) | Logging configuration. | object({…}) | | {} | -| [maintenance_config](variables.tf#L133) | Maintenance window configuration. | object({…}) | | {…} | -| [min_master_version](variables.tf#L156) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | -| [monitoring_config](variables.tf#L162) | Monitoring configuration. System metrics collection cannot be disabled. Control plane metrics are optional. Kube state metrics are optional. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | -| [node_locations](variables.tf#L199) | Zones in which the cluster's nodes are located. | list(string) | | [] | -| [private_cluster_config](variables.tf#L206) | Private cluster configuration. | object({…}) | | null | -| [release_channel](variables.tf#L225) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | string | | "REGULAR" | -| [service_account](variables.tf#L236) | The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot. | string | | null | -| [tags](variables.tf#L242) | Network tags applied to nodes. | list(string) | | [] | +| [enable_addons](variables.tf#L50) | Addons enabled in the cluster (true means enabled). | object({…}) | | {} | +| [enable_features](variables.tf#L64) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {} | +| [issue_client_certificate](variables.tf#L98) | Enable issuing client certificate. | bool | | false | +| [labels](variables.tf#L104) | Cluster resource labels. | map(string) | | null | +| [logging_config](variables.tf#L115) | Logging configuration. | object({…}) | | {} | +| [maintenance_config](variables.tf#L126) | Maintenance window configuration. | object({…}) | | {…} | +| [min_master_version](variables.tf#L149) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | +| [monitoring_config](variables.tf#L155) | Monitoring configuration. System metrics collection cannot be disabled. Control plane metrics are optional. Kube state metrics are optional. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | +| [node_locations](variables.tf#L192) | Zones in which the cluster's nodes are located. | list(string) | | [] | +| [private_cluster_config](variables.tf#L199) | Private cluster configuration. | object({…}) | | null | +| [release_channel](variables.tf#L218) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | string | | "REGULAR" | +| [service_account](variables.tf#L229) | The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot. | string | | null | +| [tags](variables.tf#L235) | Network tags applied to nodes. | list(string) | | [] | ## Outputs diff --git a/modules/gke-cluster-autopilot/main.tf b/modules/gke-cluster-autopilot/main.tf index b4119181..5bb03c9e 100644 --- a/modules/gke-cluster-autopilot/main.tf +++ b/modules/gke-cluster-autopilot/main.tf @@ -35,11 +35,13 @@ resource "google_container_cluster" "cluster" { deletion_protection = var.deletion_protection addons_config { + # HTTP Load Balancing is required to be enabled in Autopilot clusters http_load_balancing { - disabled = !var.enable_addons.http_load_balancing + disabled = false } + # Horizontal Pod Autoscaling is required to be enabled in Autopilot clusters horizontal_pod_autoscaling { - disabled = !var.enable_addons.horizontal_pod_autoscaling + disabled = false } cloudrun_config { disabled = !var.enable_addons.cloudrun diff --git a/modules/gke-cluster-autopilot/variables.tf b/modules/gke-cluster-autopilot/variables.tf index fe0a3a14..ebc71968 100644 --- a/modules/gke-cluster-autopilot/variables.tf +++ b/modules/gke-cluster-autopilot/variables.tf @@ -50,21 +50,14 @@ variable "description" { variable "enable_addons" { description = "Addons enabled in the cluster (true means enabled)." type = object({ - cloudrun = optional(bool, false) - config_connector = optional(bool, false) - dns_cache = optional(bool, false) - horizontal_pod_autoscaling = optional(bool, false) - http_load_balancing = optional(bool, false) + cloudrun = optional(bool, false) + config_connector = optional(bool, false) istio = optional(object({ enable_tls = bool })) - kalm = optional(bool, false) - network_policy = optional(bool, false) + kalm = optional(bool, false) }) - default = { - horizontal_pod_autoscaling = true - http_load_balancing = true - } + default = {} nullable = false }