forked from Azure/AgentBaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclusterconfiguration.go
49 lines (41 loc) · 1.69 KB
/
clusterconfiguration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package scenario
import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice"
)
const (
// Default agentpool value of maxPods for Azure CNI
azureCNIDefaultMaxPodsPerNode = 30
)
// Selectors
func NetworkPluginKubenetSelector(cluster *armcontainerservice.ManagedCluster) bool {
if cluster != nil && cluster.Properties != nil && cluster.Properties.NetworkProfile != nil {
return *cluster.Properties.NetworkProfile.NetworkPlugin == armcontainerservice.NetworkPluginKubenet
}
return false
}
func NetworkPluginAzureSelector(cluster *armcontainerservice.ManagedCluster) bool {
if cluster != nil && cluster.Properties != nil && cluster.Properties.NetworkProfile != nil {
return *cluster.Properties.NetworkProfile.NetworkPlugin == armcontainerservice.NetworkPluginAzure
}
return false
}
// Mutators
func NetworkPluginKubenetMutator(cluster *armcontainerservice.ManagedCluster) {
if cluster != nil && cluster.Properties != nil && cluster.Properties.NetworkProfile != nil {
cluster.Properties.NetworkProfile.NetworkPlugin = to.Ptr(armcontainerservice.NetworkPluginKubenet)
}
}
func NetworkPluginAzureMutator(cluster *armcontainerservice.ManagedCluster) {
if cluster != nil && cluster.Properties != nil {
if cluster.Properties.NetworkProfile != nil {
cluster.Properties.NetworkProfile.NetworkPlugin = to.Ptr(armcontainerservice.NetworkPluginAzure)
}
// We also update each agentpool's maxPods setting to the default for Azure CNI
if cluster.Properties.AgentPoolProfiles != nil {
for _, app := range cluster.Properties.AgentPoolProfiles {
app.MaxPods = to.Ptr[int32](azureCNIDefaultMaxPodsPerNode)
}
}
}
}