Skip to content

Commit 47f746d

Browse files
committed
chore: shuffle blocks and props around for autopilot
1 parent 7a80653 commit 47f746d

File tree

19 files changed

+219
-169
lines changed

19 files changed

+219
-169
lines changed

autogen/main/cluster.tf.tmpl

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,42 +94,53 @@ resource "google_container_cluster" "primary" {
9494
}
9595
}
9696
{% endif %}
97-
{% if autopilot_cluster != true %}
98-
# only one of logging/monitoring_service or logging/monitoring_config can be specified
99-
{% if beta_cluster %}
100-
logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service
101-
{% else %}
102-
logging_service = local.logmon_config_is_set ? null : var.logging_service
103-
{% endif %}
97+
10498
dynamic "logging_config" {
10599
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
106100

107101
content {
108102
enable_components = var.logging_enabled_components
109103
}
110104
}
111-
{% if beta_cluster %}
112-
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
113-
{% else %}
114-
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
115-
{% endif %}
105+
116106
dynamic "monitoring_config" {
107+
{% if autopilot_cluster != true %}
117108
{% if beta_cluster %}
118109
for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : []
119110
{% else %}
120111
for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : []
121112
{% endif %}
113+
{% else %}
114+
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
115+
{% endif %}
122116
content{
123117
enable_components = var.monitoring_enabled_components
118+
{% if autopilot_cluster != true %}
124119
managed_prometheus {
125120
enabled = var.monitoring_enable_managed_prometheus
126121
}
127122
advanced_datapath_observability_config {
128123
enable_metrics = var.monitoring_enable_observability_metrics
129124
enable_relay = var.monitoring_enable_observability_relay
130125
}
126+
{% endif %}
131127
}
132128
}
129+
130+
{% if autopilot_cluster != true %}
131+
# only one of logging/monitoring_service or logging/monitoring_config can be specified
132+
{% if beta_cluster %}
133+
logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service
134+
{% else %}
135+
logging_service = local.logmon_config_is_set ? null : var.logging_service
136+
{% endif %}
137+
138+
{% if beta_cluster %}
139+
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
140+
{% else %}
141+
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
142+
{% endif %}
143+
133144
cluster_autoscaling {
134145
enabled = var.cluster_autoscaling.enabled
135146
dynamic "auto_provisioning_defaults" {

cluster.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,15 @@ resource "google_container_cluster" "primary" {
8080

8181
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version
8282

83-
# only one of logging/monitoring_service or logging/monitoring_config can be specified
84-
logging_service = local.logmon_config_is_set ? null : var.logging_service
83+
8584
dynamic "logging_config" {
8685
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
8786

8887
content {
8988
enable_components = var.logging_enabled_components
9089
}
9190
}
92-
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
91+
9392
dynamic "monitoring_config" {
9493
for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : []
9594
content {
@@ -103,6 +102,12 @@ resource "google_container_cluster" "primary" {
103102
}
104103
}
105104
}
105+
106+
# only one of logging/monitoring_service or logging/monitoring_config can be specified
107+
logging_service = local.logmon_config_is_set ? null : var.logging_service
108+
109+
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
110+
106111
cluster_autoscaling {
107112
enabled = var.cluster_autoscaling.enabled
108113
dynamic "auto_provisioning_defaults" {

modules/beta-autopilot-private-cluster/cluster.tf

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ resource "google_container_cluster" "primary" {
7272

7373
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version
7474

75+
76+
dynamic "logging_config" {
77+
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
78+
79+
content {
80+
enable_components = var.logging_enabled_components
81+
}
82+
}
83+
84+
dynamic "monitoring_config" {
85+
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
86+
content {
87+
enable_components = var.monitoring_enabled_components
88+
}
89+
}
90+
7591
cluster_autoscaling {
7692
dynamic "auto_provisioning_defaults" {
7793
for_each = (var.create_service_account || var.service_account != "") ? [1] : []
@@ -347,21 +363,6 @@ resource "google_container_cluster" "primary" {
347363
}
348364
}
349365

350-
dynamic "logging_config" {
351-
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
352-
353-
content {
354-
enable_components = var.logging_enabled_components
355-
}
356-
}
357-
358-
dynamic "monitoring_config" {
359-
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
360-
content {
361-
enable_components = var.monitoring_enabled_components
362-
}
363-
}
364-
365366
node_pool_defaults {
366367
node_config_defaults {
367368
logging_variant = var.logging_variant

modules/beta-autopilot-private-cluster/variables.tf

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,6 @@ variable "identity_namespace" {
313313
default = "enabled"
314314
}
315315

316-
variable "monitoring_enabled_components" {
317-
type = list(string)
318-
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."
319-
default = []
320-
}
321-
322-
variable "logging_enabled_components" {
323-
type = list(string)
324-
description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration."
325-
default = []
326-
}
327316

328317
variable "release_channel" {
329318
type = string
@@ -524,6 +513,18 @@ variable "timeouts" {
524513
}
525514
}
526515

516+
variable "monitoring_enabled_components" {
517+
type = list(string)
518+
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."
519+
default = []
520+
}
521+
522+
variable "logging_enabled_components" {
523+
type = list(string)
524+
description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration."
525+
default = []
526+
}
527+
527528
variable "enable_l4_ilb_subsetting" {
528529
type = bool
529530
description = "Enable L4 ILB Subsetting on the cluster"

modules/beta-autopilot-public-cluster/cluster.tf

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ resource "google_container_cluster" "primary" {
7272

7373
min_master_version = var.release_channel == null || var.release_channel == "UNSPECIFIED" ? local.master_version : var.kubernetes_version == "latest" ? null : var.kubernetes_version
7474

75+
76+
dynamic "logging_config" {
77+
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
78+
79+
content {
80+
enable_components = var.logging_enabled_components
81+
}
82+
}
83+
84+
dynamic "monitoring_config" {
85+
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
86+
content {
87+
enable_components = var.monitoring_enabled_components
88+
}
89+
}
90+
7591
cluster_autoscaling {
7692
dynamic "auto_provisioning_defaults" {
7793
for_each = (var.create_service_account || var.service_account != "") ? [1] : []
@@ -326,21 +342,6 @@ resource "google_container_cluster" "primary" {
326342
}
327343
}
328344

329-
dynamic "logging_config" {
330-
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
331-
332-
content {
333-
enable_components = var.logging_enabled_components
334-
}
335-
}
336-
337-
dynamic "monitoring_config" {
338-
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
339-
content {
340-
enable_components = var.monitoring_enabled_components
341-
}
342-
}
343-
344345
node_pool_defaults {
345346
node_config_defaults {
346347
logging_variant = var.logging_variant

modules/beta-autopilot-public-cluster/variables.tf

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,6 @@ variable "identity_namespace" {
277277
default = "enabled"
278278
}
279279

280-
variable "monitoring_enabled_components" {
281-
type = list(string)
282-
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."
283-
default = []
284-
}
285-
286-
variable "logging_enabled_components" {
287-
type = list(string)
288-
description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration."
289-
default = []
290-
}
291280

292281
variable "release_channel" {
293282
type = string
@@ -488,6 +477,18 @@ variable "timeouts" {
488477
}
489478
}
490479

480+
variable "monitoring_enabled_components" {
481+
type = list(string)
482+
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."
483+
default = []
484+
}
485+
486+
variable "logging_enabled_components" {
487+
type = list(string)
488+
description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration."
489+
default = []
490+
}
491+
491492
variable "enable_l4_ilb_subsetting" {
492493
type = bool
493494
description = "Enable L4 ILB Subsetting on the cluster"

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,15 @@ resource "google_container_cluster" "primary" {
8686
type = var.cluster_telemetry_type
8787
}
8888
}
89-
# only one of logging/monitoring_service or logging/monitoring_config can be specified
90-
logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service
89+
9190
dynamic "logging_config" {
9291
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
9392

9493
content {
9594
enable_components = var.logging_enabled_components
9695
}
9796
}
98-
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
97+
9998
dynamic "monitoring_config" {
10099
for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : []
101100
content {
@@ -109,6 +108,12 @@ resource "google_container_cluster" "primary" {
109108
}
110109
}
111110
}
111+
112+
# only one of logging/monitoring_service or logging/monitoring_config can be specified
113+
logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service
114+
115+
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
116+
112117
cluster_autoscaling {
113118
enabled = var.cluster_autoscaling.enabled
114119
dynamic "auto_provisioning_defaults" {

modules/beta-private-cluster-update-variant/variables.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,18 @@ variable "timeouts" {
812812
}
813813
}
814814

815+
variable "monitoring_enabled_components" {
816+
type = list(string)
817+
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."
818+
default = []
819+
}
820+
821+
variable "logging_enabled_components" {
822+
type = list(string)
823+
description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration."
824+
default = []
825+
}
826+
815827
variable "monitoring_enable_managed_prometheus" {
816828
type = bool
817829
description = "Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled."
@@ -830,18 +842,6 @@ variable "monitoring_enable_observability_relay" {
830842
default = false
831843
}
832844

833-
variable "monitoring_enabled_components" {
834-
type = list(string)
835-
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."
836-
default = []
837-
}
838-
839-
variable "logging_enabled_components" {
840-
type = list(string)
841-
description = "List of services to monitor: SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS. Empty list is default GKE configuration."
842-
default = []
843-
}
844-
845845
variable "enable_kubernetes_alpha" {
846846
type = bool
847847
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."

modules/beta-private-cluster/cluster.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,15 @@ resource "google_container_cluster" "primary" {
8686
type = var.cluster_telemetry_type
8787
}
8888
}
89-
# only one of logging/monitoring_service or logging/monitoring_config can be specified
90-
logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service
89+
9190
dynamic "logging_config" {
9291
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
9392

9493
content {
9594
enable_components = var.logging_enabled_components
9695
}
9796
}
98-
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
97+
9998
dynamic "monitoring_config" {
10099
for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : []
101100
content {
@@ -109,6 +108,12 @@ resource "google_container_cluster" "primary" {
109108
}
110109
}
111110
}
111+
112+
# only one of logging/monitoring_service or logging/monitoring_config can be specified
113+
logging_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.logging_service
114+
115+
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
116+
112117
cluster_autoscaling {
113118
enabled = var.cluster_autoscaling.enabled
114119
dynamic "auto_provisioning_defaults" {

0 commit comments

Comments
 (0)