-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: (PSKD-709) Add Support for Google NetApp Volumes (#224)
* feat: (PSKD-709) Add support for Google NetApp volumes Signed-off-by: Ritika Patil <[email protected]>
- Loading branch information
Showing
13 changed files
with
246 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright © 2021-2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Terraform Registry : https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/netapp_volume | ||
# GitHub Repository : https://github.com/terraform-google-modules | ||
# | ||
|
||
# Reserve compute address CIDR for NetApp Volumes to use | ||
resource "google_compute_global_address" "private_ip_alloc" { | ||
name = "${var.network}-ip-range" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
address = split("/", var.netapp_subnet_cidr)[0] | ||
prefix_length = split("/", var.netapp_subnet_cidr)[1] | ||
network = var.network | ||
} | ||
|
||
# Create the PSA peering | ||
resource "google_service_networking_connection" "default" { | ||
network = var.network | ||
service = "netapp.servicenetworking.goog" | ||
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] | ||
|
||
deletion_policy = "ABANDON" | ||
} | ||
|
||
# Modify the PSA Connection to allow import/export of custom routes | ||
resource "google_compute_network_peering_routes_config" "route_updates" { | ||
peering = google_service_networking_connection.default.peering | ||
network = var.network | ||
|
||
import_custom_routes = true | ||
export_custom_routes = true | ||
} | ||
|
||
resource "google_netapp_storage_pool" "netapp-tf-pool" { | ||
name = "${var.prefix}-netapp-storage-pool" | ||
location = var.region | ||
service_level = var.service_level | ||
capacity_gib = var.capacity_gib | ||
network = var.network | ||
|
||
lifecycle { | ||
ignore_changes = [network] | ||
} | ||
} | ||
|
||
resource "google_netapp_volume" "netapp-nfs-volume" { | ||
location = var.region | ||
name = "${var.prefix}-netapp-volume" | ||
capacity_gib = var.capacity_gib # Size can be up to space available in pool | ||
share_name = var.volume_path | ||
storage_pool = google_netapp_storage_pool.netapp-tf-pool.name | ||
protocols = var.protocols | ||
unix_permissions = "0777" | ||
export_policy { | ||
rules { | ||
access_type = "READ_WRITE" | ||
allowed_clients = var.allowed_clients | ||
has_root_access = true | ||
nfsv3 = contains(var.protocols, "NFSV3") ? true : false | ||
nfsv4 = contains(var.protocols, "NFSV4") ? true : false | ||
} | ||
} | ||
|
||
depends_on = [ | ||
google_netapp_storage_pool.netapp-tf-pool, | ||
google_service_networking_connection.default | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
output "mountpath" { | ||
value = google_netapp_volume.netapp-nfs-volume.mount_options[0].export | ||
} | ||
|
||
output "export_ip" { | ||
value = split(":", google_netapp_volume.netapp-nfs-volume.mount_options[0].export_full)[0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright © 2021-2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
variable "prefix" { | ||
description = "A prefix used in the name for all cloud resources created by this script. The prefix string must start with lowercase letter and contain only lowercase alphanumeric characters and hyphen or dash(-), but can not start or end with '-'." | ||
type = string | ||
} | ||
|
||
variable "region" { | ||
description = "The region to create the VM in" | ||
type = string | ||
} | ||
|
||
variable "service_level" { | ||
description = "Service level of the storage pool. Possible values are: PREMIUM, EXTREME, STANDARD, FLEX." | ||
type = string | ||
default = "PREMIUM" | ||
} | ||
|
||
variable "protocols" { | ||
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." | ||
type = list(string) | ||
default = ["NFSV3"] | ||
} | ||
|
||
variable "capacity_gib" { | ||
description = "Capacity of the storage pool (in GiB)." | ||
type = string | ||
default = 2048 | ||
} | ||
|
||
variable "volume_path" { | ||
description = "A unique file path for the volume. Used when creating mount targets. Needs to be unique per location." | ||
type = string | ||
default = "export" | ||
} | ||
|
||
variable "network" { | ||
description = "VPC network name with format: `projects/{{project}}/global/networks/{{network}}`" | ||
type = string | ||
} | ||
|
||
|
||
variable "allowed_clients" { | ||
description = "CIDR blocks allowed to mount nfs exports" | ||
type = string | ||
default = "0.0.0.0/0" | ||
} | ||
|
||
variable "netapp_subnet_cidr" { | ||
description = "Address space for Google Cloud NetApp Volumes subnet" | ||
type = string | ||
default = "192.168.5.0/24" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.