From 0ef7ee4670921d5b6188f948a45dc50f22e4d2df Mon Sep 17 00:00:00 2001
From: luigi-bitonti <93377317+luigi-bitonti@users.noreply.github.com>
Date: Tue, 23 Jan 2024 12:09:22 +0100
Subject: [PATCH] Added beta apis feature (#1999)
---
modules/gke-cluster-autopilot/README.md | 30 ++++++++++----------
modules/gke-cluster-autopilot/main.tf | 20 ++++++++------
modules/gke-cluster-autopilot/variables.tf | 1 +
modules/gke-cluster-standard/README.md | 32 +++++++++++-----------
modules/gke-cluster-standard/main.tf | 18 ++++++++----
modules/gke-cluster-standard/variables.tf | 1 +
6 files changed, 57 insertions(+), 45 deletions(-)
diff --git a/modules/gke-cluster-autopilot/README.md b/modules/gke-cluster-autopilot/README.md
index 39b8d34d..bf8affbe 100644
--- a/modules/gke-cluster-autopilot/README.md
+++ b/modules/gke-cluster-autopilot/README.md
@@ -206,25 +206,25 @@ module "cluster-1" {
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
-| [location](variables.tf#L111) | Autopilot clusters are always regional. | string
| ✓ | |
-| [name](variables.tf#L188) | Cluster name. | string
| ✓ | |
-| [project_id](variables.tf#L224) | Cluster project ID. | string
| ✓ | |
-| [vpc_config](variables.tf#L240) | VPC-level configuration. | object({…})
| ✓ | |
+| [location](variables.tf#L112) | Autopilot clusters are always regional. | string
| ✓ | |
+| [name](variables.tf#L189) | Cluster name. | string
| ✓ | |
+| [project_id](variables.tf#L225) | Cluster project ID. | string
| ✓ | |
+| [vpc_config](variables.tf#L241) | 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#L64) | Enable cluster-level features. Certain features allow configuration. | object({…})
| | {}
|
-| [issue_client_certificate](variables.tf#L99) | Enable issuing client certificate. | bool
| | false
|
-| [labels](variables.tf#L105) | Cluster resource labels. | map(string)
| | null
|
-| [logging_config](variables.tf#L116) | Logging configuration. | object({…})
| | {}
|
-| [maintenance_config](variables.tf#L127) | Maintenance window configuration. | object({…})
| | {…}
|
-| [min_master_version](variables.tf#L150) | Minimum version of the master, defaults to the version of the most recent official release. | string
| | null
|
-| [monitoring_config](variables.tf#L156) | 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#L193) | Configuration for nodes and nodepools. | object({…})
| | {}
|
-| [node_locations](variables.tf#L203) | Zones in which the cluster's nodes are located. | list(string)
| | []
|
-| [private_cluster_config](variables.tf#L210) | Private cluster configuration. | object({…})
| | null
|
-| [release_channel](variables.tf#L229) | Release channel for GKE upgrades. Clusters created in the Autopilot mode must use a release channel. Choose between \"RAPID\", \"REGULAR\", and \"STABLE\". | string
| | "REGULAR"
|
+| [enable_features](variables.tf#L64) | Enable cluster-level features. Certain features allow configuration. | object({…})
| | {}
|
+| [issue_client_certificate](variables.tf#L100) | Enable issuing client certificate. | bool
| | false
|
+| [labels](variables.tf#L106) | Cluster resource labels. | map(string)
| | null
|
+| [logging_config](variables.tf#L117) | Logging configuration. | object({…})
| | {}
|
+| [maintenance_config](variables.tf#L128) | Maintenance window configuration. | object({…})
| | {…}
|
+| [min_master_version](variables.tf#L151) | Minimum version of the master, defaults to the version of the most recent official release. | string
| | null
|
+| [monitoring_config](variables.tf#L157) | 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#L194) | Configuration for nodes and nodepools. | object({…})
| | {}
|
+| [node_locations](variables.tf#L204) | Zones in which the cluster's nodes are located. | list(string)
| | []
|
+| [private_cluster_config](variables.tf#L211) | Private cluster configuration. | object({…})
| | null
|
+| [release_channel](variables.tf#L230) | 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 86517761..73a17dcf 100644
--- a/modules/gke-cluster-autopilot/main.tf
+++ b/modules/gke-cluster-autopilot/main.tf
@@ -58,13 +58,6 @@ resource "google_container_cluster" "cluster" {
}
}
- dynamic "service_external_ips_config" {
- for_each = !var.enable_features.service_external_ips ? [""] : []
- content {
- enabled = var.enable_features.service_external_ips
- }
- }
-
dynamic "authenticator_groups_config" {
for_each = var.enable_features.groups_for_rbac != null ? [""] : []
content {
@@ -109,7 +102,12 @@ resource "google_container_cluster" "cluster" {
cluster_dns_domain = var.enable_features.dns.domain
}
}
-
+ dynamic "enable_k8s_beta_apis" {
+ for_each = var.enable_features.beta_apis != null ? [""] : []
+ content {
+ enabled_apis = var.enable_features.beta_apis
+ }
+ }
dynamic "gateway_api_config" {
for_each = var.enable_features.gateway_api ? [""] : []
content {
@@ -297,6 +295,12 @@ resource "google_container_cluster" "cluster" {
}
}
}
+ dynamic "service_external_ips_config" {
+ for_each = !var.enable_features.service_external_ips ? [""] : []
+ content {
+ enabled = var.enable_features.service_external_ips
+ }
+ }
dynamic "vertical_pod_autoscaling" {
for_each = var.enable_features.vertical_pod_autoscaling ? [""] : []
diff --git a/modules/gke-cluster-autopilot/variables.tf b/modules/gke-cluster-autopilot/variables.tf
index 97c8348b..57089927 100644
--- a/modules/gke-cluster-autopilot/variables.tf
+++ b/modules/gke-cluster-autopilot/variables.tf
@@ -64,6 +64,7 @@ variable "enable_addons" {
variable "enable_features" {
description = "Enable cluster-level features. Certain features allow configuration."
type = object({
+ beta_apis = optional(list(string))
binary_authorization = optional(bool, false)
cost_management = optional(bool, false)
dns = optional(object({
diff --git a/modules/gke-cluster-standard/README.md b/modules/gke-cluster-standard/README.md
index ceff50a8..56ea388d 100644
--- a/modules/gke-cluster-standard/README.md
+++ b/modules/gke-cluster-standard/README.md
@@ -310,27 +310,27 @@ module "cluster-1" {
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
-| [location](variables.tf#L212) | Cluster zone or region. | string
| ✓ | |
-| [name](variables.tf#L323) | Cluster name. | string
| ✓ | |
-| [project_id](variables.tf#L359) | Cluster project id. | string
| ✓ | |
-| [vpc_config](variables.tf#L370) | VPC-level configuration. | object({…})
| ✓ | |
+| [location](variables.tf#L213) | Cluster zone or region. | string
| ✓ | |
+| [name](variables.tf#L324) | Cluster name. | string
| ✓ | |
+| [project_id](variables.tf#L360) | Cluster project id. | string
| ✓ | |
+| [vpc_config](variables.tf#L371) | 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
|
| [deletion_protection](variables.tf#L115) | 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#L122) | Cluster description. | string
| | null
|
| [enable_addons](variables.tf#L128) | Addons enabled in the cluster (true means enabled). | object({…})
| | {…}
|
-| [enable_features](variables.tf#L152) | Enable cluster-level features. Certain features allow configuration. | object({…})
| | {…}
|
-| [issue_client_certificate](variables.tf#L200) | Enable issuing client certificate. | bool
| | false
|
-| [labels](variables.tf#L206) | Cluster resource labels. | map(string)
| | null
|
-| [logging_config](variables.tf#L217) | Logging configuration. | object({…})
| | {}
|
-| [maintenance_config](variables.tf#L238) | Maintenance window configuration. | object({…})
| | {…}
|
-| [max_pods_per_node](variables.tf#L261) | Maximum number of pods per node in this cluster. | number
| | 110
|
-| [min_master_version](variables.tf#L267) | Minimum version of the master, defaults to the version of the most recent official release. | string
| | null
|
-| [monitoring_config](variables.tf#L273) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…})
| | {}
|
-| [node_config](variables.tf#L328) | Node-level configuration. | object({…})
| | {}
|
-| [node_locations](variables.tf#L338) | Zones in which the cluster's nodes are located. | list(string)
| | []
|
-| [private_cluster_config](variables.tf#L345) | Private cluster configuration. | object({…})
| | null
|
-| [release_channel](variables.tf#L364) | Release channel for GKE upgrades. | string
| | null
|
+| [enable_features](variables.tf#L152) | Enable cluster-level features. Certain features allow configuration. | object({…})
| | {…}
|
+| [issue_client_certificate](variables.tf#L201) | Enable issuing client certificate. | bool
| | false
|
+| [labels](variables.tf#L207) | Cluster resource labels. | map(string)
| | null
|
+| [logging_config](variables.tf#L218) | Logging configuration. | object({…})
| | {}
|
+| [maintenance_config](variables.tf#L239) | Maintenance window configuration. | object({…})
| | {…}
|
+| [max_pods_per_node](variables.tf#L262) | Maximum number of pods per node in this cluster. | number
| | 110
|
+| [min_master_version](variables.tf#L268) | Minimum version of the master, defaults to the version of the most recent official release. | string
| | null
|
+| [monitoring_config](variables.tf#L274) | Monitoring configuration. Google Cloud Managed Service for Prometheus is enabled by default. | object({…})
| | {}
|
+| [node_config](variables.tf#L329) | Node-level configuration. | object({…})
| | {}
|
+| [node_locations](variables.tf#L339) | Zones in which the cluster's nodes are located. | list(string)
| | []
|
+| [private_cluster_config](variables.tf#L346) | Private cluster configuration. | object({…})
| | null
|
+| [release_channel](variables.tf#L365) | 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 069f6d24..14d8795f 100644
--- a/modules/gke-cluster-standard/main.tf
+++ b/modules/gke-cluster-standard/main.tf
@@ -110,12 +110,6 @@ resource "google_container_cluster" "cluster" {
enabled = var.backup_configs.enable_backup_agent
}
}
- dynamic "service_external_ips_config" {
- for_each = !var.enable_features.service_external_ips ? [""] : []
- content {
- enabled = var.enable_features.service_external_ips
- }
- }
dynamic "authenticator_groups_config" {
for_each = var.enable_features.groups_for_rbac != null ? [""] : []
content {
@@ -250,6 +244,12 @@ resource "google_container_cluster" "cluster" {
cluster_dns_domain = var.enable_features.dns.domain
}
}
+ dynamic "enable_k8s_beta_apis" {
+ for_each = var.enable_features.beta_apis != null ? [""] : []
+ content {
+ enabled_apis = var.enable_features.beta_apis
+ }
+ }
dynamic "gateway_api_config" {
for_each = var.enable_features.gateway_api ? [""] : []
content {
@@ -452,6 +452,12 @@ resource "google_container_cluster" "cluster" {
}
}
}
+ dynamic "service_external_ips_config" {
+ for_each = !var.enable_features.service_external_ips ? [""] : []
+ content {
+ enabled = var.enable_features.service_external_ips
+ }
+ }
dynamic "vertical_pod_autoscaling" {
for_each = var.enable_features.vertical_pod_autoscaling ? [""] : []
content {
diff --git a/modules/gke-cluster-standard/variables.tf b/modules/gke-cluster-standard/variables.tf
index 1f95c0c8..9fceb4be 100644
--- a/modules/gke-cluster-standard/variables.tf
+++ b/modules/gke-cluster-standard/variables.tf
@@ -152,6 +152,7 @@ variable "enable_addons" {
variable "enable_features" {
description = "Enable cluster-level features. Certain features allow configuration."
type = object({
+ beta_apis = optional(list(string))
binary_authorization = optional(bool, false)
cost_management = optional(bool, false)
dns = optional(object({