diff --git a/.changelog/3392.txt b/.changelog/3392.txt new file mode 100644 index 0000000000..4b0eeeea1e --- /dev/null +++ b/.changelog/3392.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +Addon "Compute Engine persistent disk CSI Driver" for Google Kubernetes Engine cluster `google_container_cluster` +``` diff --git a/google-beta/resource_container_cluster.go b/google-beta/resource_container_cluster.go index 840d4084b9..63ab3580ee 100644 --- a/google-beta/resource_container_cluster.go +++ b/google-beta/resource_container_cluster.go @@ -56,6 +56,7 @@ var ( "addons_config.0.istio_config", "addons_config.0.cloudrun_config", "addons_config.0.dns_cache_config", + "addons_config.0.gce_persistent_disk_csi_driver_config", } ) @@ -285,6 +286,21 @@ func resourceContainerCluster() *schema.Resource { }, }, }, + "gce_persistent_disk_csi_driver_config": { + Type: schema.TypeList, + Optional: true, + Computed: true, + AtLeastOneOf: addonsConfigKeys, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, }, }, }, @@ -2187,6 +2203,14 @@ func expandClusterAddonsConfig(configured interface{}) *containerBeta.AddonsConf } } + if v, ok := config["gce_persistent_disk_csi_driver_config"]; ok && len(v.([]interface{})) > 0 { + addon := v.([]interface{})[0].(map[string]interface{}) + ac.GcePersistentDiskCsiDriverConfig = &containerBeta.GcePersistentDiskCsiDriverConfig{ + Enabled: addon["enabled"].(bool), + ForceSendFields: []string{"Enabled"}, + } + } + return ac } @@ -2591,6 +2615,14 @@ func flattenClusterAddonsConfig(c *containerBeta.AddonsConfig) []map[string]inte }, } } + + if c.GcePersistentDiskCsiDriverConfig != nil { + result["gce_persistent_disk_csi_driver_config"] = []map[string]interface{}{ + { + "enabled": c.GcePersistentDiskCsiDriverConfig.Enabled, + }, + } + } return []map[string]interface{}{result} } diff --git a/google-beta/resource_container_cluster_test.go b/google-beta/resource_container_cluster_test.go index 136e46cb7f..963ebd7a70 100644 --- a/google-beta/resource_container_cluster_test.go +++ b/google-beta/resource_container_cluster_test.go @@ -1972,6 +1972,9 @@ resource "google_container_cluster" "primary" { dns_cache_config { enabled = false } + gce_persistent_disk_csi_driver_config { + enabled = false + } } } `, clusterName) @@ -2006,6 +2009,9 @@ resource "google_container_cluster" "primary" { dns_cache_config { enabled = true } + gce_persistent_disk_csi_driver_config { + enabled = true + } } } `, clusterName) diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index bbf40a393d..8a95afaa18 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -324,14 +324,17 @@ The `addons_config` block supports: * `cloudrun_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). The status of the CloudRun addon. It requires `istio_config` enabled. It is disabled by default. Set `disabled = false` to enable. This addon can only be enabled at cluster creation time. - + * `dns_cache_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). The status of the NodeLocal DNSCache addon. It is disabled by default. - Set `enabled = true` to enable. - + Set `enabled = true` to enable. + **Enabling/Disabling NodeLocal DNSCache in an existing cluster is a disruptive operation. All cluster nodes running GKE 1.15 and higher are recreated.** +* `gce_persistent_disk_csi_driver_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). + Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to disabled; set `enabled = true` to enable. + This example `addons_config` disables two addons: ```hcl