Skip to content

Commit d96afa7

Browse files
authored
feat: Add GCE PD CSI Driver beta support (terraform-google-modules#497)
BREAKING CHANGE: Minimum provider change increased to 3.19.
1 parent c090d5b commit d96afa7

File tree

30 files changed

+100
-13
lines changed

30 files changed

+100
-13
lines changed

autogen/main/cluster.tf.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ resource "google_container_cluster" "primary" {
152152
dns_cache_config {
153153
enabled = var.dns_cache
154154
}
155+
156+
dynamic "gce_persistent_disk_csi_driver_config" {
157+
for_each = local.cluster_gce_pd_csi_config
158+
159+
content {
160+
enabled = gce_persistent_disk_csi_driver_config.value.enabled
161+
}
162+
}
155163
{% endif %}
156164
}
157165

autogen/main/main.tf.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ locals {
8888
{% if beta_cluster %}
8989
cluster_cloudrun_config = var.cloudrun ? [{ disabled = false }] : []
9090

91+
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
92+
9193
cluster_node_metadata_config = var.node_metadata == "UNSPECIFIED" ? [] : [{
9294
node_metadata = var.node_metadata
9395
}]

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ variable "dns_cache" {
417417
default = false
418418
}
419419

420+
variable "gce_pd_csi_driver" {
421+
type = bool
422+
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
423+
default = false
424+
}
425+
420426
variable "database_encryption" {
421427
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
422428
type = list(object({ state = string, key_name = string }))

autogen/main/versions.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ terraform {
1919

2020
required_providers {
2121
{% if beta_cluster %}
22-
google-beta = ">= 3.16, <4.0.0"
22+
google-beta = ">= 3.19, <4.0.0"
2323
{% else %}
2424
google = ">= 3.16, <4.0.0"
2525
{% endif %}

examples/node_pool/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.16.0"
22+
version = "~> 3.19.0"
2323
region = var.region
2424
}
2525

examples/node_pool_update_variant_beta/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.16.0"
22+
version = "~> 3.19.0"
2323
credentials = file(var.credentials_path)
2424
region = var.region
2525
}

examples/safer_cluster/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ provider "google" {
3434
}
3535

3636
provider "google-beta" {
37-
version = "~> 3.16.0"
37+
version = "~> 3.19.0"
3838
}
3939

4040
module "gke" {

examples/simple_regional_beta/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This example illustrates how to create a simple cluster with beta features.
1313
| database\_encryption | Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: "ENCRYPTED"; "DECRYPTED". key_name is the name of a CloudKMS key. | object | `<list>` | no |
1414
| dns\_cache | (Beta) The status of the NodeLocal DNSCache addon. | bool | `"false"` | no |
1515
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
16+
| gce\_pd\_csi\_driver | (Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | bool | `"false"` | no |
1617
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
1718
| ip\_range\_services | The secondary ip range to use for services | string | n/a | yes |
1819
| istio | Boolean to enable / disable Istio | string | `"true"` | no |

examples/simple_regional_beta/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.16.0"
22+
version = "~> 3.19.0"
2323
region = var.region
2424
}
2525

@@ -39,6 +39,7 @@ module "gke" {
3939
istio = var.istio
4040
cloudrun = var.cloudrun
4141
dns_cache = var.dns_cache
42+
gce_pd_csi_driver = var.gce_pd_csi_driver
4243
node_metadata = var.node_metadata
4344
sandbox_enabled = var.sandbox_enabled
4445
remove_default_node_pool = var.remove_default_node_pool

examples/simple_regional_beta/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ variable "dns_cache" {
6363
default = false
6464
}
6565

66+
variable "gce_pd_csi_driver" {
67+
type = bool
68+
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
69+
default = false
70+
}
71+
6672
variable "node_metadata" {
6773
description = "Specifies how node metadata is exposed to the workload running on the node"
6874
default = "SECURE"

examples/simple_regional_private_beta/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ provider "google" {
2424
}
2525

2626
provider "google-beta" {
27-
version = "~> 3.16.0"
27+
version = "~> 3.19.0"
2828
region = var.region
2929
}
3030

@@ -56,9 +56,10 @@ module "gke" {
5656
},
5757
]
5858

59-
istio = var.istio
60-
cloudrun = var.cloudrun
61-
dns_cache = var.dns_cache
59+
istio = var.istio
60+
cloudrun = var.cloudrun
61+
dns_cache = var.dns_cache
62+
gce_pd_csi_driver = var.gce_pd_csi_driver
6263
}
6364

6465
data "google_client_config" "default" {

examples/simple_regional_private_beta/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ variable "dns_cache" {
6161
description = "Boolean to enable / disable NodeLocal DNSCache "
6262
default = false
6363
}
64+
65+
variable "gce_pd_csi_driver" {
66+
type = bool
67+
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
68+
default = false
69+
}

examples/workload_metadata_config/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ locals {
1919
}
2020

2121
provider "google-beta" {
22-
version = "~> 3.16.0"
22+
version = "~> 3.19.0"
2323
region = var.region
2424
}
2525

modules/beta-private-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ Then perform the following commands on the root folder:
183183
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
184184
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers | list(string) | `<list>` | no |
185185
| firewall\_priority | Priority rule for firewall rules | number | `"1000"` | no |
186+
| gce\_pd\_csi\_driver | (Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | bool | `"false"` | no |
186187
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
187188
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
188189
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ resource "google_container_cluster" "primary" {
137137
dns_cache_config {
138138
enabled = var.dns_cache
139139
}
140+
141+
dynamic "gce_persistent_disk_csi_driver_config" {
142+
for_each = local.cluster_gce_pd_csi_config
143+
144+
content {
145+
enabled = gce_persistent_disk_csi_driver_config.value.enabled
146+
}
147+
}
140148
}
141149

142150
ip_allocation_policy {

modules/beta-private-cluster-update-variant/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ locals {
8181

8282
cluster_cloudrun_config = var.cloudrun ? [{ disabled = false }] : []
8383

84+
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
85+
8486
cluster_node_metadata_config = var.node_metadata == "UNSPECIFIED" ? [] : [{
8587
node_metadata = var.node_metadata
8688
}]

modules/beta-private-cluster-update-variant/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ variable "dns_cache" {
410410
default = false
411411
}
412412

413+
variable "gce_pd_csi_driver" {
414+
type = bool
415+
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
416+
default = false
417+
}
418+
413419
variable "database_encryption" {
414420
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
415421
type = list(object({ state = string, key_name = string }))

modules/beta-private-cluster-update-variant/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ terraform {
1818
required_version = "~> 0.12.6"
1919

2020
required_providers {
21-
google-beta = ">= 3.16, <4.0.0"
21+
google-beta = ">= 3.19, <4.0.0"
2222
}
2323
}

modules/beta-private-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Then perform the following commands on the root folder:
161161
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
162162
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers | list(string) | `<list>` | no |
163163
| firewall\_priority | Priority rule for firewall rules | number | `"1000"` | no |
164+
| gce\_pd\_csi\_driver | (Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | bool | `"false"` | no |
164165
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
165166
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
166167
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |

modules/beta-private-cluster/cluster.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ resource "google_container_cluster" "primary" {
137137
dns_cache_config {
138138
enabled = var.dns_cache
139139
}
140+
141+
dynamic "gce_persistent_disk_csi_driver_config" {
142+
for_each = local.cluster_gce_pd_csi_config
143+
144+
content {
145+
enabled = gce_persistent_disk_csi_driver_config.value.enabled
146+
}
147+
}
140148
}
141149

142150
ip_allocation_policy {

modules/beta-private-cluster/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ locals {
8181

8282
cluster_cloudrun_config = var.cloudrun ? [{ disabled = false }] : []
8383

84+
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
85+
8486
cluster_node_metadata_config = var.node_metadata == "UNSPECIFIED" ? [] : [{
8587
node_metadata = var.node_metadata
8688
}]

modules/beta-private-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ variable "dns_cache" {
410410
default = false
411411
}
412412

413+
variable "gce_pd_csi_driver" {
414+
type = bool
415+
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
416+
default = false
417+
}
418+
413419
variable "database_encryption" {
414420
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
415421
type = list(object({ state = string, key_name = string }))

modules/beta-private-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ terraform {
1818
required_version = "~> 0.12.6"
1919

2020
required_providers {
21-
google-beta = ">= 3.16, <4.0.0"
21+
google-beta = ">= 3.19, <4.0.0"
2222
}
2323
}

modules/beta-public-cluster/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Then perform the following commands on the root folder:
140140
| enable\_vertical\_pod\_autoscaling | Vertical Pod Autoscaling automatically adjusts the resources of pods controlled by it | bool | `"false"` | no |
141141
| firewall\_inbound\_ports | List of TCP ports for admission/webhook controllers | list(string) | `<list>` | no |
142142
| firewall\_priority | Priority rule for firewall rules | number | `"1000"` | no |
143+
| gce\_pd\_csi\_driver | (Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. | bool | `"false"` | no |
143144
| grant\_registry\_access | Grants created cluster-specific service account storage.objectViewer role. | bool | `"false"` | no |
144145
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | bool | `"true"` | no |
145146
| http\_load\_balancing | Enable httpload balancer addon | bool | `"true"` | no |

modules/beta-public-cluster/cluster.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ resource "google_container_cluster" "primary" {
137137
dns_cache_config {
138138
enabled = var.dns_cache
139139
}
140+
141+
dynamic "gce_persistent_disk_csi_driver_config" {
142+
for_each = local.cluster_gce_pd_csi_config
143+
144+
content {
145+
enabled = gce_persistent_disk_csi_driver_config.value.enabled
146+
}
147+
}
140148
}
141149

142150
ip_allocation_policy {

modules/beta-public-cluster/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ locals {
8181

8282
cluster_cloudrun_config = var.cloudrun ? [{ disabled = false }] : []
8383

84+
cluster_gce_pd_csi_config = var.gce_pd_csi_driver ? [{ enabled = true }] : [{ enabled = false }]
85+
8486
cluster_node_metadata_config = var.node_metadata == "UNSPECIFIED" ? [] : [{
8587
node_metadata = var.node_metadata
8688
}]

modules/beta-public-cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ variable "dns_cache" {
386386
default = false
387387
}
388388

389+
variable "gce_pd_csi_driver" {
390+
type = bool
391+
description = "(Beta) Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver."
392+
default = false
393+
}
394+
389395
variable "database_encryption" {
390396
description = "Application-layer Secrets Encryption settings. The object format is {state = string, key_name = string}. Valid values of state are: \"ENCRYPTED\"; \"DECRYPTED\". key_name is the name of a CloudKMS key."
391397
type = list(object({ state = string, key_name = string }))

modules/beta-public-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ terraform {
1818
required_version = "~> 0.12.6"
1919

2020
required_providers {
21-
google-beta = ">= 3.16, <4.0.0"
21+
google-beta = ">= 3.19, <4.0.0"
2222
}
2323
}

test/fixtures/beta_cluster/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module "this" {
5656

5757
dns_cache = true
5858

59+
gce_pd_csi_driver = true
60+
5961
enable_binary_authorization = true
6062

6163
pod_security_policy_config = [{

test/integration/beta_cluster/controls/gcloud.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
"cloudRunConfig" => {},
6161
"dnsCacheConfig" => {
6262
"enabled" => true,
63+
},
64+
"gcePersistentDiskCsiDriverConfig" => {
65+
"enabled" => true,
6366
}
6467
})
6568
end

0 commit comments

Comments
 (0)