Skip to content

Commit

Permalink
feat!: make promethus configurable (#1715)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyz authored Sep 26, 2023
1 parent 3a9b056 commit ae26016
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 93 deletions.
20 changes: 9 additions & 11 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,15 @@ resource "google_container_cluster" "primary" {
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
{% endif %}
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
{% 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 %}
content{
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,11 @@ resource "google_container_cluster" "primary" {
}
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : []
content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,11 @@ resource "google_container_cluster" "primary" {
}
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : []
content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,11 @@ resource "google_container_cluster" "primary" {
}
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : []
content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,11 @@ resource "google_container_cluster" "primary" {
}
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : []
content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,11 @@ resource "google_container_cluster" "primary" {
}
monitoring_service = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? null : var.monitoring_service
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

for_each = local.cluster_telemetry_type_is_set || local.logmon_config_is_set ? [1] : []
content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions modules/private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,11 @@ resource "google_container_cluster" "primary" {
}
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : []
content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions modules/private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,11 @@ resource "google_container_cluster" "primary" {
}
monitoring_service = local.logmon_config_is_set ? null : var.monitoring_service
dynamic "monitoring_config" {
for_each = length(var.monitoring_enabled_components) > 0 || var.monitoring_enable_managed_prometheus ? [1] : []

for_each = local.logmon_config_is_set || local.logmon_config_is_set ? [1] : []
content {
enable_components = length(var.monitoring_enabled_components) > 0 ? var.monitoring_enabled_components : []

dynamic "managed_prometheus" {
for_each = var.monitoring_enable_managed_prometheus ? [1] : []

content {
enabled = var.monitoring_enable_managed_prometheus
}
enable_components = var.monitoring_enabled_components
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions test/integration/beta_cluster/testdata/TestBetaCluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
"enabled": true
}
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
}
},
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
}
},
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
}
},
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
}
},
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
"enabled": true
}
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
},
"managedPrometheusConfig": {
}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
Expand Down
3 changes: 2 additions & 1 deletion test/integration/simple_zonal/testdata/TestSimpleZonal.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
}
},
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"enableComponents": [
"SYSTEM_COMPONENTS"
]
}
},
"managedPrometheusConfig": {}
},
"monitoringService": "monitoring.googleapis.com/kubernetes",
"name": "CLUSTER_NAME",
Expand Down

0 comments on commit ae26016

Please sign in to comment.