From dc24cd10b6042e7f9b704966a2a78bbd61e602cb Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Wed, 17 Sep 2025 09:15:20 +0200 Subject: [PATCH] add support for permissive mode to GKE cluster modules backup plans (#3331) --- modules/gke-cluster-autopilot/README.md | 36 +++++++++--------- modules/gke-cluster-autopilot/main.tf | 2 +- modules/gke-cluster-autopilot/variables.tf | 1 + modules/gke-cluster-standard/README.md | 44 +++++++++++----------- modules/gke-cluster-standard/main.tf | 1 + modules/gke-cluster-standard/variables.tf | 1 + 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/modules/gke-cluster-autopilot/README.md b/modules/gke-cluster-autopilot/README.md index 60f8b72ce..848b59055 100644 --- a/modules/gke-cluster-autopilot/README.md +++ b/modules/gke-cluster-autopilot/README.md @@ -268,25 +268,25 @@ module "cluster-1" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [location](variables.tf#L161) | Autopilot clusters are always regional. | string | ✓ | | -| [name](variables.tf#L240) | Cluster name. | string | ✓ | | -| [project_id](variables.tf#L272) | Cluster project ID. | string | ✓ | | -| [vpc_config](variables.tf#L288) | VPC-level configuration. | object({…}) | ✓ | | +| [location](variables.tf#L162) | Autopilot clusters are always regional. | string | ✓ | | +| [name](variables.tf#L241) | Cluster name. | string | ✓ | | +| [project_id](variables.tf#L273) | Cluster project ID. | string | ✓ | | +| [vpc_config](variables.tf#L289) | VPC-level configuration. | object({…}) | ✓ | | | [access_config](variables.tf#L17) | Control plane endpoint and nodes access configurations. | object({…}) | | {} | -| [backup_configs](variables.tf#L45) | Configuration for Backup for GKE. | object({…}) | | {} | -| [deletion_protection](variables.tf#L66) | 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#L73) | Cluster description. | string | | null | -| [enable_addons](variables.tf#L79) | Addons enabled in the cluster (true means enabled). | object({…}) | | {} | -| [enable_features](variables.tf#L93) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {} | -| [issue_client_certificate](variables.tf#L149) | Enable issuing client certificate. | bool | | false | -| [labels](variables.tf#L155) | Cluster resource labels. | map(string) | | null | -| [logging_config](variables.tf#L166) | Logging configuration. | object({…}) | | {} | -| [maintenance_config](variables.tf#L177) | Maintenance window configuration. | object({…}) | | {…} | -| [min_master_version](variables.tf#L200) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | -| [monitoring_config](variables.tf#L206) | 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_config](variables.tf#L245) | Configuration for nodes and nodepools. | object({…}) | | {} | -| [node_locations](variables.tf#L265) | Zones in which the cluster's nodes are located. | list(string) | | [] | -| [release_channel](variables.tf#L277) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | string | | "REGULAR" | +| [backup_configs](variables.tf#L45) | Configuration for Backup for GKE. | object({…}) | | {} | +| [deletion_protection](variables.tf#L67) | 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#L74) | Cluster description. | string | | null | +| [enable_addons](variables.tf#L80) | Addons enabled in the cluster (true means enabled). | object({…}) | | {} | +| [enable_features](variables.tf#L94) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {} | +| [issue_client_certificate](variables.tf#L150) | Enable issuing client certificate. | bool | | false | +| [labels](variables.tf#L156) | Cluster resource labels. | map(string) | | null | +| [logging_config](variables.tf#L167) | Logging configuration. | object({…}) | | {} | +| [maintenance_config](variables.tf#L178) | Maintenance window configuration. | object({…}) | | {…} | +| [min_master_version](variables.tf#L201) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | +| [monitoring_config](variables.tf#L207) | 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_config](variables.tf#L246) | Configuration for nodes and nodepools. | object({…}) | | {} | +| [node_locations](variables.tf#L266) | Zones in which the cluster's nodes are located. | list(string) | | [] | +| [release_channel](variables.tf#L278) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | string | | "REGULAR" | ## Outputs diff --git a/modules/gke-cluster-autopilot/main.tf b/modules/gke-cluster-autopilot/main.tf index 9cc7ec7b9..24f82eeeb 100644 --- a/modules/gke-cluster-autopilot/main.tf +++ b/modules/gke-cluster-autopilot/main.tf @@ -396,7 +396,7 @@ resource "google_gke_backup_backup_plan" "backup_plan" { backup_config { include_volume_data = each.value.include_volume_data include_secrets = each.value.include_secrets - + permissive_mode = each.value.permissive_mode dynamic "encryption_key" { for_each = each.value.encryption_key != null ? [""] : [] content { diff --git a/modules/gke-cluster-autopilot/variables.tf b/modules/gke-cluster-autopilot/variables.tf index bbeb90e06..94b19b769 100644 --- a/modules/gke-cluster-autopilot/variables.tf +++ b/modules/gke-cluster-autopilot/variables.tf @@ -52,6 +52,7 @@ variable "backup_configs" { include_volume_data = optional(bool, true) labels = optional(map(string)) namespaces = optional(list(string)) + permissive_mode = optional(bool) region = string schedule = string retention_policy_days = optional(string) diff --git a/modules/gke-cluster-standard/README.md b/modules/gke-cluster-standard/README.md index ec711568c..d88f8c624 100644 --- a/modules/gke-cluster-standard/README.md +++ b/modules/gke-cluster-standard/README.md @@ -510,29 +510,29 @@ module "cluster-1" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [location](variables.tf#L281) | Cluster zone or region. | string | ✓ | | -| [name](variables.tf#L396) | Cluster name. | string | ✓ | | -| [project_id](variables.tf#L447) | Cluster project id. | string | ✓ | | -| [vpc_config](variables.tf#L458) | VPC-level configuration. | object({…}) | ✓ | | +| [location](variables.tf#L282) | Cluster zone or region. | string | ✓ | | +| [name](variables.tf#L397) | Cluster name. | string | ✓ | | +| [project_id](variables.tf#L448) | Cluster project id. | string | ✓ | | +| [vpc_config](variables.tf#L459) | VPC-level configuration. | object({…}) | ✓ | | | [access_config](variables.tf#L17) | Control plane endpoint and nodes access configurations. | object({…}) | | {} | -| [backup_configs](variables.tf#L45) | Configuration for Backup for GKE. | object({…}) | | {} | -| [cluster_autoscaling](variables.tf#L67) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | object({…}) | | null | -| [default_nodepool](variables.tf#L147) | Enable default nodepool. | object({…}) | | {} | -| [deletion_protection](variables.tf#L165) | 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#L172) | Cluster description. | string | | null | -| [enable_addons](variables.tf#L178) | Addons enabled in the cluster (true means enabled). | object({…}) | | {} | -| [enable_features](variables.tf#L200) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {} | -| [issue_client_certificate](variables.tf#L268) | Enable issuing client certificate. | bool | | false | -| [labels](variables.tf#L274) | Cluster resource labels. | map(string) | | {} | -| [logging_config](variables.tf#L286) | Logging configuration. | object({…}) | | {} | -| [maintenance_config](variables.tf#L307) | Maintenance window configuration. | object({…}) | | {…} | -| [max_pods_per_node](variables.tf#L330) | Maximum number of pods per node in this cluster. | number | | 110 | -| [min_master_version](variables.tf#L336) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | -| [monitoring_config](variables.tf#L342) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | -| [node_config](variables.tf#L401) | Node-level configuration. | object({…}) | | {} | -| [node_locations](variables.tf#L423) | Zones in which the cluster's nodes are located. | list(string) | | [] | -| [node_pool_auto_config](variables.tf#L430) | Node pool configs that apply to auto-provisioned node pools in autopilot clusters and node auto-provisioning-enabled clusters. | object({…}) | | {} | -| [release_channel](variables.tf#L452) | Release channel for GKE upgrades. | string | | null | +| [backup_configs](variables.tf#L45) | Configuration for Backup for GKE. | object({…}) | | {} | +| [cluster_autoscaling](variables.tf#L68) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | object({…}) | | null | +| [default_nodepool](variables.tf#L148) | Enable default nodepool. | object({…}) | | {} | +| [deletion_protection](variables.tf#L166) | 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#L173) | Cluster description. | string | | null | +| [enable_addons](variables.tf#L179) | Addons enabled in the cluster (true means enabled). | object({…}) | | {} | +| [enable_features](variables.tf#L201) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {} | +| [issue_client_certificate](variables.tf#L269) | Enable issuing client certificate. | bool | | false | +| [labels](variables.tf#L275) | Cluster resource labels. | map(string) | | {} | +| [logging_config](variables.tf#L287) | Logging configuration. | object({…}) | | {} | +| [maintenance_config](variables.tf#L308) | Maintenance window configuration. | object({…}) | | {…} | +| [max_pods_per_node](variables.tf#L331) | Maximum number of pods per node in this cluster. | number | | 110 | +| [min_master_version](variables.tf#L337) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | +| [monitoring_config](variables.tf#L343) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…}) | | {} | +| [node_config](variables.tf#L402) | Node-level configuration. | object({…}) | | {} | +| [node_locations](variables.tf#L424) | Zones in which the cluster's nodes are located. | list(string) | | [] | +| [node_pool_auto_config](variables.tf#L431) | Node pool configs that apply to auto-provisioned node pools in autopilot clusters and node auto-provisioning-enabled clusters. | object({…}) | | {} | +| [release_channel](variables.tf#L453) | 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 8c194b177..087e5c46e 100644 --- a/modules/gke-cluster-standard/main.tf +++ b/modules/gke-cluster-standard/main.tf @@ -629,6 +629,7 @@ resource "google_gke_backup_backup_plan" "backup_plan" { backup_config { include_volume_data = each.value.include_volume_data include_secrets = each.value.include_secrets + permissive_mode = each.value.permissive_mode dynamic "encryption_key" { for_each = each.value.encryption_key != null ? [""] : [] content { diff --git a/modules/gke-cluster-standard/variables.tf b/modules/gke-cluster-standard/variables.tf index c2b146278..f3908966c 100644 --- a/modules/gke-cluster-standard/variables.tf +++ b/modules/gke-cluster-standard/variables.tf @@ -54,6 +54,7 @@ variable "backup_configs" { include_volume_data = optional(bool, true) labels = optional(map(string)) namespaces = optional(list(string)) + permissive_mode = optional(bool) schedule = optional(string) retention_policy_days = optional(number) retention_policy_lock = optional(bool, false)