Skip to content

Commit c2864ef

Browse files
Enable usage of gcp filestore csi driver (#5648) (#10998)
Signed-off-by: Modular Magician <[email protected]>
1 parent f98a7c0 commit c2864ef

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

.changelog/5648.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
container: added support for GCPFilestoreCSIDriver addon to `google_container_cluster` resource.
3+
```

google/resource_container_cluster.go

+34
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var (
5959
"addons_config.0.horizontal_pod_autoscaling",
6060
"addons_config.0.network_policy_config",
6161
"addons_config.0.cloudrun_config",
62+
"addons_config.0.gcp_filestore_csi_driver_config",
6263
}
6364

6465
forceNewClusterNodeConfigFields = []string{
@@ -228,6 +229,23 @@ func resourceContainerCluster() *schema.Resource {
228229
},
229230
},
230231
},
232+
"gcp_filestore_csi_driver_config": {
233+
Type: schema.TypeList,
234+
Optional: true,
235+
Computed: true,
236+
AtLeastOneOf: addonsConfigKeys,
237+
MaxItems: 1,
238+
Description: `The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes. Defaults to disabled; set enabled = true to enable.`,
239+
ConflictsWith: []string{"enable_autopilot"},
240+
Elem: &schema.Resource{
241+
Schema: map[string]*schema.Schema{
242+
"enabled": {
243+
Type: schema.TypeBool,
244+
Required: true,
245+
},
246+
},
247+
},
248+
},
231249
"cloudrun_config": {
232250
Type: schema.TypeList,
233251
Optional: true,
@@ -2564,6 +2582,14 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
25642582
}
25652583
}
25662584

2585+
if v, ok := config["gcp_filestore_csi_driver_config"]; ok && len(v.([]interface{})) > 0 {
2586+
addon := v.([]interface{})[0].(map[string]interface{})
2587+
ac.GcpFilestoreCsiDriverConfig = &container.GcpFilestoreCsiDriverConfig{
2588+
Enabled: addon["enabled"].(bool),
2589+
ForceSendFields: []string{"Enabled"},
2590+
}
2591+
}
2592+
25672593
if v, ok := config["cloudrun_config"]; ok && len(v.([]interface{})) > 0 {
25682594
addon := v.([]interface{})[0].(map[string]interface{})
25692595
ac.CloudRunConfig = &container.CloudRunConfig{
@@ -3068,6 +3094,14 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac
30683094
}
30693095
}
30703096

3097+
if c.GcpFilestoreCsiDriverConfig != nil {
3098+
result["gcp_filestore_csi_driver_config"] = []map[string]interface{}{
3099+
{
3100+
"enabled": c.GcpFilestoreCsiDriverConfig.Enabled,
3101+
},
3102+
}
3103+
}
3104+
30713105
if c.CloudRunConfig != nil {
30723106
cloudRunConfig := map[string]interface{}{
30733107
"disabled": c.CloudRunConfig.Disabled,

google/resource_container_cluster_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,9 @@ resource "google_container_cluster" "primary" {
20952095
network_policy_config {
20962096
disabled = true
20972097
}
2098+
gcp_filestore_csi_driver_config {
2099+
enabled = false
2100+
}
20982101
cloudrun_config {
20992102
disabled = true
21002103
}
@@ -2130,6 +2133,9 @@ resource "google_container_cluster" "primary" {
21302133
network_policy_config {
21312134
disabled = false
21322135
}
2136+
gcp_filestore_csi_driver_config {
2137+
enabled = true
2138+
}
21332139
cloudrun_config {
21342140
disabled = false
21352141
}

website/docs/r/container_cluster.html.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ subnetwork in which the cluster's instances are launched.
367367
It can only be disabled if the nodes already do not have network policies enabled.
368368
Defaults to disabled; set `disabled = false` to enable.
369369

370+
* `gcp_filestore_csi_driver_config` - (Optional) The status of the Filestore CSI driver addon,
371+
which allows the usage of filestore instance as volumes.
372+
It is disbaled by default; set `enabled = true` to enable.
373+
370374
* `cloudrun_config` - (Optional). Structure is [documented below](#nested_cloudrun_config).
371375

372376
* `istio_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).

0 commit comments

Comments
 (0)