Skip to content

Commit 9278265

Browse files
authored
feat: Added monitoring_enabled_components and logging_enabled_components variables to beta clusters (#1028)
1 parent 41a0c83 commit 9278265

File tree

29 files changed

+173
-25
lines changed

29 files changed

+173
-25
lines changed

Diff for: Makefile

+8-7
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ SHELL := /usr/bin/env bash
2121
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.0
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
24+
DOCKER_BIN ?= docker
2425

2526
# Enter docker container for local development
2627
.PHONY: docker_run
2728
docker_run:
28-
docker run --rm -it \
29+
$(DOCKER_BIN) run --rm -it \
2930
-e SERVICE_ACCOUNT_JSON \
3031
-v "$(CURDIR)":/workspace \
3132
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
@@ -34,7 +35,7 @@ docker_run:
3435
# Execute prepare tests within the docker container
3536
.PHONY: docker_test_prepare
3637
docker_test_prepare:
37-
docker run --rm -it \
38+
$(DOCKER_BIN) run --rm -it \
3839
-e SERVICE_ACCOUNT_JSON \
3940
-e TF_VAR_org_id \
4041
-e TF_VAR_folder_id \
@@ -46,7 +47,7 @@ docker_test_prepare:
4647
# Clean up test environment within the docker container
4748
.PHONY: docker_test_cleanup
4849
docker_test_cleanup:
49-
docker run --rm -it \
50+
$(DOCKER_BIN) run --rm -it \
5051
-e SERVICE_ACCOUNT_JSON \
5152
-e TF_VAR_org_id \
5253
-e TF_VAR_folder_id \
@@ -58,7 +59,7 @@ docker_test_cleanup:
5859
# Execute integration tests within the docker container
5960
.PHONY: docker_test_integration
6061
docker_test_integration:
61-
docker run --rm -it \
62+
$(DOCKER_BIN) run --rm -it \
6263
-e SERVICE_ACCOUNT_JSON \
6364
-v "$(CURDIR)":/workspace \
6465
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
@@ -67,7 +68,7 @@ docker_test_integration:
6768
# Execute lint tests within the docker container
6869
.PHONY: docker_test_lint
6970
docker_test_lint:
70-
docker run --rm -it \
71+
$(DOCKER_BIN) run --rm -it \
7172
-e ENABLE_PARALLEL=1 \
7273
-v "$(CURDIR)":/workspace \
7374
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
@@ -76,15 +77,15 @@ docker_test_lint:
7677
# Generate documentation
7778
.PHONY: docker_generate_docs
7879
docker_generate_docs:
79-
docker run --rm -it \
80+
$(DOCKER_BIN) run --rm -it \
8081
-v "$(CURDIR)":/workspace \
8182
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
8283
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
8384

8485
# Generate files from autogen
8586
.PHONY: docker_generate_modules
8687
docker_generate_modules:
87-
docker run --rm -it \
88+
$(DOCKER_BIN) run --rm -it \
8889
-v "$(CURDIR)":/workspace \
8990
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
9091
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_modules'

Diff for: autogen/main/cluster.tf.tmpl

+15
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,22 @@ resource "google_container_cluster" "primary" {
7878
}
7979
}
8080
logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service
81+
dynamic "logging_config" {
82+
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
83+
84+
content {
85+
enable_components = var.logging_enabled_components
86+
}
87+
}
88+
8189
monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service
90+
dynamic "monitoring_config" {
91+
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
92+
93+
content {
94+
enable_components = var.monitoring_enabled_components
95+
}
96+
}
8297
{% else %}
8398
logging_service = var.logging_service
8499
monitoring_service = var.monitoring_service

Diff for: autogen/main/variables.tf.tmpl

+16
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,28 @@ variable "logging_service" {
349349
default = "logging.googleapis.com/kubernetes"
350350
}
351351

352+
{% if beta_cluster %}
353+
variable "logging_enabled_components" {
354+
type = list(string)
355+
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS. Empty list is default GKE configuration."
356+
default = []
357+
}
358+
359+
{% endif %}
352360
variable "monitoring_service" {
353361
type = string
354362
description = "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"
355363
default = "monitoring.googleapis.com/kubernetes"
356364
}
357365

