Skip to content

Commit 04c88e6

Browse files
feat: add auto_monitoring_config in GKE managed_prometheus (#2420)
Co-authored-by: Andrew Peabody <[email protected]>
1 parent 839093c commit 04c88e6

File tree

30 files changed

+219
-0
lines changed

30 files changed

+219
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Then perform the following commands on the root folder:
225225
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
226226
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
227227
| 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 |
228+
| monitoring\_auto\_monitoring\_config\_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | `string` | `"NONE"` | no |
228229
| monitoring\_enable\_managed\_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `null` | no |
229230
| monitoring\_enable\_observability\_metrics | Whether or not the advanced datapath metrics are enabled. | `bool` | `false` | no |
230231
| monitoring\_enable\_observability\_relay | Whether or not the advanced datapath relay is enabled. | `bool` | `false` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ resource "google_container_cluster" "primary" {
132132
{% if autopilot_cluster != true %}
133133
managed_prometheus {
134134
enabled = var.monitoring_enable_managed_prometheus == null ? false : var.monitoring_enable_managed_prometheus
135+
dynamic "auto_monitoring_config" {
136+
for_each = var.monitoring_enable_managed_prometheus == true && var.monitoring_auto_monitoring_config_scope != null ? [1] : []
137+
content {
138+
scope = var.monitoring_auto_monitoring_config_scope
139+
}
140+
}
135141
}
136142
advanced_datapath_observability_config {
137143
enable_metrics = var.monitoring_enable_observability_metrics

autogen/main/variables.tf.tmpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,23 @@ variable "monitoring_enable_managed_prometheus" {
10291029
default = null
10301030
}
10311031

1032+
variable "monitoring_auto_monitoring_config_scope" {
1033+
default = "NONE"
1034+
description = "Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE"
1035+
type = string
1036+
1037+
validation {
1038+
condition = contains(
1039+
[
1040+
"ALL",
1041+
"NONE",
1042+
],
1043+
var.monitoring_auto_monitoring_config_scope
1044+
)
1045+
error_message = "'monitoring_auto_monitoring_config_scope' value is invalid"
1046+
}
1047+
}
1048+
10321049
variable "monitoring_enable_observability_metrics" {
10331050
type = bool
10341051
description = "Whether or not the advanced datapath metrics are enabled."

cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ resource "google_container_cluster" "primary" {
109109
enable_components = var.monitoring_enabled_components
110110
managed_prometheus {
111111
enabled = var.monitoring_enable_managed_prometheus == null ? false : var.monitoring_enable_managed_prometheus
112+
dynamic "auto_monitoring_config" {
113+
for_each = var.monitoring_enable_managed_prometheus == true && var.monitoring_auto_monitoring_config_scope != null ? [1] : []
114+
content {
115+
scope = var.monitoring_auto_monitoring_config_scope
116+
}
117+
}
112118
}
113119
advanced_datapath_observability_config {
114120
enable_metrics = var.monitoring_enable_observability_metrics

metadata.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ spec:
728728
- name: monitoring_enable_managed_prometheus
729729
description: Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled.
730730
varType: bool
731+
- name: monitoring_auto_monitoring_config_scope
732+
description: "Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE"
733+
varType: string
734+
defaultValue: NONE
731735
- name: monitoring_enable_observability_metrics
732736
description: Whether or not the advanced datapath metrics are enabled.
733737
varType: bool

modules/beta-private-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ Then perform the following commands on the root folder:
269269
| 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 |
270270
| 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 |
271271
| master\_ipv4\_cidr\_block | (Optional) The IP range in CIDR notation to use for the hosted master network. | `string` | `null` | no |
272+
| monitoring\_auto\_monitoring\_config\_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | `string` | `"NONE"` | no |
272273
| monitoring\_enable\_managed\_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `null` | no |
273274
| monitoring\_enable\_observability\_metrics | Whether or not the advanced datapath metrics are enabled. | `bool` | `false` | no |
274275
| monitoring\_enable\_observability\_relay | Whether or not the advanced datapath relay is enabled. | `bool` | `false` | no |

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ resource "google_container_cluster" "primary" {
115115
enable_components = var.monitoring_enabled_components
116116
managed_prometheus {
117117
enabled = var.monitoring_enable_managed_prometheus == null ? false : var.monitoring_enable_managed_prometheus
118+
dynamic "auto_monitoring_config" {
119+
for_each = var.monitoring_enable_managed_prometheus == true && var.monitoring_auto_monitoring_config_scope != null ? [1] : []
120+
content {
121+
scope = var.monitoring_auto_monitoring_config_scope
122+
}
123+
}
118124
}
119125
advanced_datapath_observability_config {
120126
enable_metrics = var.monitoring_enable_observability_metrics

modules/beta-private-cluster-update-variant/metadata.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,10 @@ spec:
721721
- name: monitoring_enable_managed_prometheus
722722
description: Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled.
723723
varType: bool
724+
- name: monitoring_auto_monitoring_config_scope
725+
description: "Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE"
726+
varType: string
727+
defaultValue: NONE
724728
- name: monitoring_enable_observability_metrics
725729
description: Whether or not the advanced datapath metrics are enabled.
726730
varType: bool

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,23 @@ variable "monitoring_enable_managed_prometheus" {
973973
default = null
974974
}
975975

976+
variable "monitoring_auto_monitoring_config_scope" {
977+
default = "NONE"
978+
description = "Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE"
979+
type = string
980+
981+
validation {
982+
condition = contains(
983+
[
984+
"ALL",
985+
"NONE",
986+
],
987+
var.monitoring_auto_monitoring_config_scope
988+
)
989+
error_message = "'monitoring_auto_monitoring_config_scope' value is invalid"
990+
}
991+
}
992+
976993
variable "monitoring_enable_observability_metrics" {
977994
type = bool
978995
description = "Whether or not the advanced datapath metrics are enabled."

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Then perform the following commands on the root folder:
247247
| 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 |
248248
| 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 |
249249
| master\_ipv4\_cidr\_block | (Optional) The IP range in CIDR notation to use for the hosted master network. | `string` | `null` | no |
250+
| monitoring\_auto\_monitoring\_config\_scope | Whether or not to enable GKE Auto-Monitoring. Supported values include: ALL, NONE | `string` | `"NONE"` | no |
250251
| monitoring\_enable\_managed\_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `null` | no |
251252
| monitoring\_enable\_observability\_metrics | Whether or not the advanced datapath metrics are enabled. | `bool` | `false` | no |
252253
| monitoring\_enable\_observability\_relay | Whether or not the advanced datapath relay is enabled. | `bool` | `false` | no |

0 commit comments

Comments
 (0)