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 #1969

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
3 changes: 3 additions & 0 deletions .changelog/3392.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Addon "Compute Engine persistent disk CSI Driver" for Google Kubernetes Engine cluster `google_container_cluster`
```
32 changes: 32 additions & 0 deletions google-beta/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)

Expand Down Expand Up @@ -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,
},
},
},
},
},
},
},
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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}
}

Expand Down
6 changes: 6 additions & 0 deletions google-beta/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,9 @@ resource "google_container_cluster" "primary" {
dns_cache_config {
enabled = false
}
gce_persistent_disk_csi_driver_config {
enabled = false
}
}
}
`, clusterName)
Expand Down Expand Up @@ -2006,6 +2009,9 @@ resource "google_container_cluster" "primary" {
dns_cache_config {
enabled = true
}
gce_persistent_disk_csi_driver_config {
enabled = true
}
}
}
`, clusterName)
Expand Down
9 changes: 6 additions & 3 deletions website/docs/r/container_cluster.html.markdown
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