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