Skip to content

Commit a52f22c

Browse files
committed
feat: (PSKD-709) Add support for Google NetApp volumes
1 parent 08ed3e2 commit a52f22c

File tree

7 files changed

+46
-15
lines changed

7 files changed

+46
-15
lines changed

docs/CONFIG-VARS.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Supported configuration variables are listed in the table below. All variables
1717
- [Additional Nodepools](#additional-nodepools)
1818
- [Storage](#storage)
1919
- [For `storage_type=standard` only (NFS server VM)](#for-storage_typestandard-only-nfs-server-vm)
20-
- [For `storage_type=ha` only (Google Filestore)](#for-storage_typeha-only-google-filestore) #TODO
20+
- [For `storage_type=ha` with Google Filestore](#for-storage_typeha-with-google-filestore)
21+
- [For `storage_type=ha` with Google NetApp Volumes](#for-storage_typeha-with-google-netapp-volumes)
2122
- [Google Artifact Registry (GAR) and Google Container Registry (GCR)](#google-artifact-registry-gar-and-google-container-registry-gcr)
2223
- [Postgres Servers](#postgres-servers)
2324
- [Monitoring](#monitoring)
@@ -212,6 +213,7 @@ stateful = {
212213
| Name | Description | Type | Default | Notes |
213214
| :--- | ---: | ---: | ---: | ---: |
214215
| storage_type | Type of Storage. Valid Values: "standard", "ha" | string | "standard" | "standard" creates NFS server VM, "ha" Google Filestore instance |
216+
| storage_type_backend | The storage backend for the chosen `storage_type`. | string | If `storage_type=standard` the default is "nfs";<br>If `storage_type=ha` the default is "filestore" | Valid Values: "nfs" if `storage_type=standard`; "filestore" or "netapp" if `storage_type=ha` |
215217

216218
### For `storage_type=standard` only (NFS server VM)
217219

@@ -221,13 +223,26 @@ stateful = {
221223
| nfs_vm_admin | OS Admin User for the NFS server VM | string | "nfsuser" | The NFS server VM is only created when storage_type="standard" |
222224
| nfs_raid_disk_size | Size in Gb for each disk of the RAID5 cluster on the NFS server VM | number | 1000 | The NFS server VM is only created when storage_type="standard" |
223225

224-
### For `storage_type=ha` only (Google Filestore)
226+
### For `storage_type=ha` with Google Filestore
225227

226228
| Name | Description | Type | Default | Notes |
227229
| :--- | ---: | ---: | ---: | ---: |
228230
| filestore_tier | The service tier for the Google Filestore Instance | string | "BASIC_HDD" | Valid Values: "BASIC_HDD", "BASIC_SSD" (previously called "STANDARD" and "PREMIUM" respectively.) |
229231
| filestore_size_in_gb | Size in GB of Filesystem in the Google Filestore Instance | number | 1024 for BASIC_HDD, 2560 for BASIC_SDD | 2560 GB is the minimum size for the BASIC_SSD tier. The BASIC_HDD tier allows a minimum size of 1024 GB. |
230232

233+
### For `storage_type=ha` with Google NetApp Volumes
234+
235+
When `storage_type=ha` and `storage_type_backend=netapp` are specified, [Google NetApp Volumes](https://cloud.google.com/netapp/volumes/docs/discover/overview) service is created. Before using this storage option,
236+
- Enable the Google Cloud NetApp Volumes API for your project, see how to enable [here](https://cloud.google.com/netapp/volumes/docs/get-started/configure-access/initiate-console-settings#enable_the_api).
237+
- Grant access to NetApp Volumes operations by granting IAM roles to users. The two predefined roles are `roles/netapp.admin` and `roles/netapp.viewer`. You can assign these roles to specific users or service accounts.
238+
239+
| Name | Description | Type | Default | Notes |
240+
| :--- | ---: | ---: | ---: | ---: |
241+
| netapp_service_level | The service level of the storage pool. | string | "PREMIUM" | Valid Values are: PREMIUM, EXTREME, STANDARD, FLEX. |
242+
| netapp_protocols | The target volume protocol expressed as a list. | list(string) | Each value may be one of: NFSV3, NFSV4, SMB. Currently, only NFS is supported. |
243+
| netapp_capacity_gib | Capacity of the storage pool (in GiB). Storage Pool capacity specified must be between 2048 GiB and 10485760 GiB. | string | "2048" | |
244+
| netapp_volume_path | A unique file path for the volume. Used when creating mount targets. Needs to be unique per location.| string | "export" | |
245+
231246
## Google Artifact Registry (GAR) and Google Container Registry (GCR)
232247

233248
| Name | Description | Type | Default | Notes |

examples/sample-input-ha.tfvars

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@ jump_vm_admin = "jumpuser"
9494
# Storage for Viya Compute Services
9595
# Supported storage_type values
9696
# "standard" - Custom managed NFS Server VM and disks
97-
# "ha" - Google Filestore
97+
# "ha" - Google Filestore or Google NetApp Volumes
9898
storage_type = "ha"
99+
storage_type_backend = "filestore" # "filestore" is the default, use "netapp" to create Google NetApp Volumes

main.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,13 @@ module "google_netapp" {
307307

308308
count = var.storage_type == "ha" && var.storage_type_backend == "netapp" ? 1 : 0
309309

310-
prefix = var.prefix
311-
region = local.region
312-
network = module.vpc.network_name
313-
service_level = var.netapp_service_level
314-
capacity_gib = var.netapp_capacity_gib
315-
protocols = var.netapp_protocols
310+
prefix = var.prefix
311+
region = local.region
312+
network = module.vpc.network_name
313+
service_level = var.netapp_service_level
314+
capacity_gib = var.netapp_capacity_gib
315+
protocols = var.netapp_protocols
316316
# netapp_subnet_cidr = var.netapp_subnet_cidr
317-
volume_path = "${var.prefix}-${var.netapp_volume_path}"
318-
allowed_clients = join(",", [local.gke_subnet_cidr, local.misc_subnet_cidr])
317+
volume_path = "${var.prefix}-${var.netapp_volume_path}"
318+
allowed_clients = join(",", [local.gke_subnet_cidr, local.misc_subnet_cidr])
319319
}

modules/google_netapp/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ resource "google_service_networking_connection" "default" {
1919
network = var.network
2020
service = "netapp.servicenetworking.goog"
2121
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
22+
23+
depends_on = [
24+
google_compute_global_address.private_ip_alloc
25+
]
2226
}
2327

2428
# Modify the PSA Connection to allow import/export of custom routes
@@ -36,6 +40,10 @@ resource "google_netapp_storage_pool" "netapp-tf-pool" {
3640
service_level = var.service_level
3741
capacity_gib = var.capacity_gib
3842
network = var.network
43+
44+
lifecycle {
45+
ignore_changes = [network]
46+
}
3947
}
4048

4149
resource "google_netapp_volume" "netapp-nfs-volume" {

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ output "rwx_filestore_endpoint" {
2828
value = (var.storage_type == "none"
2929
? null
3030
: var.storage_type == "ha" && var.storage_type_backend == "filestore" ? google_filestore_instance.rwx[0].networks[0].ip_addresses[0]
31-
: var.storage_type == "ha" && var.storage_type_backend == "netapp" ? try(module.google_netapp.mountpath, null) : module.nfs_server[0].private_ip # TODO
31+
: var.storage_type == "ha" && var.storage_type_backend == "netapp" ? module.google_netapp[0].export_ip : module.nfs_server[0].private_ip
3232
)
3333
}
3434

@@ -37,7 +37,7 @@ output "rwx_filestore_path" {
3737
value = (var.storage_type == "none"
3838
? null
3939
: var.storage_type == "ha" && var.storage_type_backend == "filestore" ? "/${google_filestore_instance.rwx[0].file_shares[0].name}"
40-
: var.storage_type == "ha" && var.storage_type_backend == "netapp" ? try("/${module.google_netapp.mountpath}", null) : "/export"
40+
: var.storage_type == "ha" && var.storage_type_backend == "netapp" ? "${module.google_netapp[0].mountpath}" : "/export"
4141
)
4242
}
4343

variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,14 @@ variable "netapp_service_level" {
451451
}
452452

453453
variable "netapp_protocols" {
454-
description = "The target volume protocol expressed as a list. Allowed combinations are ['NFSV3'], ['NFSV4'], ['SMB'], ['NFSV3', 'NFSV4'], ['SMB', 'NFSV3'] and ['SMB', 'NFSV4']. Each value may be one of: NFSV3, NFSV4, SMB."
454+
description = "The target volume protocol expressed as a list. Each value may be one of: NFSV3, NFSV4, SMB. Currently, only NFS is supported."
455455
type = list(string)
456456
default = ["NFSV4"]
457+
458+
validation {
459+
condition = var.netapp_protocols != null ? startswith(var.netapp_protocols[0], "NFS") : null
460+
error_message = "ERROR: Currently, only NFS protocol is supported."
461+
}
457462
}
458463

459464
variable "netapp_capacity_gib" {

vms.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ locals {
1212
: var.storage_type == "ha" && var.storage_type_backend == "filestore" ? "/${google_filestore_instance.rwx[0].file_shares[0].name}"
1313
: var.storage_type == "ha" && var.storage_type_backend == "netapp" ? "/${module.google_netapp[0].mountpath}" : "/export"
1414
)
15+
protocol_version = var.storage_type == "ha" && var.storage_type_backend == "netapp" ? split("V", var.netapp_protocols[0])[1] == "4" ? "4.1" : "3" : "3"
16+
1517
}
1618

1719
module "nfs_server" {
@@ -70,7 +72,7 @@ module "jump_server" {
7072
["${local.rwx_filestore_endpoint}:${local.rwx_filestore_path}",
7173
var.jump_rwx_filestore_path,
7274
"nfs",
73-
"_netdev,auto,x-systemd.automount,x-systemd.mount-timeout=10,timeo=14,x-systemd.idle-timeout=1min,relatime,hard,rsize=65536,wsize=65536,vers=3,tcp,namlen=255,retrans=2,sec=sys,local_lock=none",
75+
"_netdev,auto,x-systemd.automount,x-systemd.mount-timeout=10,timeo=14,x-systemd.idle-timeout=1min,relatime,hard,rsize=65536,wsize=65536,vers=${local.protocol_version},tcp,namlen=255,retrans=2,sec=sys,local_lock=none",
7476
"0",
7577
"0"
7678
])

0 commit comments

Comments
 (0)