@@ -18,11 +18,11 @@ var (
18
18
)
19
19
20
20
const (
21
+ largeClusterTimeout = 30 * time .Minute
21
22
clusterTimeout = 15 * time .Minute
22
23
clusterCreateTicker = 30 * time .Second
23
24
pollFrequency = 5 * time .Second
24
- AgentARMSKU = "Standard_D4pls_v5"
25
- AuxilaryNodeCount = 1
25
+ AgentARMSKU = "Standard_D4pls_v6"
26
26
)
27
27
28
28
type CreateNPMCluster struct {
@@ -35,6 +35,7 @@ type CreateNPMCluster struct {
35
35
PodCidr string
36
36
DNSServiceIP string
37
37
ServiceCidr string
38
+ NodesPerPool int32
38
39
}
39
40
40
41
func (c * CreateNPMCluster ) Prevalidate () error {
@@ -47,15 +48,21 @@ func (c *CreateNPMCluster) Stop() error {
47
48
48
49
func (c * CreateNPMCluster ) Run () error {
49
50
// Start with default cluster template
50
- npmCluster := GetStarterClusterTemplate (c .Location )
51
+ npmCluster := GetStarterClusterTemplate (c .Location , c . NodesPerPool )
51
52
52
53
npmCluster .Properties .NetworkProfile .NetworkPolicy = to .Ptr (armcontainerservice .NetworkPolicyAzure )
54
+ npmCluster .Properties .NetworkProfile .PodCidr = to .Ptr (c .PodCidr )
55
+ npmCluster .Properties .NetworkProfile .ServiceCidr = to .Ptr (c .ServiceCidr )
56
+
57
+ // podSubnetId := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/subnets/%s", c.SubscriptionID, c.ResourceGroupName, c.VnetName, c.SubnetName)
58
+ // vnetSubnetId := fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/subnets/%s", c.SubscriptionID, c.ResourceGroupName, c.VnetName, c.SubnetName)
59
+ // npmCluster.Properties.AgentPoolProfiles[0].PodSubnetID = to.Ptr(podSubnetId)
53
60
54
61
//nolint:appendCombine // separate for verbosity
55
62
npmCluster .Properties .AgentPoolProfiles = append (npmCluster .Properties .AgentPoolProfiles , & armcontainerservice.ManagedClusterAgentPoolProfile { //nolint:all
56
63
Type : to .Ptr (armcontainerservice .AgentPoolTypeVirtualMachineScaleSets ),
57
64
// AvailabilityZones: []*string{to.Ptr("1")},
58
- Count : to.Ptr [int32 ](AuxilaryNodeCount ),
65
+ Count : to.Ptr [int32 ](c . NodesPerPool ),
59
66
EnableNodePublicIP : to .Ptr (false ),
60
67
Mode : to .Ptr (armcontainerservice .AgentPoolModeUser ),
61
68
OSType : to .Ptr (armcontainerservice .OSTypeWindows ),
@@ -64,6 +71,8 @@ func (c *CreateNPMCluster) Run() error {
64
71
VMSize : to .Ptr (AgentSKU ),
65
72
Name : to .Ptr ("ws22" ),
66
73
MaxPods : to .Ptr (int32 (MaxPodsPerNode )),
74
+ // VnetSubnetID: to.Ptr(vnetSubnetId),
75
+ // PodSubnetID: to.Ptr(podSubnetId),
67
76
})
68
77
69
78
/* todo: add azlinux node pool
@@ -86,14 +95,15 @@ func (c *CreateNPMCluster) Run() error {
86
95
npmCluster .Properties .AgentPoolProfiles = append (npmCluster .Properties .AgentPoolProfiles , & armcontainerservice.ManagedClusterAgentPoolProfile { //nolint:all
87
96
Type : to .Ptr (armcontainerservice .AgentPoolTypeVirtualMachineScaleSets ),
88
97
// AvailabilityZones: []*string{to.Ptr("1")},
89
- Count : to.Ptr [int32 ](AuxilaryNodeCount ),
98
+ Count : to.Ptr [int32 ](c . NodesPerPool ),
90
99
EnableNodePublicIP : to .Ptr (false ),
91
100
Mode : to .Ptr (armcontainerservice .AgentPoolModeUser ),
92
101
OSType : to .Ptr (armcontainerservice .OSTypeLinux ),
93
102
ScaleDownMode : to .Ptr (armcontainerservice .ScaleDownModeDelete ),
94
103
VMSize : to .Ptr (AgentARMSKU ),
95
104
Name : to .Ptr ("arm64" ),
96
105
MaxPods : to .Ptr (int32 (MaxPodsPerNode )),
106
+ // PodSubnetID: to.Ptr(podSubnetId),
97
107
})
98
108
99
109
npmCluster .Properties .AutoUpgradeProfile = & armcontainerservice.ManagedClusterAutoUpgradeProfile {
@@ -105,7 +115,14 @@ func (c *CreateNPMCluster) Run() error {
105
115
if err != nil {
106
116
return fmt .Errorf ("failed to obtain a credential: %w" , err )
107
117
}
108
- ctx , cancel := context .WithTimeout (context .Background (), clusterTimeout )
118
+
119
+ var timeout time.Duration
120
+ if c .NodesPerPool > 20 {
121
+ timeout = largeClusterTimeout
122
+ } else {
123
+ timeout = clusterTimeout
124
+ }
125
+ ctx , cancel := context .WithTimeout (context .Background (), timeout )
109
126
defer cancel ()
110
127
111
128
clientFactory , err := armcontainerservice .NewClientFactory (c .SubscriptionID , cred , nil )
0 commit comments