From c1a720a404e21540b44300fa972eb1ffd9b736e3 Mon Sep 17 00:00:00 2001 From: Andrew Peabody Date: Thu, 22 Aug 2024 16:47:25 -0700 Subject: [PATCH] fix(autopilot): option to configure gcfs (#2052) --- autogen/main/cluster.tf.tmpl | 11 ++++++----- autogen/main/variables.tf.tmpl | 7 ++++++- modules/beta-autopilot-private-cluster/README.md | 1 + modules/beta-autopilot-private-cluster/cluster.tf | 9 ++++++--- modules/beta-autopilot-private-cluster/variables.tf | 6 ++++++ modules/beta-autopilot-public-cluster/README.md | 1 + modules/beta-autopilot-public-cluster/cluster.tf | 9 ++++++--- modules/beta-autopilot-public-cluster/variables.tf | 6 ++++++ 8 files changed, 38 insertions(+), 12 deletions(-) diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index 88fd2b5871..b4fcd80ae3 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -480,11 +480,6 @@ resource "google_container_cluster" "primary" { ignore_changes = [node_pool, initial_node_count, resource_labels["asmv"]] } {% endif %} - {% if autopilot_cluster == true %} - lifecycle { - ignore_changes = [node_pool_defaults[0].node_config_defaults[0].gcfs_config[0]] - } - {% endif %} {% if autopilot_cluster != true %} dynamic "dns_config" { @@ -671,6 +666,12 @@ resource "google_container_cluster" "primary" { node_config_defaults { {% if autopilot_cluster %} logging_variant = var.logging_variant + dynamic "gcfs_config" { + for_each = var.enable_gcfs != null ? [true] : [] + content { + enabled = var.enable_gcfs + } + } {% endif %} {% if autopilot_cluster != true %} gcfs_config { diff --git a/autogen/main/variables.tf.tmpl b/autogen/main/variables.tf.tmpl index 01a3142ce6..a3118d41ab 100644 --- a/autogen/main/variables.tf.tmpl +++ b/autogen/main/variables.tf.tmpl @@ -941,13 +941,18 @@ variable "sandbox_enabled" { description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it)." default = false } + {% endif %} variable "enable_gcfs" { type = bool description = "(Beta) Enable image streaming on cluster level." + {% if autopilot_cluster != true %} default = false -} {% endif %} + {% if autopilot_cluster %} + default = null + {% endif %} +} {% endif %} {% if autopilot_cluster != true %} diff --git a/modules/beta-autopilot-private-cluster/README.md b/modules/beta-autopilot-private-cluster/README.md index f2cfe4a8d4..b94c531c4b 100644 --- a/modules/beta-autopilot-private-cluster/README.md +++ b/modules/beta-autopilot-private-cluster/README.md @@ -93,6 +93,7 @@ Then perform the following commands on the root folder: | enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no | | enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no | | enable\_fqdn\_network\_policy | Enable FQDN Network Policies on the cluster | `bool` | `null` | no | +| enable\_gcfs | (Beta) Enable image streaming on cluster level. | `bool` | `null` | no | | enable\_l4\_ilb\_subsetting | Enable L4 ILB Subsetting on the cluster | `bool` | `false` | no | | enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | `bool` | `false` | no | | enable\_private\_endpoint | Whether the master's internal IP address is used as the cluster endpoint | `bool` | `false` | no | diff --git a/modules/beta-autopilot-private-cluster/cluster.tf b/modules/beta-autopilot-private-cluster/cluster.tf index 7bb915f04a..7472b09941 100644 --- a/modules/beta-autopilot-private-cluster/cluster.tf +++ b/modules/beta-autopilot-private-cluster/cluster.tf @@ -261,9 +261,6 @@ resource "google_container_cluster" "primary" { } } - lifecycle { - ignore_changes = [node_pool_defaults[0].node_config_defaults[0].gcfs_config[0]] - } timeouts { create = lookup(var.timeouts, "create", "45m") @@ -352,6 +349,12 @@ resource "google_container_cluster" "primary" { node_pool_defaults { node_config_defaults { logging_variant = var.logging_variant + dynamic "gcfs_config" { + for_each = var.enable_gcfs != null ? [true] : [] + content { + enabled = var.enable_gcfs + } + } } } diff --git a/modules/beta-autopilot-private-cluster/variables.tf b/modules/beta-autopilot-private-cluster/variables.tf index 6c815c5a3a..b53537b90e 100644 --- a/modules/beta-autopilot-private-cluster/variables.tf +++ b/modules/beta-autopilot-private-cluster/variables.tf @@ -524,6 +524,12 @@ variable "enable_l4_ilb_subsetting" { default = false } +variable "enable_gcfs" { + type = bool + description = "(Beta) Enable image streaming on cluster level." + default = null +} + variable "allow_net_admin" { description = "(Optional) Enable NET_ADMIN for the cluster." type = bool diff --git a/modules/beta-autopilot-public-cluster/README.md b/modules/beta-autopilot-public-cluster/README.md index 0eb3696956..596d5512a1 100644 --- a/modules/beta-autopilot-public-cluster/README.md +++ b/modules/beta-autopilot-public-cluster/README.md @@ -86,6 +86,7 @@ Then perform the following commands on the root folder: | enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no | | enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no | | enable\_fqdn\_network\_policy | Enable FQDN Network Policies on the cluster | `bool` | `null` | no | +| enable\_gcfs | (Beta) Enable image streaming on cluster level. | `bool` | `null` | no | | enable\_l4\_ilb\_subsetting | Enable L4 ILB Subsetting on the cluster | `bool` | `false` | no | | enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | `bool` | `false` | no | | enable\_resource\_consumption\_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | `bool` | `true` | no | diff --git a/modules/beta-autopilot-public-cluster/cluster.tf b/modules/beta-autopilot-public-cluster/cluster.tf index 2d950e6c81..bc65225fcc 100644 --- a/modules/beta-autopilot-public-cluster/cluster.tf +++ b/modules/beta-autopilot-public-cluster/cluster.tf @@ -261,9 +261,6 @@ resource "google_container_cluster" "primary" { } } - lifecycle { - ignore_changes = [node_pool_defaults[0].node_config_defaults[0].gcfs_config[0]] - } timeouts { create = lookup(var.timeouts, "create", "45m") @@ -331,6 +328,12 @@ resource "google_container_cluster" "primary" { node_pool_defaults { node_config_defaults { logging_variant = var.logging_variant + dynamic "gcfs_config" { + for_each = var.enable_gcfs != null ? [true] : [] + content { + enabled = var.enable_gcfs + } + } } } diff --git a/modules/beta-autopilot-public-cluster/variables.tf b/modules/beta-autopilot-public-cluster/variables.tf index 744b16b551..6e88d8a3a1 100644 --- a/modules/beta-autopilot-public-cluster/variables.tf +++ b/modules/beta-autopilot-public-cluster/variables.tf @@ -488,6 +488,12 @@ variable "enable_l4_ilb_subsetting" { default = false } +variable "enable_gcfs" { + type = bool + description = "(Beta) Enable image streaming on cluster level." + default = null +} + variable "allow_net_admin" { description = "(Optional) Enable NET_ADMIN for the cluster." type = bool