Skip to content

Commit c5e6473

Browse files
committed
PLT-1551: Added two node cluster supporrt edgenative cluster cloud config
1 parent 574f53e commit c5e6473

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
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.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/robfig/cron v1.2.0
1313
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368
1414
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d
15-
github.com/spectrocloud/palette-sdk-go v0.0.0-20241227233030-cd7c351b4722
15+
github.com/spectrocloud/palette-sdk-go v0.0.0-20250128174237-7ff93c608ae2
1616
github.com/stretchr/testify v1.10.0
1717
gotest.tools v2.2.0+incompatible
1818
k8s.io/api v0.23.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368 h1:eY0BOyEbGu
601601
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368/go.mod h1:LlZ9We4kDaELYi7Is0SVmnySuDhwphJLS6ZT4wXxFIk=
602602
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d h1:OMRbHxMJ1a+G1BYzvUYuMM0wLkYJPdnEOFx16faQ/UY=
603603
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d/go.mod h1:MktpRPnSXDTHsQrFSD+daJFQ1zMLSR+1gWOL31jVvWE=
604-
github.com/spectrocloud/palette-sdk-go v0.0.0-20241227233030-cd7c351b4722 h1:Z574padnTtuCGPZfxhtbRGl3CtsAF8Zx+rc5aCo30zU=
605-
github.com/spectrocloud/palette-sdk-go v0.0.0-20241227233030-cd7c351b4722/go.mod h1:Zv1+/Imw/lIOPAa+q9TzdyKiXmIzfLSwVTj11WemIZc=
604+
github.com/spectrocloud/palette-sdk-go v0.0.0-20250128174237-7ff93c608ae2 h1:dgisL6mrzj4aEUEfOfotrTPGvClYjf+m3DeiLciR1CQ=
605+
github.com/spectrocloud/palette-sdk-go v0.0.0-20250128174237-7ff93c608ae2/go.mod h1:Zv1+/Imw/lIOPAa+q9TzdyKiXmIzfLSwVTj11WemIZc=
606606
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
607607
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
608608
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=

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)