in pkg/engine/engine.go [545:685]
func getAddonFuncMap(addon api.KubernetesAddon, cs *api.ContainerService) template.FuncMap {
return template.FuncMap{
"ContainerImage": func(name string) string {
i := addon.GetAddonContainersIndexByName(name)
return addon.Containers[i].Image
},
"ContainerCPUReqs": func(name string) string {
i := addon.GetAddonContainersIndexByName(name)
return addon.Containers[i].CPURequests
},
"ContainerCPULimits": func(name string) string {
i := addon.GetAddonContainersIndexByName(name)
return addon.Containers[i].CPULimits
},
"ContainerMemReqs": func(name string) string {
i := addon.GetAddonContainersIndexByName(name)
return addon.Containers[i].MemoryRequests
},
"ContainerMemLimits": func(name string) string {
i := addon.GetAddonContainersIndexByName(name)
return addon.Containers[i].MemoryLimits
},
"ContainerConfig": func(name string) string {
return addon.Config[name]
},
"ContainerConfigBase64": func(name string) string {
return base64.StdEncoding.EncodeToString([]byte(addon.Config[name]))
},
"HasWindows": func() bool {
return cs.Properties.HasWindows()
},
"IsCustomCloudProfile": func() bool {
return cs.Properties.IsCustomCloudProfile()
},
"HasLinux": func() bool {
return cs.Properties.AnyAgentIsLinux()
},
"IsAzureStackCloud": func() bool {
return cs.Properties.IsAzureStackCloud()
},
"NeedsStorageAccountStorageClasses": func() bool {
return len(cs.Properties.AgentPoolProfiles) > 0 && cs.Properties.AgentPoolProfiles[0].StorageProfile == api.StorageAccount
},
"NeedsManagedDiskStorageClasses": func() bool {
return len(cs.Properties.AgentPoolProfiles) > 0 && cs.Properties.AgentPoolProfiles[0].StorageProfile == api.ManagedDisks
},
"UsesCloudControllerManager": func() bool {
return to.Bool(cs.Properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager)
},
"HasAvailabilityZones": func() bool {
return cs.Properties.HasAvailabilityZones()
},
"HasAgentPoolAvailabilityZones": func() bool {
return cs.Properties.HasAgentPoolAvailabilityZones()
},
"GetAgentPoolZones": func() string {
if len(cs.Properties.AgentPoolProfiles) == 0 {
return ""
}
var zones string
for _, pool := range cs.Properties.AgentPoolProfiles {
if pool.AvailabilityZones != nil {
for _, zone := range pool.AvailabilityZones {
zones += fmt.Sprintf("\n - %s-%s", cs.Location, zone)
}
}
if zones != "" {
return zones
}
}
return zones
},
"CSIControllerReplicas": func() string {
replicas := "2"
if cs.Properties.HasWindows() && !cs.Properties.AnyAgentIsLinux() {
replicas = "1"
}
return replicas
},
"ShouldEnableCSISnapshotFeature": func(csiDriverName string) bool {
// Snapshot is not available for Windows clusters
if cs.Properties.HasWindows() && !cs.Properties.AnyAgentIsLinux() {
return false
}
switch csiDriverName {
case common.AzureDiskCSIDriverAddonName:
// Snapshot feature for Azure Disk CSI Driver is in beta, requiring K8s 1.17+
return common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.17.0")
case common.AzureFileCSIDriverAddonName:
// Snapshot feature for Azure File CSI Driver is in alpha, requiring K8s 1.13-1.16
return common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.13.0") &&
!common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.17.0")
}
return false
},
"IsKubernetesVersionGe": func(version string) bool {
return common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, version)
},
"GetAADPodIdentityTaintKey": func() string {
return common.AADPodIdentityTaintKey
},
"GetMode": func() string {
return addon.Mode
},
"GetClusterSubnet": func() string {
return cs.Properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet
},
"IsAzureCNI": func() bool {
return cs.Properties.OrchestratorProfile.IsAzureCNI()
},
"GetCRDAPIVersion": func() string {
if common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.22.0") {
return "apiextensions.k8s.io/v1"
}
return "apiextensions.k8s.io/v1beta1"
},
"GetRBACAPIVersion": func() string {
if common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.22.0") {
return "rbac.authorization.k8s.io/v1"
}
return "rbac.authorization.k8s.io/v1beta1"
},
"GetStorageAPIVersion": func() string {
if common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.22.0") {
return "storage.k8s.io/v1"
}
return "storage.k8s.io/v1beta1"
},
"GetWebhookAPIVersion": func() string {
if common.IsKubernetesVersionGe(cs.Properties.OrchestratorProfile.OrchestratorVersion, "1.22.0") {
return "admissionregistration.k8s.io/v1"
}
return "admissionregistration.k8s.io/v1beta1"
},
"ShouldEnforceKubernetesDisaStig": func() bool {
return cs.Properties.FeatureFlags.IsFeatureEnabled("EnforceKubernetesDisaStig")
},
}
}