366+
{% if beta_cluster %}
367+
variable "monitoring_enabled_components" {
368+
type = list(string)
369+
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
370+
default = []
371+
}
372+
373+
{% endif %}
358374
variable "create_service_account" {
359375
type = bool
360376
description = "Defines if service account specified to run nodes should be created."

Diff for: autogen/main/versions.tf.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ terraform {
2424
required_providers {
2525
google-beta = {
2626
source = "hashicorp/google-beta"
27-
version = ">= 3.79.0, <4.0.0"
27+
version = ">= 3.87.0, <4.0.0"
2828
}
2929
kubernetes = {
3030
source = "hashicorp/kubernetes"

Diff for: examples/node_pool_update_variant_beta/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.79.0"
22+
version = "~> 3.87.0"
2323
credentials = file(var.credentials_path)
2424
region = var.region
2525
}

Diff for: examples/node_pool_update_variant_public_beta/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.79.0"
22+
version = "~> 3.87.0"
2323
credentials = file(var.credentials_path)
2424
region = var.region
2525
}

Diff for: examples/regional_private_node_pool_oauth_scopes/provider.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ provider "google" {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.79.0"
22+
version = "~> 3.87.0"
2323
}
2424

2525
data "google_client_config" "default" {}

Diff for: examples/safer_cluster/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ provider "google" {
3535
}
3636

3737
provider "google-beta" {
38-
version = "~> 3.79.0"
38+
version = "~> 3.87.0"
3939
}
4040

4141
data "google_client_config" "default" {}

Diff for: examples/safer_cluster_iap_bastion/provider.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ provider "google" {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.79.0"
22+
version = "~> 3.87.0"
2323
}
2424

2525
data "google_client_config" "default" {}

Diff for: examples/simple_regional_beta/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.79.0"
22+
version = "~> 3.87.0"
2323
region = var.region
2424
}
2525

Diff for: examples/simple_regional_private_beta/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ provider "google" {
2424
}
2525

2626
provider "google-beta" {
27-
version = "~> 3.79.0"
27+
version = "~> 3.87.0"
2828
region = var.region
2929
}
3030

Diff for: examples/simple_zonal_with_asm/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.79.0"
22+
version = "~> 3.87.0"
2323
region = var.region
2424
}
2525

Diff for: examples/workload_metadata_config/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.79.0"
22+
version = "~> 3.87.0"
2323
region = var.region
2424
}
2525

Diff for: modules/beta-private-cluster-update-variant/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ Then perform the following commands on the root folder:
211211
| istio\_auth | (Beta) The authentication type between services in Istio. | `string` | `"AUTH_MUTUAL_TLS"` | no |
212212
| kalm\_config | (Beta) Whether KALM is enabled for this cluster. | `bool` | `false` | no |
213213
| 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 |
214+
| logging\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS. Empty list is default GKE configuration. | `list(string)` | `[]` | no |
214215
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | `string` | `"logging.googleapis.com/kubernetes"` | no |
215216
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
216217
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
@@ -219,6 +220,7 @@ Then perform the following commands on the root folder:
219220
| 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 |
220221
| 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 |
221222
| 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 |
223+
| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration. | `list(string)` | `[]` | no |
222224
| 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 |
223225
| name | The name of the cluster (required) | `string` | n/a | yes |
224226
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |

Diff for: modules/beta-private-cluster-update-variant/cluster.tf

+16-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,23 @@ resource "google_container_cluster" "primary" {
6868
type = var.cluster_telemetry_type
6969
}
7070
}
71-
logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service
71+
logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service
72+
dynamic "logging_config" {
73+
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
74+
75+
content {
76+
enable_components = var.logging_enabled_components
77+
}
78+
}
79+
7280
monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service
81+
dynamic "monitoring_config" {
82+
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
83+
84+
content {
85+
enable_components = var.monitoring_enabled_components
86+
}
87+
}
7388

