Skip to content

Commit 9b55788

Browse files
GKE Addon for Compute Engine persistent disk CSI Driver (#3392) (#1969)
* GKE Addon for Compute Engine persistent disk CSI Driver * update docs Signed-off-by: Modular Magician <[email protected]>
1 parent e402daa commit 9b55788

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

.changelog/3392.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
Addon "Compute Engine persistent disk CSI Driver" for Google Kubernetes Engine cluster `google_container_cluster`
3+
```

google-beta/resource_container_cluster.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ var (
5656
"addons_config.0.istio_config",
5757
"addons_config.0.cloudrun_config",
5858
"addons_config.0.dns_cache_config",
59+
"addons_config.0.gce_persistent_disk_csi_driver_config",
5960
}
6061
)
6162

@@ -285,6 +286,21 @@ func resourceContainerCluster() *schema.Resource {
285286
},
286287
},
287288
},
289+
"gce_persistent_disk_csi_driver_config": {
290+
Type: schema.TypeList,
291+
Optional: true,
292+
Computed: true,
293+
AtLeastOneOf: addonsConfigKeys,
294+
MaxItems: 1,
295+
Elem: &schema.Resource{
296+
Schema: map[string]*schema.Schema{
297+
"enabled": {
298+
Type: schema.TypeBool,
299+
Required: true,
300+
},
301+
},
302+
},
303+
},
288304
},
289305
},
290306
},
@@ -2187,6 +2203,14 @@ func expandClusterAddonsConfig(configured interface{}) *containerBeta.AddonsConf
21872203
}
21882204
}
21892205

2206+
if v, ok := config["gce_persistent_disk_csi_driver_config"]; ok && len(v.([]interface{})) > 0 {
2207+
addon := v.([]interface{})[0].(map[string]interface{})
2208+
ac.GcePersistentDiskCsiDriverConfig = &containerBeta.GcePersistentDiskCsiDriverConfig{
2209+
Enabled: addon["enabled"].(bool),
2210+
ForceSendFields: []string{"Enabled"},
2211+
}
2212+
}
2213+
21902214
return ac
21912215
}
21922216

@@ -2591,6 +2615,14 @@ func flattenClusterAddonsConfig(c *containerBeta.AddonsConfig) []map[string]inte
25912615
},
25922616
}
25932617
}
2618+
2619+
if c.GcePersistentDiskCsiDriverConfig != nil {
2620+
result["gce_persistent_disk_csi_driver_config"] = []map[string]interface{}{
2621+
{
2622+
"enabled": c.GcePersistentDiskCsiDriverConfig.Enabled,
2623+
},
2624+
}
2625+
}
25942626
return []map[string]interface{}{result}
25952627
}
25962628

google-beta/resource_container_cluster_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,9 @@ resource "google_container_cluster" "primary" {
19721972
dns_cache_config {
19731973
enabled = false
19741974
}
1975+
gce_persistent_disk_csi_driver_config {
1976+
enabled = false
1977+
}
19751978
}
19761979
}
19771980
`, clusterName)
@@ -2006,6 +2009,9 @@ resource "google_container_cluster" "primary" {
20062009
dns_cache_config {
20072010
enabled = true
20082011
}
2012+
gce_persistent_disk_csi_driver_config {
2013+
enabled = true
2014+
}
20092015
}
20102016
}
20112017
`, clusterName)

website/docs/r/container_cluster.html.markdown

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,17 @@ The `addons_config` block supports:
324324
* `cloudrun_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
325325
The status of the CloudRun addon. It requires `istio_config` enabled. It is disabled by default.
326326
Set `disabled = false` to enable. This addon can only be enabled at cluster creation time.
327-
327+
328328
* `dns_cache_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
329329
The status of the NodeLocal DNSCache addon. It is disabled by default.
330-
Set `enabled = true` to enable.
331-
330+
Set `enabled = true` to enable.
331+
332332
**Enabling/Disabling NodeLocal DNSCache in an existing cluster is a disruptive operation.
333333
All cluster nodes running GKE 1.15 and higher are recreated.**
334334

335+
* `gce_persistent_disk_csi_driver_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
336+
Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to disabled; set `enabled = true` to enable.
337+
335338
This example `addons_config` disables two addons:
336339

337340
```hcl

0 commit comments

Comments
 (0)