Skip to content

Commit fd57d7b

Browse files
authored
PLT-1551: Added two node cluster supporrt edgenative cluster cloud config (#568)
1 parent 592d890 commit fd57d7b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

docs/resources/cluster_edge_native.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Refer to the [Import section](/docs#import) to learn more.
124124

125125
Optional:
126126

127+
- `is_two_node_cluster` (Boolean) Set to `true` to enable a two-node cluster.
127128
- `ntp_servers` (Set of String) A list of NTP servers to be used by the cluster.
128129
- `overlay_cidr_range` (String) The Overlay (VPN) creates a virtual network, using techniques like VxLAN. It overlays the existing network infrastructure, enhancing connectivity either at Layer 2 or Layer 3, making it flexible and adaptable for various needs. For example, `100.64.192.0/24`
129130
- `ssh_keys` (Set of String) List of public SSH (Secure Shell) to establish, administer, and communicate with remote clusters.

spectrocloud/resource_cluster_edge_native.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ func resourceClusterEdgeNative() *schema.Resource {
154154
ForceNew: true,
155155
Description: "The Overlay (VPN) creates a virtual network, using techniques like VxLAN. It overlays the existing network infrastructure, enhancing connectivity either at Layer 2 or Layer 3, making it flexible and adaptable for various needs. For example, `100.64.192.0/24`",
156156
},
157+
"is_two_node_cluster": {
158+
Type: schema.TypeBool,
159+
Optional: true,
160+
Default: false,
161+
Description: "Set to `true` to enable a two-node cluster.",
162+
},
157163
"ntp_servers": {
158164
Type: schema.TypeSet,
159165
Optional: true,
@@ -419,6 +425,9 @@ func flattenClusterConfigsEdgeNative(cloudConfig map[string]interface{}, config
419425
if config.Spec.ClusterConfig.OverlayNetworkConfiguration.Cidr != "" {
420426
m["overlay_cidr_range"] = config.Spec.ClusterConfig.OverlayNetworkConfiguration.Cidr
421427
}
428+
if config.Spec.ClusterConfig != nil {
429+
m["is_two_node_cluster"] = config.Spec.ClusterConfig.IsTwoNodeCluster
430+
}
422431

423432
return []interface{}{m}
424433
}
@@ -614,6 +623,7 @@ func resourceClusterEdgeNativeUpdate(ctx context.Context, d *schema.ResourceData
614623
func toEdgeNativeCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1SpectroEdgeNativeClusterEntity, error) {
615624
cloudConfig := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})
616625
sshKeys, _ := toSSHKeys(cloudConfig)
626+
isTwoNodeCluster := cloudConfig["is_two_node_cluster"]
617627

618628
clusterContext := d.Get("context").(string)
619629
profiles, err := toProfiles(c, d, clusterContext)
@@ -636,6 +646,7 @@ func toEdgeNativeCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1
636646
SSHKeys: sshKeys,
637647
ControlPlaneEndpoint: controlPlaneEndpoint,
638648
OverlayNetworkConfiguration: overlayConfig,
649+
IsTwoNodeCluster: isTwoNodeCluster.(bool),
639650
},
640651
},
641652
}

spectrocloud/resource_cluster_edge_native_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,11 @@ func TestFlattenClusterConfigsEdgeNative(t *testing.T) {
553553
// Assertions for valid Cloud Config and Config
554554
expectedValidResult := []interface{}{
555555
map[string]interface{}{
556-
"ssh_keys": []string{"ssh-key-1", "ssh-key-2"},
557-
"vip": "192.168.1.1",
558-
"ntp_servers": []string{"ntp-server-1", "ntp-server-2"},
559-
"overlay_cidr_range": "10.0.0.0/16",
556+
"ssh_keys": []string{"ssh-key-1", "ssh-key-2"},
557+
"vip": "192.168.1.1",
558+
"ntp_servers": []string{"ntp-server-1", "ntp-server-2"},
559+
"overlay_cidr_range": "10.0.0.0/16",
560+
"is_two_node_cluster": false,
560561
},
561562
}
562563
assert.Equal(t, expectedValidResult, resultValid)
@@ -576,7 +577,7 @@ func TestFlattenClusterConfigsEdgeNative(t *testing.T) {
576577
resultMissingHost := flattenClusterConfigsEdgeNative(cloudConfig, missingHostConfig)
577578

578579
// Assertions for missing Control Plane Endpoint Host
579-
assert.Equal(t, []interface{}{map[string]interface{}{}}, resultMissingHost)
580+
assert.Equal(t, []interface{}{map[string]interface{}{"is_two_node_cluster": false}}, resultMissingHost)
580581

581582
// Test case 3: Missing Cluster Config
582583
missingConfig := &models.V1EdgeNativeCloudConfig{}

0 commit comments

Comments
 (0)