From 19f8ec7b2987a6bf93a27dd0b37726a775a7d62b Mon Sep 17 00:00:00 2001 From: Keerthana Routhu Date: Mon, 4 Aug 2025 21:22:12 -0700 Subject: [PATCH 1/2] test --- test/e2e/jobs/scale.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/jobs/scale.go b/test/e2e/jobs/scale.go index f4c8ac7d9a..34b8647878 100644 --- a/test/e2e/jobs/scale.go +++ b/test/e2e/jobs/scale.go @@ -14,7 +14,7 @@ import ( func DefaultScaleTestOptions() scaletest.Options { return scaletest.Options{ - Namespace: "scale-test", + Namespace: "krouthu-scale-test", MaxKwokPodsPerNode: 0, NumKwokDeployments: 0, NumKwokReplicas: 0, From e5689f78d4aadd6af727d8cef8d265789cbe764c Mon Sep 17 00:00:00 2001 From: Keerthana Routhu Date: Mon, 4 Aug 2025 21:27:10 -0700 Subject: [PATCH 2/2] test --- test/e2e/framework/azure/create-cluster.go | 35 +++++++---- test/e2e/framework/azure/create-publicip.go | 64 +++++++++++++++++++++ test/e2e/jobs/scale.go | 9 ++- 3 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 test/e2e/framework/azure/create-publicip.go diff --git a/test/e2e/framework/azure/create-cluster.go b/test/e2e/framework/azure/create-cluster.go index c6a5b9e50a..81dc9eaba9 100644 --- a/test/e2e/framework/azure/create-cluster.go +++ b/test/e2e/framework/azure/create-cluster.go @@ -20,14 +20,15 @@ const ( var defaultClusterCreateTimeout = 30 * time.Minute type CreateCluster struct { - SubscriptionID string - ResourceGroupName string - Location string - ClusterName string - podCidr string - vmSize string - networkPluginMode string - Nodes int32 + SubscriptionID string + ResourceGroupName string + Location string + ClusterName string + podCidr string + vmSize string + networkPluginMode string + Nodes int32 + loadBalancerOutboundIpId string } func (c *CreateCluster) SetPodCidr(podCidr string) *CreateCluster { @@ -45,6 +46,11 @@ func (c *CreateCluster) SetNetworkPluginMode(networkPluginMode string) *CreateCl return c } +func (c *CreateCluster) SetPublicIP(loadBalancerOutboundIpId string) *CreateCluster { + c.loadBalancerOutboundIpId = loadBalancerOutboundIpId + return c +} + func (c *CreateCluster) Run() error { cred, err := azidentity.NewAzureCLICredential(nil) if err != nil { @@ -128,9 +134,16 @@ func GetStarterClusterTemplate(location string) armcontainerservice.ManagedClust EnableRBAC: to.Ptr(true), LinuxProfile: nil, NetworkProfile: &armcontainerservice.NetworkProfile{ - LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard), - OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer), - NetworkPlugin: to.Ptr(armcontainerservice.NetworkPluginAzure), + LoadBalancerSKU: to.Ptr(armcontainerservice.LoadBalancerSKUStandard), + OutboundType: to.Ptr(armcontainerservice.OutboundTypeLoadBalancer), + NetworkPlugin: to.Ptr(armcontainerservice.NetworkPluginAzure), + LoadBalancerProfile: &armcontainerservice.ManagedClusterLoadBalancerProfile{ + OutboundIPs: &armcontainerservice.ManagedClusterLoadBalancerProfileOutboundIPs{ + PublicIPs: []*armcontainerservice.ResourceReference{ + ID: to.Ptr(c.loadBalancerOutboundIpId) + } + } + } }, WindowsProfile: &armcontainerservice.ManagedClusterWindowsProfile{ AdminPassword: to.Ptr("replacePassword1234$"), diff --git a/test/e2e/framework/azure/create-publicip.go b/test/e2e/framework/azure/create-publicip.go new file mode 100644 index 0000000000..f60c33740c --- /dev/null +++ b/test/e2e/framework/azure/create-publicip.go @@ -0,0 +1,64 @@ +package azure + +import ( + "context" + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v5" +) + + +type CreatePublicIp struct { + SubscriptionID string + ResourceGroupName string + Location string + PublicIpName string + IPTagType string + Tag string +} + +func (c *CreatePublicIp) Run() error { + cred, err := azidentity.NewAzureCLICredential(nil) + if err != nil { + return fmt.Errorf("failed to obtain a credential: %w", err) + } + ctx := context.Background() + clientFactory, err := armnetwork.NewClientFactory(c.SubscriptionID, cred, nil) + if err != nil { + return fmt.Errorf("failed to create client: %w", err) + } + + log.Printf("creating public ip \"%s\" in resource group \"%s\"...", c.PublicIpName, c.ResourceGroupName) + + poller, err := clientFactory.NewPublicIPAddressesClient().BeginCreateOrUpdate(ctx, c.ResourceGroupName, c.PublicIpName, armnetwork.PublicIpAddress{ + Location: to.Ptr(c.Location), + Properties: &armnetwork.PublicIPAddressPropertiesFormat{ + IPTags: []*armnetwork.IPTag{ + { + IPTagType: to.Ptr(c.IPTagType), + Tag: to.Ptr(c.Tag), + } + }, + }, + }, nil) + if err != nil { + return fmt.Errorf("failed to finish the request for create public ip: %w", err) + } + + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + return fmt.Errorf("failed to pull the result for create public ip: %w", err) + } + return nil +} + +func (c *CreatePublicIp) Prevalidate() error { + return nil +} + +func (c *CreatePublicIp) Stop() error { + return nil +} diff --git a/test/e2e/jobs/scale.go b/test/e2e/jobs/scale.go index 34b8647878..9d50121525 100644 --- a/test/e2e/jobs/scale.go +++ b/test/e2e/jobs/scale.go @@ -14,7 +14,7 @@ import ( func DefaultScaleTestOptions() scaletest.Options { return scaletest.Options{ - Namespace: "krouthu-scale-test", + Namespace: "scale-test", MaxKwokPodsPerNode: 0, NumKwokDeployments: 0, NumKwokReplicas: 0, @@ -57,9 +57,16 @@ func GetScaleTestInfra(subID, rg, clusterName, location, kubeConfigFilePath stri Location: location, }, nil) + job.AddStep(&azure.CreatePublicIp{ + PublicIpName: fmt.Sprintf("%s-lb-ip", clusterName) + IPTagType: "FirstPartyUsage", + Tag: "/NonProd" + }, nil) + job.AddStep((&azure.CreateCluster{ ClusterName: clusterName, Nodes: nodes, + loadBalancerOutboundIpId: fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers//Microsoft.Network/publicIPAddresses/%s-lb-ip", subID, rg, clusterName), }). SetPodCidr("100.64.0.0/10"). SetVMSize("Standard_D4_v3").