From bc5bceece674e70d92605008b1ab3312bdbef055 Mon Sep 17 00:00:00 2001 From: Ludo Date: Tue, 4 Jun 2024 09:34:27 +0200 Subject: [PATCH] enable stateful ha in gke cluster standard module --- modules/gke-cluster-standard/README.md | 34 +++++++++--------- modules/gke-cluster-standard/main.tf | 43 ++++++++++++----------- modules/gke-cluster-standard/variables.tf | 1 + 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/modules/gke-cluster-standard/README.md b/modules/gke-cluster-standard/README.md index 84f8a9d1b4..3d00b8c9c1 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#L236) | Cluster zone or region. | string | ✓ | | -| [name](variables.tf#L371) | Cluster name. | string | ✓ | | -| [project_id](variables.tf#L410) | Cluster project id. | string | ✓ | | -| [vpc_config](variables.tf#L421) | VPC-level configuration. | object({…}) | ✓ | | +| [location](variables.tf#L237) | Cluster zone or region. | string | ✓ | | +| [name](variables.tf#L372) | Cluster name. | string | ✓ | | +| [project_id](variables.tf#L411) | Cluster project id. | string | ✓ | | +| [vpc_config](variables.tf#L422) | VPC-level configuration. | object({…}) | ✓ | | | [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | object({…}) | | {} | | [cluster_autoscaling](variables.tf#L39) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | object({…}) | | null | | [default_nodepool](variables.tf#L118) | Enable default nodepool. | object({…}) | | {} | | [deletion_protection](variables.tf#L136) | 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#L143) | Cluster description. | string | | null | -| [enable_addons](variables.tf#L149) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | -| [enable_features](variables.tf#L173) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | -| [issue_client_certificate](variables.tf#L223) | Enable issuing client certificate. | bool | | false | -| [labels](variables.tf#L229) | Cluster resource labels. | map(string) | | {} | -| [logging_config](variables.tf#L241) | Logging configuration. | object({…}) | | {} | -| [maintenance_config](variables.tf#L262) | Maintenance window configuration. | object({…}) | | {…} | -| [max_pods_per_node](variables.tf#L285) | Maximum number of pods per node in this cluster. | number | | 110 | -| [min_master_version](variables.tf#L291) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | -| [monitoring_config](variables.tf#L297) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | -| [node_config](variables.tf#L376) | Node-level configuration. | object({…}) | | {} | -| [node_locations](variables.tf#L389) | Zones in which the cluster's nodes are located. | list(string) | | [] | -| [private_cluster_config](variables.tf#L396) | Private cluster configuration. | object({…}) | | null | -| [release_channel](variables.tf#L415) | Release channel for GKE upgrades. | string | | null | +| [enable_addons](variables.tf#L149) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | +| [enable_features](variables.tf#L174) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | +| [issue_client_certificate](variables.tf#L224) | Enable issuing client certificate. | bool | | false | +| [labels](variables.tf#L230) | Cluster resource labels. | map(string) | | {} | +| [logging_config](variables.tf#L242) | Logging configuration. | object({…}) | | {} | +| [maintenance_config](variables.tf#L263) | Maintenance window configuration. | object({…}) | | {…} | +| [max_pods_per_node](variables.tf#L286) | Maximum number of pods per node in this cluster. | number | | 110 | +| [min_master_version](variables.tf#L292) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | +| [monitoring_config](variables.tf#L298) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | +| [node_config](variables.tf#L377) | Node-level configuration. | object({…}) | | {} | +| [node_locations](variables.tf#L390) | Zones in which the cluster's nodes are located. | list(string) | | [] | +| [private_cluster_config](variables.tf#L397) | Private cluster configuration. | object({…}) | | null | +| [release_channel](variables.tf#L416) | Release channel for GKE upgrades. | string | | null | ## Outputs diff --git a/modules/gke-cluster-standard/main.tf b/modules/gke-cluster-standard/main.tf index ddc96b41f8..c76c192e1f 100644 --- a/modules/gke-cluster-standard/main.tf +++ b/modules/gke-cluster-standard/main.tf @@ -73,20 +73,32 @@ resource "google_container_cluster" "cluster" { } } addons_config { + cloudrun_config { + disabled = !var.enable_addons.cloudrun + } + config_connector_config { + enabled = var.enable_addons.config_connector + } dns_cache_config { enabled = var.enable_addons.dns_cache } - http_load_balancing { - disabled = !var.enable_addons.http_load_balancing + gce_persistent_disk_csi_driver_config { + enabled = var.enable_addons.gce_persistent_disk_csi_driver + } + gcp_filestore_csi_driver_config { + enabled = var.enable_addons.gcp_filestore_csi_driver + } + gcs_fuse_csi_driver_config { + enabled = var.enable_addons.gcs_fuse_csi_driver + } + gke_backup_agent_config { + enabled = var.backup_configs.enable_backup_agent } horizontal_pod_autoscaling { disabled = !var.enable_addons.horizontal_pod_autoscaling } - network_policy_config { - disabled = !var.enable_addons.network_policy - } - cloudrun_config { - disabled = !var.enable_addons.cloudrun + http_load_balancing { + disabled = !var.enable_addons.http_load_balancing } istio_config { disabled = var.enable_addons.istio == null @@ -94,23 +106,14 @@ resource "google_container_cluster" "cluster" { try(var.enable_addons.istio.enable_tls, false) ? "AUTH_MUTUAL_TLS" : "AUTH_NONE" ) } - gce_persistent_disk_csi_driver_config { - enabled = var.enable_addons.gce_persistent_disk_csi_driver - } - gcp_filestore_csi_driver_config { - enabled = var.enable_addons.gcp_filestore_csi_driver - } - gcs_fuse_csi_driver_config { - enabled = var.enable_addons.gcs_fuse_csi_driver - } kalm_config { enabled = var.enable_addons.kalm } - config_connector_config { - enabled = var.enable_addons.config_connector + network_policy_config { + disabled = !var.enable_addons.network_policy } - gke_backup_agent_config { - enabled = var.backup_configs.enable_backup_agent + stateful_ha_config { + enabled = var.enable_addons.stateful_ha } } dynamic "authenticator_groups_config" { diff --git a/modules/gke-cluster-standard/variables.tf b/modules/gke-cluster-standard/variables.tf index 4de2276978..017db18ae2 100644 --- a/modules/gke-cluster-standard/variables.tf +++ b/modules/gke-cluster-standard/variables.tf @@ -162,6 +162,7 @@ variable "enable_addons" { })) kalm = optional(bool, false) network_policy = optional(bool, false) + stateful_ha = optional(bool, false) }) default = { horizontal_pod_autoscaling = true