Skip to content

Commit c83a222

Browse files
feat: Community Netapp Networking Components Enable #291 (#292)
* feat: Community Netapp Networking Components Enable * Adding support for a new community flag providing options to disable deployment of Netapp Networking Components Signed-off-by: Thomas M <[email protected]> * Updating documentation #291 Adding an example of when the community_netapp_networking_components_enabled field should be set to false. Signed-off-by: Thomas M <[email protected]> --------- Signed-off-by: Thomas M <[email protected]> Co-authored-by: Chris Miller <[email protected]>
1 parent c0d9232 commit c83a222

File tree

6 files changed

+126
-4
lines changed

6 files changed

+126
-4
lines changed

docs/community/community-config-vars.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ Community contributed configuration variables are listed in the tables below. Th
99

1010
## Table of Contents
1111

12-
* [Community Feature](#community_feature)
12+
- [Community-Contributed Configuration Variables](#community-contributed-configuration-variables)
13+
- [Table of Contents](#table-of-contents)
14+
- [Community Feature](#community-feature)
15+
- [Netapp Networking Components Enabled](#netapp-networking-components-enabled)
1316

1417
<a name="community_feature"></a>
1518
## Community Feature
@@ -22,4 +25,17 @@ Here is a table with the variables you would use to configure it
2225

2326
| Name | Description | Type | Default | Release Added | Notes |
2427
| :--- | ---: | ---: | ---: | ---: | ---: |
25-
| community_enable_community_feature | Enable community feature | bool | false | vMajor.Minor.Patch | |
28+
| community_enable_community_feature | Enable community feature | bool | false | vMajor.Minor.Patch | |
29+
30+
<a name="netapp_networking_components_enabled"></a>
31+
## Netapp Networking Components Enabled
32+
33+
Netapp Networking Components Enabling allows for control of the deployment of Netapp networking components when deploying HA with Netapp Volumes as the backend. This leaves the expectation that the Network Peering and IP ranges for Netapp have already been configured for the subscription and this Terraform project is just deploying some extra volumes.
34+
35+
An example case where this would be necessary: two clusters using HA with Netapp Volumes are being deployed to the same project. In this case, the first cluster will be able to register the private IP range and the peering. The second cluster will need to disable the deployment of these components.
36+
37+
There are no checks that the Netapp Peering and IP Ranges have been properly configured. That is left to the Terraform Apply to detect any deployment issues or the usability of the resulting platform to determine any permission issues.
38+
39+
| Name | Description | Type | Default | Release Added | Notes |
40+
| :--- | ---: | ---: | ---: | ---: | ---: |
41+
| community_netapp_networking_components_enabled | Enable Netapp networking components | bool | true | v7.6.3 | |

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,6 @@ module "google_netapp" {
319319
volume_path = "${var.prefix}-${var.netapp_volume_path}"
320320
allowed_clients = join(",", [local.gke_subnet_cidr, local.misc_subnet_cidr])
321321
depends_on = [ module.gke ]
322+
323+
community_netapp_networking_components_enabled = var.community_netapp_networking_components_enabled
322324
}

modules/google_netapp/main.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
# Reserve compute address CIDR for NetApp Volumes to use
99
resource "google_compute_global_address" "private_ip_alloc" {
10+
count = var.community_netapp_networking_components_enabled ? 1 : 0
11+
1012
name = "${var.network}-ip-range"
1113
purpose = "VPC_PEERING"
1214
address_type = "INTERNAL"
@@ -17,16 +19,20 @@ resource "google_compute_global_address" "private_ip_alloc" {
1719

1820
# Create the PSA peering
1921
resource "google_service_networking_connection" "default" {
22+
count = var.community_netapp_networking_components_enabled ? 1 : 0
23+
2024
network = var.network
2125
service = "netapp.servicenetworking.goog"
22-
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
26+
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc[0].name]
2327

2428
deletion_policy = "ABANDON"
2529
}
2630

2731
# Modify the PSA Connection to allow import/export of custom routes
2832
resource "google_compute_network_peering_routes_config" "route_updates" {
29-
peering = google_service_networking_connection.default.peering
33+
count = var.community_netapp_networking_components_enabled ? 1 : 0
34+
35+
peering = google_service_networking_connection.default[0].peering
3036
network = var.network
3137

3238
import_custom_routes = true

modules/google_netapp/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ variable "netapp_subnet_cidr" {
5252
type = string
5353
default = "192.168.5.0/24"
5454
}
55+
56+
# Community Contribution
57+
variable "community_netapp_networking_components_enabled" {
58+
description = "Community Contribution. Enable/Disable the deployment of Networking components for Netapp resources. Enabled by default."
59+
type = bool
60+
default = true
61+
}

test/nondefaultplan/netapp_test.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package nondefaultplan
5+
6+
import (
7+
"test/helpers"
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
// Test the default variables when using the sample-input-defaults.tfvars file
14+
// with storage_type set to "ha". This should engage the Azure NetApp Files module,
15+
// with the default values as tested herein.
16+
func TestPlanNetApp(t *testing.T) {
17+
t.Parallel()
18+
19+
variables := helpers.GetDefaultPlanVars(t)
20+
variables["prefix"] = "net-app"
21+
variables["storage_type"] = "ha"
22+
variables["storage_type_backend"] = "netapp"
23+
24+
tests := map[string]helpers.TestCase{
25+
"poolExists": {
26+
Expected: `nil`,
27+
ResourceMapName: "module.google_netapp[0].google_netapp_storage_pool.netapp-tf-pool",
28+
AttributeJsonPath: "{$}",
29+
AssertFunction: assert.NotEqual,
30+
},
31+
"poolServiceLevel": {
32+
Expected: `PREMIUM`,
33+
ResourceMapName: "module.google_netapp[0].google_netapp_storage_pool.netapp-tf-pool",
34+
AttributeJsonPath: "{$.service_level}",
35+
},
36+
"capactityGib": {
37+
Expected: `2048`,
38+
ResourceMapName: "module.google_netapp[0].google_netapp_storage_pool.netapp-tf-pool",
39+
AttributeJsonPath: "{$.capacity_gib}",
40+
},
41+
"volumeExists": {
42+
Expected: `nil`,
43+
ResourceMapName: "module.google_netapp[0].google_netapp_volume.netapp-nfs-volume",
44+
AttributeJsonPath: "{$}",
45+
AssertFunction: assert.NotEqual,
46+
},
47+
"volumeProtocols": {
48+
Expected: `["NFSV3"]`,
49+
ResourceMapName: "module.google_netapp[0].google_netapp_volume.netapp-nfs-volume",
50+
AttributeJsonPath: "{$.protocols}",
51+
AssertFunction: assert.Contains,
52+
},
53+
"shareName": {
54+
Expected: `net-app-export`,
55+
ResourceMapName: "module.google_netapp[0].google_netapp_volume.netapp-nfs-volume",
56+
AttributeJsonPath: "{$.share_name}",
57+
},
58+
"communityNetappPrivateIpAllocEnabled": {
59+
Expected: `nil`,
60+
ResourceMapName: "module.google_netapp[0].google_compute_global_address.private_ip_alloc[0]",
61+
AttributeJsonPath: "{$}",
62+
AssertFunction: assert.NotEqual,
63+
},
64+
"communityNetappRouteUpdatesEnabled": {
65+
Expected: `nil`,
66+
ResourceMapName: "module.google_netapp[0].google_compute_network_peering_routes_config.route_updates[0]",
67+
AttributeJsonPath: "{$}",
68+
AssertFunction: assert.NotEqual,
69+
},
70+
"communityNetappServiceNetworkingConnectionEnabled": {
71+
Expected: `nil`,
72+
ResourceMapName: "module.google_netapp[0].google_service_networking_connection.default[0]",
73+
AttributeJsonPath: "{$}",
74+
AssertFunction: assert.NotEqual,
75+
},
76+
}
77+
78+
plan := helpers.GetPlan(t, variables)
79+
helpers.RunTests(t, tests, plan)
80+
}

variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,4 +604,15 @@ variable "cluster_node_pool_mode" {
604604
description = "Flag for predefined cluster node configurations - Values : default, minimal"
605605
type = string
606606
default = "default"
607+
}
608+
609+
# Community Contribution
610+
# Disabling this feature will prevent the deployment of a new private IP range and network peeering when utilizing
611+
# HA storage with Netapp Volumes. This should be utilized when a project has pre-existing networking components that
612+
# include the network peering configuration for Netapp. Otherwise, this feature should remain a True to allow the
613+
# networking configuration to be deployed.
614+
variable "community_netapp_networking_components_enabled" {
615+
description = "Community Contribution. Enable/Disable the deployment of Networking components for Netapp resources. Enabled by default."
616+
type = bool
617+
default = true
607618
}

0 commit comments

Comments
 (0)