Skip to content

Commit 568c824

Browse files
ykztsbharathkkb
andauthored
fix: support managed prometheus for autopilot (#1310)
Co-authored-by: Bharath KKB <[email protected]>
1 parent f292c45 commit 568c824

File tree

8 files changed

+49
-2
lines changed

8 files changed

+49
-2
lines changed

autogen/main/cluster.tf.tmpl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ resource "google_container_cluster" "primary" {
7171
{% endif %}
7272
min_master_version = var.release_channel != null ? null : local.master_version
7373

74-
{% if beta_cluster and autopilot_cluster != true %}
74+
{% if beta_cluster and autopilot_cluster != true %}
7575
dynamic "cluster_telemetry" {
7676
for_each = local.cluster_telemetry_type_is_set ? [1] : []
7777
content {
@@ -106,6 +106,17 @@ resource "google_container_cluster" "primary" {
106106
{% else %}
107107
logging_service = var.logging_service
108108
monitoring_service = var.monitoring_service
109+
{% if beta_cluster %}
110+
dynamic "monitoring_config" {
111+
for_each = var.monitoring_enable_managed_prometheus ? [1] : []
112+
113+
content {
114+
managed_prometheus {
115+
enabled = var.monitoring_enable_managed_prometheus
116+
}
117+
}
118+
}
119+
{% endif %}
109120
{% endif %}
110121
{% if autopilot_cluster != true %}
111122
cluster_autoscaling {

autogen/main/variables.tf.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@ variable "timeouts" {
583583
error_message = "Only create, update, delete timeouts can be specified."
584584
}
585585
}
586-
{% if beta_cluster and autopilot_cluster != true %}
586+
{% if beta_cluster %}
587+
{% if autopilot_cluster != true %}
587588

588589
variable "enable_kubernetes_alpha" {
589590
type = bool
@@ -602,12 +603,14 @@ variable "monitoring_enabled_components" {
602603
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
603604
default = []
604605
}
606+
{% endif %}
605607

606608
variable "monitoring_enable_managed_prometheus" {
607609
type = bool
608610
description = "(Beta) Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled."
609611
default = false
610612
}
613+
{% if autopilot_cluster != true %}
611614

612615
variable "istio" {
613616
description = "(Beta) Enable Istio addon"
@@ -678,4 +681,5 @@ variable "gce_pd_csi_driver" {
678681
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
679682
default = false
680683
}
684+
{% endif %}
681685
{% endif %}

modules/beta-autopilot-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Then perform the following commands on the root folder:
110110
| 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 |
111111
| master\_global\_access\_enabled | (Beta) Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint. | `bool` | `true` | no |
112112
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | `string` | `"10.0.0.0/28"` | no |
113+
| monitoring\_enable\_managed\_prometheus | (Beta) Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `false` | no |
113114
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | `string` | `"monitoring.googleapis.com/kubernetes"` | no |
114115
| name | The name of the cluster (required) | `string` | n/a | yes |
115116
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ resource "google_container_cluster" "primary" {
5555

5656
logging_service = var.logging_service
5757
monitoring_service = var.monitoring_service
58+
dynamic "monitoring_config" {
59+
for_each = var.monitoring_enable_managed_prometheus ? [1] : []
60+
61+
content {
62+
managed_prometheus {
63+
enabled = var.monitoring_enable_managed_prometheus
64+
}
65+
}
66+
}
5867
vertical_pod_autoscaling {
5968
enabled = var.enable_vertical_pod_autoscaling
6069
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,9 @@ variable "timeouts" {
392392
error_message = "Only create, update, delete timeouts can be specified."
393393
}
394394
}
395+
396+
variable "monitoring_enable_managed_prometheus" {
397+
type = bool
398+
description = "(Beta) Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled."
399+
default = false
400+
}

modules/beta-autopilot-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Then perform the following commands on the root folder:
9999
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
100100
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
101101
| 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 |
102+
| monitoring\_enable\_managed\_prometheus | (Beta) Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `false` | no |
102103
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | `string` | `"monitoring.googleapis.com/kubernetes"` | no |
103104
| name | The name of the cluster (required) | `string` | n/a | yes |
104105
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ resource "google_container_cluster" "primary" {
5555

5656
logging_service = var.logging_service
5757
monitoring_service = var.monitoring_service
58+
dynamic "monitoring_config" {
59+
for_each = var.monitoring_enable_managed_prometheus ? [1] : []
60+
61+
content {
62+
managed_prometheus {
63+
enabled = var.monitoring_enable_managed_prometheus
64+
}
65+
}
66+
}
5867
vertical_pod_autoscaling {
5968
enabled = var.enable_vertical_pod_autoscaling
6069
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,9 @@ variable "timeouts" {
361361
error_message = "Only create, update, delete timeouts can be specified."
362362
}
363363
}
364+
365+
variable "monitoring_enable_managed_prometheus" {
366+
type = bool
367+
description = "(Beta) Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled."
368+
default = false
369+
}

0 commit comments

Comments
 (0)