7489
cluster_autoscaling {
7590
enabled = var.cluster_autoscaling.enabled

Diff for: modules/beta-private-cluster-update-variant/variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,24 @@ variable "logging_service" {
335335
default = "logging.googleapis.com/kubernetes"
336336
}
337337

338+
variable "logging_enabled_components" {
339+
type = list(string)
340+
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS. Empty list is default GKE configuration."
341+
default = []
342+
}
343+
338344
variable "monitoring_service" {
339345
type = string
340346
description = "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"
341347
default = "monitoring.googleapis.com/kubernetes"
342348
}
343349

350+
variable "monitoring_enabled_components" {
351+
type = list(string)
352+
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
353+
default = []
354+
}
355+
344356
variable "create_service_account" {
345357
type = bool
346358
description = "Defines if service account specified to run nodes should be created."

Diff for: modules/beta-private-cluster-update-variant/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 3.79.0, <4.0.0"
24+
version = ">= 3.87.0, <4.0.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

Diff for: modules/beta-private-cluster/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ Then perform the following commands on the root folder:
189189
| istio\_auth | (Beta) The authentication type between services in Istio. | `string` | `"AUTH_MUTUAL_TLS"` | no |
190190
| kalm\_config | (Beta) Whether KALM is enabled for this cluster. | `bool` | `false` | no |
191191
| 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 |
192+
| logging\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS. Empty list is default GKE configuration. | `list(string)` | `[]` | no |
192193
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | `string` | `"logging.googleapis.com/kubernetes"` | no |
193194
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
194195
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
@@ -197,6 +198,7 @@ Then perform the following commands on the root folder:
197198
| 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 |
198199
| 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 |
199200
| 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 |
201+
| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration. | `list(string)` | `[]` | no |
200202
| 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 |
201203
| name | The name of the cluster (required) | `string` | n/a | yes |
202204
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |

Diff for: modules/beta-private-cluster/cluster.tf

+16-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,23 @@ resource "google_container_cluster" "primary" {
6868
type = var.cluster_telemetry_type
6969
}
7070
}
71-
logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service
71+
logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service
72+
dynamic "logging_config" {
73+
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
74+
75+
content {
76+
enable_components = var.logging_enabled_components
77+
}
78+
}
79+
7280
monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service
81+
dynamic "monitoring_config" {
82+
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
83+
84+
content {
85+
enable_components = var.monitoring_enabled_components
86+
}
87+
}
7388

7489
cluster_autoscaling {
7590
enabled = var.cluster_autoscaling.enabled

Diff for: modules/beta-private-cluster/variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,24 @@ variable "logging_service" {
335335
default = "logging.googleapis.com/kubernetes"
336336
}
337337

338+
variable "logging_enabled_components" {
339+
type = list(string)
340+
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS. Empty list is default GKE configuration."
341+
default = []
342+
}
343+
338344
variable "monitoring_service" {
339345
type = string
340346
description = "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"
341347
default = "monitoring.googleapis.com/kubernetes"
342348
}
343349

350+
variable "monitoring_enabled_components" {
351+
type = list(string)
352+
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
353+
default = []
354+
}
355+
344356
variable "create_service_account" {
345357
type = bool
346358
description = "Defines if service account specified to run nodes should be created."

Diff for: modules/beta-private-cluster/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 3.79.0, <4.0.0"
24+
version = ">= 3.87.0, <4.0.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

Diff for: modules/beta-public-cluster-update-variant/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@ Then perform the following commands on the root folder:
202202
| istio\_auth | (Beta) The authentication type between services in Istio. | `string` | `"AUTH_MUTUAL_TLS"` | no |
203203
| kalm\_config | (Beta) Whether KALM is enabled for this cluster. | `bool` | `false` | no |
204204
| 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 |
205+
| logging\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS. Empty list is default GKE configuration. | `list(string)` | `[]` | no |
205206
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | `string` | `"logging.googleapis.com/kubernetes"` | no |
206207
| maintenance\_end\_time | Time window specified for recurring maintenance operations in RFC3339 format | `string` | `""` | no |
207208
| maintenance\_exclusions | List of maintenance exclusions. A cluster can have up to three | `list(object({ name = string, start_time = string, end_time = string }))` | `[]` | no |
208209
| maintenance\_recurrence | Frequency of the recurring maintenance window in RFC5545 format. | `string` | `""` | no |
209210
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
210211
| 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 |
212+
| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration. | `list(string)` | `[]` | no |
211213
| 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 |
212214
| name | The name of the cluster (required) | `string` | n/a | yes |
213215
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |

Diff for: modules/beta-public-cluster-update-variant/cluster.tf

+16-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,23 @@ resource "google_container_cluster" "primary" {
6868
type = var.cluster_telemetry_type
6969
}
7070
}
71-
logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service
71+
logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service
72+
dynamic "logging_config" {
73+
for_each = length(var.logging_enabled_components) > 0 ? [1] : []
74+
75+
content {
76+
enable_components = var.logging_enabled_components
77+
}
78+
}
79+
7280
monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service
81+
dynamic "monitoring_config" {
82+
for_each = length(var.monitoring_enabled_components) > 0 ? [1] : []
83+
84+
content {
85+
enable_components = var.monitoring_enabled_components
86+
}
87+
}
7388

7489
cluster_autoscaling {
7590
enabled = var.cluster_autoscaling.enabled

0 commit comments

Comments
 (0)