diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index 0557adf505..b78bd4e247 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -94,13 +94,6 @@ resource "google_container_cluster" "primary" { } } {% endif %} -{% if autopilot_cluster != true %} - # only one of logging/monitoring_service or logging/monitoring_config can be specified - {% if beta_cluster %} - logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service - {% else %} - logging_service = local.logmon_config_is_set ? null : var.logging_service - {% endif %} dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -108,19 +101,20 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - {% if beta_cluster %} - monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service - {% else %} - monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service - {% endif %} + dynamic "monitoring_config" { + {% if autopilot_cluster != true %} {% if beta_cluster %} for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : [] {% else %} for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : [] {% endif %} + {% else %} + for_each = length(var.monitoring_enabled_components) > 0 ? [1] : [] + {% endif %} content{ enable_components = var.monitoring_enabled_components + {% if autopilot_cluster != true %} managed_prometheus { enabled = var.monitoring_enable_managed_prometheus } @@ -128,8 +122,23 @@ resource "google_container_cluster" "primary" { enable_metrics = var.monitoring_enable_observability_metrics enable_relay = var.monitoring_enable_observability_relay } + {% endif %} } } + +{% if autopilot_cluster != true %} + # only one of logging/monitoring_service or logging/monitoring_config can be specified + {% if beta_cluster %} + logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service + {% else %} + logging_service = local.logmon_config_is_set ? null : var.logging_service + {% endif %} + {% if beta_cluster %} + monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + {% else %} + monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service + {% endif %} + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/autogen/main/variables.tf.tmpl b/autogen/main/variables.tf.tmpl index 6315b51cb7..b387fc8ccd 100644 --- a/autogen/main/variables.tf.tmpl +++ b/autogen/main/variables.tf.tmpl @@ -852,6 +852,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components: + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components: + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + {% if autopilot_cluster != true %} variable "monitoring_enable_managed_prometheus" { type = bool @@ -871,18 +918,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days." diff --git a/cluster.tf b/cluster.tf index b7417ee759..274c422c19 100644 --- a/cluster.tf +++ b/cluster.tf @@ -80,8 +80,6 @@ resource "google_container_cluster" "primary" { min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version - # only one of logging/monitoring_service or logging/monitoring_config can be specified - logging_service = local.logmon_config_is_set ? null : var.logging_service dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -89,7 +87,7 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service + dynamic "monitoring_config" { for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : [] content { @@ -103,6 +101,11 @@ resource "google_container_cluster" "primary" { } } } + + # only one of logging/monitoring_service or logging/monitoring_config can be specified + logging_service = local.logmon_config_is_set ? null : var.logging_service + monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/modules/beta-autopilot-private-cluster/README.md b/modules/beta-autopilot-private-cluster/README.md index d40b2dd272..ebe6ad6382 100644 --- a/modules/beta-autopilot-private-cluster/README.md +++ b/modules/beta-autopilot-private-cluster/README.md @@ -121,6 +121,7 @@ Then perform the following commands on the root folder: | ip\_range\_services | The _name_ of the secondary subnet range to use for services | `string` | n/a | yes | | issue\_client\_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | `bool` | `false` | no | | kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | `string` | `"latest"` | no | +| logging\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, APISERVER, CONTROLLER\_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | `list(string)` | `[]` | no | | logging\_variant | (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX\_THROUGHPUT. | `string` | `null` | no | | maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no | | maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string }))` | `[]` | no | @@ -129,6 +130,7 @@ Then perform the following commands on the root folder: | master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | `list(object({ cidr_block = string, display_name = string }))` | `[]` | no | | master\_global\_access\_enabled | Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint. | `bool` | `true` | no | | master\_ipv4\_cidr\_block | The IP range in CIDR notation to use for the hosted master network. Optional for Autopilot clusters. | `string` | `null` | no | +| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER\_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration. | `list(string)` | `[]` | no | | name | The name of the cluster (required) | `string` | n/a | yes | | network | The VPC network to host the cluster in (required) | `string` | n/a | yes | | network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no | diff --git a/modules/beta-autopilot-private-cluster/cluster.tf b/modules/beta-autopilot-private-cluster/cluster.tf index 478f1a1d7f..3b2e1efa4b 100644 --- a/modules/beta-autopilot-private-cluster/cluster.tf +++ b/modules/beta-autopilot-private-cluster/cluster.tf @@ -72,6 +72,21 @@ resource "google_container_cluster" "primary" { min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version + dynamic "logging_config" { + for_each = length(var.logging_enabled_components) > 0 ? [1] : [] + + content { + enable_components = var.logging_enabled_components + } + } + + dynamic "monitoring_config" { + for_each = length(var.monitoring_enabled_components) > 0 ? [1] : [] + content { + enable_components = var.monitoring_enabled_components + } + } + cluster_autoscaling { dynamic "auto_provisioning_defaults" { for_each = (var.create_service_account || var.service_account != "") ? [1] : [] diff --git a/modules/beta-autopilot-private-cluster/variables.tf b/modules/beta-autopilot-private-cluster/variables.tf index 6e63b95766..8133c5e89c 100644 --- a/modules/beta-autopilot-private-cluster/variables.tf +++ b/modules/beta-autopilot-private-cluster/variables.tf @@ -519,6 +519,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "enable_l4_ilb_subsetting" { type = bool description = "Enable L4 ILB Subsetting on the cluster" diff --git a/modules/beta-autopilot-public-cluster/README.md b/modules/beta-autopilot-public-cluster/README.md index ba7f8a5849..3a81f58166 100644 --- a/modules/beta-autopilot-public-cluster/README.md +++ b/modules/beta-autopilot-public-cluster/README.md @@ -112,12 +112,14 @@ Then perform the following commands on the root folder: | ip\_range\_services | The _name_ of the secondary subnet range to use for services | `string` | n/a | yes | | issue\_client\_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | `bool` | `false` | no | | kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | `string` | `"latest"` | no | +| logging\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, APISERVER, CONTROLLER\_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration. | `list(string)` | `[]` | no | | logging\_variant | (Optional) The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX\_THROUGHPUT. | `string` | `null` | no | | maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no | | maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string, exclusion_scope = string }))` | `[]` | no | | maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no | | maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no | | master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | `list(object({ cidr_block = string, display_name = string }))` | `[]` | no | +| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER\_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration. | `list(string)` | `[]` | no | | name | The name of the cluster (required) | `string` | n/a | yes | | network | The VPC network to host the cluster in (required) | `string` | n/a | yes | | network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no | diff --git a/modules/beta-autopilot-public-cluster/cluster.tf b/modules/beta-autopilot-public-cluster/cluster.tf index 8c60b02120..4baca3ecac 100644 --- a/modules/beta-autopilot-public-cluster/cluster.tf +++ b/modules/beta-autopilot-public-cluster/cluster.tf @@ -72,6 +72,21 @@ resource "google_container_cluster" "primary" { min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version + dynamic "logging_config" { + for_each = length(var.logging_enabled_components) > 0 ? [1] : [] + + content { + enable_components = var.logging_enabled_components + } + } + + dynamic "monitoring_config" { + for_each = length(var.monitoring_enabled_components) > 0 ? [1] : [] + content { + enable_components = var.monitoring_enabled_components + } + } + cluster_autoscaling { dynamic "auto_provisioning_defaults" { for_each = (var.create_service_account || var.service_account != "") ? [1] : [] diff --git a/modules/beta-autopilot-public-cluster/variables.tf b/modules/beta-autopilot-public-cluster/variables.tf index 9070e43cb8..3d74358981 100644 --- a/modules/beta-autopilot-public-cluster/variables.tf +++ b/modules/beta-autopilot-public-cluster/variables.tf @@ -483,6 +483,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "enable_l4_ilb_subsetting" { type = bool description = "Enable L4 ILB Subsetting on the cluster" diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index 2b2fb297b0..1b0df01ed9 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -86,8 +86,6 @@ resource "google_container_cluster" "primary" { type = var.cluster_telemetry_type } } - # only one of logging/monitoring_service or logging/monitoring_config can be specified - logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -95,7 +93,7 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + dynamic "monitoring_config" { for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : [] content { @@ -109,6 +107,11 @@ resource "google_container_cluster" "primary" { } } } + + # only one of logging/monitoring_service or logging/monitoring_config can be specified + logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/modules/beta-private-cluster-update-variant/variables.tf b/modules/beta-private-cluster-update-variant/variables.tf index 278a5f3bbc..a911ba584b 100644 --- a/modules/beta-private-cluster-update-variant/variables.tf +++ b/modules/beta-private-cluster-update-variant/variables.tf @@ -812,6 +812,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "monitoring_enable_managed_prometheus" { type = bool description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled." @@ -830,18 +877,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days." diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 42eac444d1..cbce275c59 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -86,8 +86,6 @@ resource "google_container_cluster" "primary" { type = var.cluster_telemetry_type } } - # only one of logging/monitoring_service or logging/monitoring_config can be specified - logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -95,7 +93,7 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + dynamic "monitoring_config" { for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : [] content { @@ -109,6 +107,11 @@ resource "google_container_cluster" "primary" { } } } + + # only one of logging/monitoring_service or logging/monitoring_config can be specified + logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/modules/beta-private-cluster/variables.tf b/modules/beta-private-cluster/variables.tf index 278a5f3bbc..a911ba584b 100644 --- a/modules/beta-private-cluster/variables.tf +++ b/modules/beta-private-cluster/variables.tf @@ -812,6 +812,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "monitoring_enable_managed_prometheus" { type = bool description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled." @@ -830,18 +877,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days." diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index 4f8822a9a9..a449aacd27 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -86,8 +86,6 @@ resource "google_container_cluster" "primary" { type = var.cluster_telemetry_type } } - # only one of logging/monitoring_service or logging/monitoring_config can be specified - logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -95,7 +93,7 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + dynamic "monitoring_config" { for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : [] content { @@ -109,6 +107,11 @@ resource "google_container_cluster" "primary" { } } } + + # only one of logging/monitoring_service or logging/monitoring_config can be specified + logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/modules/beta-public-cluster-update-variant/variables.tf b/modules/beta-public-cluster-update-variant/variables.tf index 03658fa0f3..f523ff1f83 100644 --- a/modules/beta-public-cluster-update-variant/variables.tf +++ b/modules/beta-public-cluster-update-variant/variables.tf @@ -776,6 +776,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "monitoring_enable_managed_prometheus" { type = bool description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled." @@ -794,18 +841,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days." diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 38849100ff..7ce9ad4f88 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -86,8 +86,6 @@ resource "google_container_cluster" "primary" { type = var.cluster_telemetry_type } } - # only one of logging/monitoring_service or logging/monitoring_config can be specified - logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -95,7 +93,7 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + dynamic "monitoring_config" { for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : [] content { @@ -109,6 +107,11 @@ resource "google_container_cluster" "primary" { } } } + + # only one of logging/monitoring_service or logging/monitoring_config can be specified + logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/modules/beta-public-cluster/variables.tf b/modules/beta-public-cluster/variables.tf index 03658fa0f3..f523ff1f83 100644 --- a/modules/beta-public-cluster/variables.tf +++ b/modules/beta-public-cluster/variables.tf @@ -776,6 +776,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "monitoring_enable_managed_prometheus" { type = bool description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled." @@ -794,18 +841,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days." diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index 27a0dadf22..a21ca0945b 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -80,8 +80,6 @@ resource "google_container_cluster" "primary" { min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version - # only one of logging/monitoring_service or logging/monitoring_config can be specified - logging_service = local.logmon_config_is_set ? null : var.logging_service dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -89,7 +87,7 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service + dynamic "monitoring_config" { for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : [] content { @@ -103,6 +101,11 @@ resource "google_container_cluster" "primary" { } } } + + # only one of logging/monitoring_service or logging/monitoring_config can be specified + logging_service = local.logmon_config_is_set ? null : var.logging_service + monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/modules/private-cluster-update-variant/variables.tf b/modules/private-cluster-update-variant/variables.tf index dc92568ca6..60e24762df 100644 --- a/modules/private-cluster-update-variant/variables.tf +++ b/modules/private-cluster-update-variant/variables.tf @@ -783,6 +783,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "monitoring_enable_managed_prometheus" { type = bool description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled." @@ -801,18 +848,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days." diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index 1d87e0249d..928026d5e8 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -80,8 +80,6 @@ resource "google_container_cluster" "primary" { min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version - # only one of logging/monitoring_service or logging/monitoring_config can be specified - logging_service = local.logmon_config_is_set ? null : var.logging_service dynamic "logging_config" { for_each = length(var.logging_enabled_components) > 0 ? [1] : [] @@ -89,7 +87,7 @@ resource "google_container_cluster" "primary" { enable_components = var.logging_enabled_components } } - monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service + dynamic "monitoring_config" { for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : [] content { @@ -103,6 +101,11 @@ resource "google_container_cluster" "primary" { } } } + + # only one of logging/monitoring_service or logging/monitoring_config can be specified + logging_service = local.logmon_config_is_set ? null : var.logging_service + monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service + cluster_autoscaling { enabled = var.cluster_autoscaling.enabled dynamic "auto_provisioning_defaults" { diff --git a/modules/private-cluster/variables.tf b/modules/private-cluster/variables.tf index dc92568ca6..60e24762df 100644 --- a/modules/private-cluster/variables.tf +++ b/modules/private-cluster/variables.tf @@ -783,6 +783,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "monitoring_enable_managed_prometheus" { type = bool description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled." @@ -801,18 +848,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days." diff --git a/variables.tf b/variables.tf index c3b7893e0c..18806cf005 100644 --- a/variables.tf +++ b/variables.tf @@ -747,6 +747,53 @@ variable "timeouts" { } } +variable "monitoring_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.monitoring_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "SCHEDULER", + "CONTROLLER_MANAGER", + "STORAGE", + "HPA", + "POD", + "DAEMONSET", + "DEPLOYMENT", + "STATEFULSET", + "WORKLOADS", + "KUBELET", + "CADVISOR", + "DCGM" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, WORKLOADS, KUBELET, CADVISOR and DCGM." + } +} + +variable "logging_enabled_components" { + type = list(string) + description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." + default = [] + validation { + condition = alltrue([ + for c in var.logging_enabled_components : + contains([ + "SYSTEM_COMPONENTS", + "APISERVER", + "CONTROLLER_MANAGER", + "SCHEDULER", + "WORKLOADS" + ], c) + ]) + error_message = "Valid values are SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS." + } +} + variable "monitoring_enable_managed_prometheus" { type = bool description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled." @@ -765,18 +812,6 @@ variable "monitoring_enable_observability_relay" { default = false } -variable "monitoring_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM. In beta provider, WORKLOADS is supported on top of those 12 values. (WORKLOADS is deprecated and removed in GKE 1.24.) KUBELET and CADVISOR are only supported in GKE 1.29.3-gke.1093000 and above. Empty list is default GKE configuration." - default = [] -} - -variable "logging_enabled_components" { - type = list(string) - description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration." - default = [] -} - variable "enable_kubernetes_alpha" { type = bool description = "Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days."