Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GKE Addon for Compute Engine persistent disk CSI Driver #3392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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