@@ -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,18 @@ 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 )
53
54
55
+ podSubnetId := fmt .Sprintf ("/subscriptions/{subscriptionId}/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/subnets/%s" , c .SubscriptionID , c .VnetName , c .SubnetName )
56
+ npmCluster .Properties .AgentPoolProfiles [0 ].PodSubnetID = to .Ptr (podSubnetId )
57
+
54
58
//nolint:appendCombine // separate for verbosity
55
59
npmCluster .Properties .AgentPoolProfiles = append (npmCluster .Properties .AgentPoolProfiles , & armcontainerservice.ManagedClusterAgentPoolProfile { //nolint:all
56
60
Type : to .Ptr (armcontainerservice .AgentPoolTypeVirtualMachineScaleSets ),
57
61
// AvailabilityZones: []*string{to.Ptr("1")},
58
- Count : to.Ptr [int32 ](AuxilaryNodeCount ),
62
+ Count : to.Ptr [int32 ](c . NodesPerPool ),
59
63
EnableNodePublicIP : to .Ptr (false ),
60
64
Mode : to .Ptr (armcontainerservice .AgentPoolModeUser ),
61
65
OSType : to .Ptr (armcontainerservice .OSTypeWindows ),
@@ -64,6 +68,7 @@ func (c *CreateNPMCluster) Run() error {
64
68
VMSize : to .Ptr (AgentSKU ),
65
69
Name : to .Ptr ("ws22" ),
66
70
MaxPods : to .Ptr (int32 (MaxPodsPerNode )),
71
+ PodSubnetID : to .Ptr (podSubnetId ),
67
72
})
68
73
69
74
/* todo: add azlinux node pool
@@ -86,14 +91,15 @@ func (c *CreateNPMCluster) Run() error {
86
91
npmCluster .Properties .AgentPoolProfiles = append (npmCluster .Properties .AgentPoolProfiles , & armcontainerservice.ManagedClusterAgentPoolProfile { //nolint:all
87
92
Type : to .Ptr (armcontainerservice .AgentPoolTypeVirtualMachineScaleSets ),
88
93
// AvailabilityZones: []*string{to.Ptr("1")},
89
- Count : to.Ptr [int32 ](AuxilaryNodeCount ),
94
+ Count : to.Ptr [int32 ](c . NodesPerPool ),
90
95
EnableNodePublicIP : to .Ptr (false ),
91
96
Mode : to .Ptr (armcontainerservice .AgentPoolModeUser ),
92
97
OSType : to .Ptr (armcontainerservice .OSTypeLinux ),
93
98
ScaleDownMode : to .Ptr (armcontainerservice .ScaleDownModeDelete ),
94
99
VMSize : to .Ptr (AgentARMSKU ),
95
100
Name : to .Ptr ("arm64" ),
96
101
MaxPods : to .Ptr (int32 (MaxPodsPerNode )),
102
+ PodSubnetID : to .Ptr (podSubnetId ),
97
103
})
98
104
99
105
npmCluster .Properties .AutoUpgradeProfile = & armcontainerservice.ManagedClusterAutoUpgradeProfile {
@@ -105,7 +111,14 @@ func (c *CreateNPMCluster) Run() error {
105
111
if err != nil {
106
112
return fmt .Errorf ("failed to obtain a credential: %w" , err )
107
113
}
108
- ctx , cancel := context .WithTimeout (context .Background (), clusterTimeout )
114
+
115
+ var timeout time.Duration
116
+ if c .NodesPerPool > 20 {
117
+ timeout = largeClusterTimeout
118
+ } else {
119
+ timeout = clusterTimeout
120
+ }
121
+ ctx , cancel := context .WithTimeout (context .Background (), timeout )
109
122
defer cancel ()
110
123
111
124
clientFactory , err := armcontainerservice .NewClientFactory (c .SubscriptionID , cred , nil )
0 commit comments