Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions test/e2e/framework/azure/create-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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$"),
Expand Down
64 changes: 64 additions & 0 deletions test/e2e/framework/azure/create-publicip.go
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 7 additions & 0 deletions test/e2e/jobs/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down