From 5603718d81920c141103993abbc72e2080aa2701 Mon Sep 17 00:00:00 2001 From: Stanley Yu Date: Tue, 30 Nov 2021 11:19:33 -0500 Subject: [PATCH] feat: Make auto_provisioning_defaults a non-beta feature and set `min_cpu_platform` for auto-provisioned node pools (#1077) --- autogen/main/cluster.tf.tmpl | 5 ++++- cluster.tf | 8 ++++++++ modules/beta-private-cluster-update-variant/cluster.tf | 5 +++-- modules/beta-private-cluster/cluster.tf | 5 +++-- modules/beta-public-cluster-update-variant/cluster.tf | 5 +++-- modules/beta-public-cluster/cluster.tf | 5 +++-- modules/private-cluster-update-variant/cluster.tf | 8 ++++++++ modules/private-cluster/cluster.tf | 8 ++++++++ 8 files changed, 40 insertions(+), 9 deletions(-) diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index 901d0bd36..c8cb20ebd 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -86,15 +86,18 @@ resource "google_container_cluster" "primary" { cluster_autoscaling { enabled = var.cluster_autoscaling.enabled -{% if beta_cluster %} dynamic "auto_provisioning_defaults" { for_each = var.cluster_autoscaling.enabled ? [1] : [] content { service_account = local.service_account oauth_scopes = local.node_pools_oauth_scopes["all"] +{% if beta_cluster %} + min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "") +{% endif %} } } +{% if beta_cluster %} autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED" {% endif %} dynamic "resource_limits" { diff --git a/cluster.tf b/cluster.tf index d06a02678..29c4e6581 100644 --- a/cluster.tf +++ b/cluster.tf @@ -58,6 +58,14 @@ resource "google_container_cluster" "primary" { cluster_autoscaling { enabled = var.cluster_autoscaling.enabled + dynamic "auto_provisioning_defaults" { + for_each = var.cluster_autoscaling.enabled ? [1] : [] + + content { + service_account = local.service_account + oauth_scopes = local.node_pools_oauth_scopes["all"] + } + } dynamic "resource_limits" { for_each = local.autoscaling_resource_limits content { diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index c97df30d2..276d66111 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -77,8 +77,9 @@ resource "google_container_cluster" "primary" { for_each = var.cluster_autoscaling.enabled ? [1] : [] content { - service_account = local.service_account - oauth_scopes = local.node_pools_oauth_scopes["all"] + service_account = local.service_account + oauth_scopes = local.node_pools_oauth_scopes["all"] + min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "") } } autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED" diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index 54843f821..c27a1e535 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -77,8 +77,9 @@ resource "google_container_cluster" "primary" { for_each = var.cluster_autoscaling.enabled ? [1] : [] content { - service_account = local.service_account - oauth_scopes = local.node_pools_oauth_scopes["all"] + service_account = local.service_account + oauth_scopes = local.node_pools_oauth_scopes["all"] + min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "") } } autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED" diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index 5286332ba..15a85a0ff 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -77,8 +77,9 @@ resource "google_container_cluster" "primary" { for_each = var.cluster_autoscaling.enabled ? [1] : [] content { - service_account = local.service_account - oauth_scopes = local.node_pools_oauth_scopes["all"] + service_account = local.service_account + oauth_scopes = local.node_pools_oauth_scopes["all"] + min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "") } } autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED" diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 0768bdbbf..1d4e3c99e 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -77,8 +77,9 @@ resource "google_container_cluster" "primary" { for_each = var.cluster_autoscaling.enabled ? [1] : [] content { - service_account = local.service_account - oauth_scopes = local.node_pools_oauth_scopes["all"] + service_account = local.service_account + oauth_scopes = local.node_pools_oauth_scopes["all"] + min_cpu_platform = lookup(var.node_pools[0], "min_cpu_platform", "") } } autoscaling_profile = var.cluster_autoscaling.autoscaling_profile != null ? var.cluster_autoscaling.autoscaling_profile : "BALANCED" diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index 96d7736a8..e0543b203 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -58,6 +58,14 @@ resource "google_container_cluster" "primary" { cluster_autoscaling { enabled = var.cluster_autoscaling.enabled + dynamic "auto_provisioning_defaults" { + for_each = var.cluster_autoscaling.enabled ? [1] : [] + + content { + service_account = local.service_account + oauth_scopes = local.node_pools_oauth_scopes["all"] + } + } dynamic "resource_limits" { for_each = local.autoscaling_resource_limits content { diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index 5c17d614b..a6233716e 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -58,6 +58,14 @@ resource "google_container_cluster" "primary" { cluster_autoscaling { enabled = var.cluster_autoscaling.enabled + dynamic "auto_provisioning_defaults" { + for_each = var.cluster_autoscaling.enabled ? [1] : [] + + content { + service_account = local.service_account + oauth_scopes = local.node_pools_oauth_scopes["all"] + } + } dynamic "resource_limits" { for_each = local.autoscaling_resource_limits content {