Skip to content

Commit

Permalink
GKE Addon for Compute Engine persistent disk CSI Driver (#3392)
Browse files Browse the repository at this point in the history
* GKE Addon for Compute Engine persistent disk CSI Driver

* update docs
  • Loading branch information
chrissng authored Apr 21, 2020
1 parent 5833662 commit f5e3cc7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
46 changes: 39 additions & 7 deletions third_party/terraform/resources/resource_container_cluster.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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",
<% end -%>
}
)
Expand Down Expand Up @@ -288,6 +289,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,
},
},
},
},
<% end -%>
},
},
Expand Down Expand Up @@ -2221,7 +2237,15 @@ func expandClusterAddonsConfig(configured interface{}) *containerBeta.AddonsConf
if v, ok := config["dns_cache_config"]; ok && len(v.([]interface{})) > 0 {
addon := v.([]interface{})[0].(map[string]interface{})
ac.DnsCacheConfig = &containerBeta.DnsCacheConfig{
Enabled: addon["enabled"].(bool),
Enabled: addon["enabled"].(bool),
ForceSendFields: []string{"Enabled"},
}
}

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"},
}
}
Expand Down Expand Up @@ -2636,12 +2660,20 @@ func flattenClusterAddonsConfig(c *containerBeta.AddonsConfig) []map[string]inte
}

if c.DnsCacheConfig != nil {
result["dns_cache_config"] = []map[string]interface{}{
{
"enabled": c.DnsCacheConfig.Enabled,
},
}
}
result["dns_cache_config"] = []map[string]interface{}{
{
"enabled": c.DnsCacheConfig.Enabled,
},
}
}

if c.GcePersistentDiskCsiDriverConfig != nil {
result["gce_persistent_disk_csi_driver_config"] = []map[string]interface{}{
{
"enabled": c.GcePersistentDiskCsiDriverConfig.Enabled,
},
}
}
<% end -%>
return []map[string]interface{}{result}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,9 @@ resource "google_container_cluster" "primary" {
dns_cache_config {
enabled = false
}
gce_persistent_disk_csi_driver_config {
enabled = false
}
<% end -%>
}
}
Expand Down Expand Up @@ -2025,6 +2028,9 @@ resource "google_container_cluster" "primary" {
dns_cache_config {
enabled = true
}
gce_persistent_disk_csi_driver_config {
enabled = true
}
<% end -%>
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5e3cc7

Please sign in to comment.