From e8291f03a1a91c43425177151c8e78d218eed2f1 Mon Sep 17 00:00:00 2001 From: nguyenhoaibao Date: Thu, 5 Nov 2020 23:05:38 +0700 Subject: [PATCH] feat: Add cluster_telemetry var to beta submodules (#728) --- autogen/main/cluster.tf.tmpl | 11 +++++++++++ autogen/main/main.tf.tmpl | 1 + autogen/main/variables.tf.tmpl | 8 ++++++++ modules/beta-private-cluster-update-variant/README.md | 1 + .../beta-private-cluster-update-variant/cluster.tf | 10 ++++++++-- modules/beta-private-cluster-update-variant/main.tf | 1 + .../beta-private-cluster-update-variant/variables.tf | 6 ++++++ modules/beta-private-cluster/README.md | 1 + modules/beta-private-cluster/cluster.tf | 10 ++++++++-- modules/beta-private-cluster/main.tf | 1 + modules/beta-private-cluster/variables.tf | 6 ++++++ modules/beta-public-cluster-update-variant/README.md | 1 + modules/beta-public-cluster-update-variant/cluster.tf | 10 ++++++++-- modules/beta-public-cluster-update-variant/main.tf | 1 + .../beta-public-cluster-update-variant/variables.tf | 6 ++++++ modules/beta-public-cluster/README.md | 1 + modules/beta-public-cluster/cluster.tf | 10 ++++++++-- modules/beta-public-cluster/main.tf | 1 + modules/beta-public-cluster/variables.tf | 6 ++++++ 19 files changed, 84 insertions(+), 8 deletions(-) diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index 98de1991bc..e787549592 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -62,8 +62,19 @@ resource "google_container_cluster" "primary" { {% endif %} min_master_version = var.release_channel != null ? null : local.master_version +{% if beta_cluster %} + dynamic "cluster_telemetry" { + for_each = local.cluster_telemetry_type_is_set ? [1] : [] + content { + type = var.cluster_telemetry_type + } + } + logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service +{% else %} logging_service = var.logging_service monitoring_service = var.monitoring_service +{% endif %} cluster_autoscaling { enabled = var.cluster_autoscaling.enabled diff --git a/autogen/main/main.tf.tmpl b/autogen/main/main.tf.tmpl index cb23b9ce6f..872f64c191 100644 --- a/autogen/main/main.tf.tmpl +++ b/autogen/main/main.tf.tmpl @@ -172,6 +172,7 @@ locals { cluster_istio_enabled = ! local.cluster_output_istio_disabled cluster_cloudrun_enabled = var.cloudrun cluster_dns_cache_enabled = var.dns_cache + cluster_telemetry_type_is_set = var.cluster_telemetry_type != null cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled diff --git a/autogen/main/variables.tf.tmpl b/autogen/main/variables.tf.tmpl index fb71d30944..f02a024237 100644 --- a/autogen/main/variables.tf.tmpl +++ b/autogen/main/variables.tf.tmpl @@ -301,6 +301,14 @@ variable "configure_ip_masq" { default = false } +{% if beta_cluster %} +variable "cluster_telemetry_type" { + type = string + description = "Available options include ENABLED, DISABLED, and SYSTEM_ONLY" + default = null +} + +{% endif %} variable "logging_service" { type = string description = "The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none" diff --git a/modules/beta-private-cluster-update-variant/README.md b/modules/beta-private-cluster-update-variant/README.md index a063c28ec3..3d0a3ac7f9 100644 --- a/modules/beta-private-cluster-update-variant/README.md +++ b/modules/beta-private-cluster-update-variant/README.md @@ -152,6 +152,7 @@ Then perform the following commands on the root folder: | cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) |
object({
enabled = bool
autoscaling_profile = string
min_cpu_cores = number
max_cpu_cores = number
min_memory_gb = number
max_memory_gb = number
})
|
{
"autoscaling_profile": "BALANCED",
"enabled": false,
"max_cpu_cores": 0,
"max_memory_gb": 0,
"min_cpu_cores": 0,
"min_memory_gb": 0
}
| no | | cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `any` | `null` | no | | cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no | +| cluster\_telemetry\_type | Available options include ENABLED, DISABLED, and SYSTEM\_ONLY | `string` | `null` | no | | config\_connector | (Beta) Whether ConfigConnector is enabled for this cluster. | `bool` | `false` | no | | configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | `bool` | `false` | no | | create\_service\_account | Defines if service account specified to run nodes should be created. | `bool` | `true` | no | diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index 192092cf3a..87476537c1 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -56,8 +56,14 @@ resource "google_container_cluster" "primary" { } min_master_version = var.release_channel != null ? null : local.master_version - logging_service = var.logging_service - monitoring_service = var.monitoring_service + dynamic "cluster_telemetry" { + for_each = local.cluster_telemetry_type_is_set ? [1] : [] + content { + type = var.cluster_telemetry_type + } + } + logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service cluster_autoscaling { enabled = var.cluster_autoscaling.enabled diff --git a/modules/beta-private-cluster-update-variant/main.tf b/modules/beta-private-cluster-update-variant/main.tf index 9e420ee954..70d19a0b6e 100644 --- a/modules/beta-private-cluster-update-variant/main.tf +++ b/modules/beta-private-cluster-update-variant/main.tf @@ -154,6 +154,7 @@ locals { cluster_istio_enabled = ! local.cluster_output_istio_disabled cluster_cloudrun_enabled = var.cloudrun cluster_dns_cache_enabled = var.dns_cache + cluster_telemetry_type_is_set = var.cluster_telemetry_type != null cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled diff --git a/modules/beta-private-cluster-update-variant/variables.tf b/modules/beta-private-cluster-update-variant/variables.tf index 1e3094875f..49ea95208e 100644 --- a/modules/beta-private-cluster-update-variant/variables.tf +++ b/modules/beta-private-cluster-update-variant/variables.tf @@ -293,6 +293,12 @@ variable "configure_ip_masq" { default = false } +variable "cluster_telemetry_type" { + type = string + description = "Available options include ENABLED, DISABLED, and SYSTEM_ONLY" + default = null +} + variable "logging_service" { type = string description = "The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none" diff --git a/modules/beta-private-cluster/README.md b/modules/beta-private-cluster/README.md index e9ecbbb5c5..19d62d2d7d 100644 --- a/modules/beta-private-cluster/README.md +++ b/modules/beta-private-cluster/README.md @@ -130,6 +130,7 @@ Then perform the following commands on the root folder: | cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) |
object({
enabled = bool
autoscaling_profile = string
min_cpu_cores = number
max_cpu_cores = number
min_memory_gb = number
max_memory_gb = number
})
|
{
"autoscaling_profile": "BALANCED",
"enabled": false,
"max_cpu_cores": 0,
"max_memory_gb": 0,
"min_cpu_cores": 0,
"min_memory_gb": 0
}
| no | | cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `any` | `null` | no | | cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no | +| cluster\_telemetry\_type | Available options include ENABLED, DISABLED, and SYSTEM\_ONLY | `string` | `null` | no | | config\_connector | (Beta) Whether ConfigConnector is enabled for this cluster. | `bool` | `false` | no | | configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | `bool` | `false` | no | | create\_service\_account | Defines if service account specified to run nodes should be created. | `bool` | `true` | no | diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 6ed7ef9e82..2d786d1457 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -56,8 +56,14 @@ resource "google_container_cluster" "primary" { } min_master_version = var.release_channel != null ? null : local.master_version - logging_service = var.logging_service - monitoring_service = var.monitoring_service + dynamic "cluster_telemetry" { + for_each = local.cluster_telemetry_type_is_set ? [1] : [] + content { + type = var.cluster_telemetry_type + } + } + logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service cluster_autoscaling { enabled = var.cluster_autoscaling.enabled diff --git a/modules/beta-private-cluster/main.tf b/modules/beta-private-cluster/main.tf index 9e420ee954..70d19a0b6e 100644 --- a/modules/beta-private-cluster/main.tf +++ b/modules/beta-private-cluster/main.tf @@ -154,6 +154,7 @@ locals { cluster_istio_enabled = ! local.cluster_output_istio_disabled cluster_cloudrun_enabled = var.cloudrun cluster_dns_cache_enabled = var.dns_cache + cluster_telemetry_type_is_set = var.cluster_telemetry_type != null cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled diff --git a/modules/beta-private-cluster/variables.tf b/modules/beta-private-cluster/variables.tf index 1e3094875f..49ea95208e 100644 --- a/modules/beta-private-cluster/variables.tf +++ b/modules/beta-private-cluster/variables.tf @@ -293,6 +293,12 @@ variable "configure_ip_masq" { default = false } +variable "cluster_telemetry_type" { + type = string + description = "Available options include ENABLED, DISABLED, and SYSTEM_ONLY" + default = null +} + variable "logging_service" { type = string description = "The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none" diff --git a/modules/beta-public-cluster-update-variant/README.md b/modules/beta-public-cluster-update-variant/README.md index c03f38f5fb..0f0d2a5c17 100644 --- a/modules/beta-public-cluster-update-variant/README.md +++ b/modules/beta-public-cluster-update-variant/README.md @@ -146,6 +146,7 @@ Then perform the following commands on the root folder: | cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) |
object({
enabled = bool
autoscaling_profile = string
min_cpu_cores = number
max_cpu_cores = number
min_memory_gb = number
max_memory_gb = number
})
|
{
"autoscaling_profile": "BALANCED",
"enabled": false,
"max_cpu_cores": 0,
"max_memory_gb": 0,
"min_cpu_cores": 0,
"min_memory_gb": 0
}
| no | | cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `any` | `null` | no | | cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no | +| cluster\_telemetry\_type | Available options include ENABLED, DISABLED, and SYSTEM\_ONLY | `string` | `null` | no | | config\_connector | (Beta) Whether ConfigConnector is enabled for this cluster. | `bool` | `false` | no | | configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | `bool` | `false` | no | | create\_service\_account | Defines if service account specified to run nodes should be created. | `bool` | `true` | no | diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index e6a7b3f0c3..ec089185cf 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -56,8 +56,14 @@ resource "google_container_cluster" "primary" { } min_master_version = var.release_channel != null ? null : local.master_version - logging_service = var.logging_service - monitoring_service = var.monitoring_service + dynamic "cluster_telemetry" { + for_each = local.cluster_telemetry_type_is_set ? [1] : [] + content { + type = var.cluster_telemetry_type + } + } + logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service cluster_autoscaling { enabled = var.cluster_autoscaling.enabled diff --git a/modules/beta-public-cluster-update-variant/main.tf b/modules/beta-public-cluster-update-variant/main.tf index b9c44c48ea..8f9866591f 100644 --- a/modules/beta-public-cluster-update-variant/main.tf +++ b/modules/beta-public-cluster-update-variant/main.tf @@ -153,6 +153,7 @@ locals { cluster_istio_enabled = ! local.cluster_output_istio_disabled cluster_cloudrun_enabled = var.cloudrun cluster_dns_cache_enabled = var.dns_cache + cluster_telemetry_type_is_set = var.cluster_telemetry_type != null cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled diff --git a/modules/beta-public-cluster-update-variant/variables.tf b/modules/beta-public-cluster-update-variant/variables.tf index 04a6bf54de..acdf8dfc75 100644 --- a/modules/beta-public-cluster-update-variant/variables.tf +++ b/modules/beta-public-cluster-update-variant/variables.tf @@ -293,6 +293,12 @@ variable "configure_ip_masq" { default = false } +variable "cluster_telemetry_type" { + type = string + description = "Available options include ENABLED, DISABLED, and SYSTEM_ONLY" + default = null +} + variable "logging_service" { type = string description = "The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none" diff --git a/modules/beta-public-cluster/README.md b/modules/beta-public-cluster/README.md index 705db2a22b..a9df752835 100644 --- a/modules/beta-public-cluster/README.md +++ b/modules/beta-public-cluster/README.md @@ -124,6 +124,7 @@ Then perform the following commands on the root folder: | cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) |
object({
enabled = bool
autoscaling_profile = string
min_cpu_cores = number
max_cpu_cores = number
min_memory_gb = number
max_memory_gb = number
})
|
{
"autoscaling_profile": "BALANCED",
"enabled": false,
"max_cpu_cores": 0,
"max_memory_gb": 0,
"min_cpu_cores": 0,
"min_memory_gb": 0
}
| no | | cluster\_ipv4\_cidr | The IP address range of the kubernetes pods in this cluster. Default is an automatically assigned CIDR. | `any` | `null` | no | | cluster\_resource\_labels | The GCE resource labels (a map of key/value pairs) to be applied to the cluster | `map(string)` | `{}` | no | +| cluster\_telemetry\_type | Available options include ENABLED, DISABLED, and SYSTEM\_ONLY | `string` | `null` | no | | config\_connector | (Beta) Whether ConfigConnector is enabled for this cluster. | `bool` | `false` | no | | configure\_ip\_masq | Enables the installation of ip masquerading, which is usually no longer required when using aliasied IP addresses. IP masquerading uses a kubectl call, so when you have a private cluster, you will need access to the API server. | `bool` | `false` | no | | create\_service\_account | Defines if service account specified to run nodes should be created. | `bool` | `true` | no | diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 2c1941a16b..4eaf38978b 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -56,8 +56,14 @@ resource "google_container_cluster" "primary" { } min_master_version = var.release_channel != null ? null : local.master_version - logging_service = var.logging_service - monitoring_service = var.monitoring_service + dynamic "cluster_telemetry" { + for_each = local.cluster_telemetry_type_is_set ? [1] : [] + content { + type = var.cluster_telemetry_type + } + } + logging_service = local.cluster_telemetry_type_is_set ? null : var.logging_service + monitoring_service = local.cluster_telemetry_type_is_set ? null : var.monitoring_service cluster_autoscaling { enabled = var.cluster_autoscaling.enabled diff --git a/modules/beta-public-cluster/main.tf b/modules/beta-public-cluster/main.tf index b9c44c48ea..8f9866591f 100644 --- a/modules/beta-public-cluster/main.tf +++ b/modules/beta-public-cluster/main.tf @@ -153,6 +153,7 @@ locals { cluster_istio_enabled = ! local.cluster_output_istio_disabled cluster_cloudrun_enabled = var.cloudrun cluster_dns_cache_enabled = var.dns_cache + cluster_telemetry_type_is_set = var.cluster_telemetry_type != null cluster_pod_security_policy_enabled = local.cluster_output_pod_security_policy_enabled cluster_intranode_visibility_enabled = local.cluster_output_intranode_visbility_enabled cluster_vertical_pod_autoscaling_enabled = local.cluster_output_vertical_pod_autoscaling_enabled diff --git a/modules/beta-public-cluster/variables.tf b/modules/beta-public-cluster/variables.tf index 04a6bf54de..acdf8dfc75 100644 --- a/modules/beta-public-cluster/variables.tf +++ b/modules/beta-public-cluster/variables.tf @@ -293,6 +293,12 @@ variable "configure_ip_masq" { default = false } +variable "cluster_telemetry_type" { + type = string + description = "Available options include ENABLED, DISABLED, and SYSTEM_ONLY" + default = null +} + variable "logging_service" { type = string description = "The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none"