in pkg/api/defaults.go [86:672]
func (cs *ContainerService) setOrchestratorDefaults(isUpgrade, isScale bool) {
isUpdate := isUpgrade || isScale
a := cs.Properties
cloudSpecConfig := cs.GetCloudSpecConfig()
if a.OrchestratorProfile == nil {
a.OrchestratorProfile = &OrchestratorProfile{
OrchestratorType: Kubernetes,
}
}
o := a.OrchestratorProfile
o.OrchestratorVersion = common.GetValidPatchVersion(
o.OrchestratorType,
o.OrchestratorVersion, isUpdate, a.HasWindows(), a.IsAzureStackCloud())
switch o.OrchestratorType {
case Kubernetes:
if o.KubernetesConfig == nil {
o.KubernetesConfig = &KubernetesConfig{}
}
// For backwards compatibility with original, overloaded "NetworkPolicy" config vector
// we translate deprecated NetworkPolicy usage to the NetworkConfig equivalent
// and set a default network policy enforcement configuration
switch o.KubernetesConfig.NetworkPolicy {
case NetworkPolicyAzure:
if o.KubernetesConfig.NetworkPlugin == "" {
o.KubernetesConfig.NetworkPlugin = NetworkPluginAzure
o.KubernetesConfig.NetworkPolicy = DefaultNetworkPolicy
}
case NetworkPolicyNone:
o.KubernetesConfig.NetworkPlugin = NetworkPluginKubenet
o.KubernetesConfig.NetworkPolicy = DefaultNetworkPolicy
case NetworkPolicyCalico:
if o.KubernetesConfig.NetworkPlugin == "" {
// If not specified, then set the network plugin to be kubenet
// for backwards compatibility. Otherwise, use what is specified.
o.KubernetesConfig.NetworkPlugin = NetworkPluginKubenet
}
case NetworkPolicyCilium:
o.KubernetesConfig.NetworkPlugin = NetworkPluginCilium
case NetworkPolicyAntrea:
if o.KubernetesConfig.NetworkPlugin == "" {
o.KubernetesConfig.NetworkPlugin = NetworkPluginAzure
}
}
if a.IsAzureStackCloud() {
// Azure Stack's custom hyperkube image is now hosted along with MCR images.
// Forcing KubernetesImageBase/KubernetesImageBaseType.
mcrKubernetesImageBase := cloudSpecConfig.KubernetesSpecConfig.MCRKubernetesImageBase
if !strings.EqualFold(o.KubernetesConfig.KubernetesImageBase, mcrKubernetesImageBase) {
log.Warnf("apimodel: orchestratorProfile.kubernetesConfig.kubernetesImageBase forced to \"%s\"\n", mcrKubernetesImageBase)
}
o.KubernetesConfig.KubernetesImageBase = cloudSpecConfig.KubernetesSpecConfig.MCRKubernetesImageBase
if !strings.EqualFold(o.KubernetesConfig.KubernetesImageBaseType, common.KubernetesImageBaseTypeMCR) {
log.Warnf("apimodel: orchestratorProfile.kubernetesConfig.kubernetesImageBaseType forced to \"%s\"\n", common.KubernetesImageBaseTypeMCR)
}
o.KubernetesConfig.KubernetesImageBaseType = common.KubernetesImageBaseTypeMCR
if isUpgrade && strings.EqualFold(o.KubernetesConfig.MCRKubernetesImageBase, "mcr.microsoft.com/k8s/core/") {
log.Warn("apimodel: clearing deprecated orchestratorProfile.kubernetesConfig.mcrKubernetesImageBase value\n")
o.KubernetesConfig.MCRKubernetesImageBase = ""
}
}
if isUpgrade {
if (o.KubernetesConfig.KubernetesImageBase == "" || o.KubernetesConfig.KubernetesImageBase == cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase) &&
(o.KubernetesConfig.KubernetesImageBaseType == "" || o.KubernetesConfig.KubernetesImageBaseType == common.KubernetesImageBaseTypeGCR) {
o.KubernetesConfig.KubernetesImageBase = cloudSpecConfig.KubernetesSpecConfig.MCRKubernetesImageBase
o.KubernetesConfig.KubernetesImageBaseType = common.KubernetesImageBaseTypeMCR
}
}
if o.KubernetesConfig.KubernetesImageBase == "" {
o.KubernetesConfig.KubernetesImageBase = cloudSpecConfig.KubernetesSpecConfig.MCRKubernetesImageBase
} else {
if o.KubernetesConfig.KubernetesImageBase[len(o.KubernetesConfig.KubernetesImageBase)-1:] != "/" {
o.KubernetesConfig.KubernetesImageBase += "/"
}
}
if o.KubernetesConfig.KubernetesImageBaseType == "" {
o.KubernetesConfig.KubernetesImageBaseType = common.KubernetesImageBaseTypeMCR
}
if o.KubernetesConfig.MCRKubernetesImageBase == "" {
o.KubernetesConfig.MCRKubernetesImageBase = cloudSpecConfig.KubernetesSpecConfig.MCRKubernetesImageBase
}
if o.KubernetesConfig.EtcdVersion == "" {
o.KubernetesConfig.EtcdVersion = DefaultEtcdVersion
} else if isUpgrade {
if o.KubernetesConfig.EtcdVersion != DefaultEtcdVersion {
// Override (i.e., upgrade) the etcd version if the default is newer in an upgrade scenario
if common.GetMinVersion([]string{o.KubernetesConfig.EtcdVersion, DefaultEtcdVersion}, true) == o.KubernetesConfig.EtcdVersion {
log.Warnf("etcd will be upgraded to version %s\n", DefaultEtcdVersion)
o.KubernetesConfig.EtcdVersion = DefaultEtcdVersion
}
}
}
if !isUpgrade && !isScale &&
!cs.Properties.IsCustomCloudProfile() &&
!cs.Properties.MasterProfile.IsVirtualMachineScaleSets() &&
o.KubernetesConfig.UseManagedIdentity == nil {
o.KubernetesConfig.UseManagedIdentity = to.BoolPtr(true)
}
if a.HasWindows() {
if o.KubernetesConfig.NetworkPlugin == "" {
o.KubernetesConfig.NetworkPlugin = DefaultNetworkPluginWindows
}
} else {
if o.KubernetesConfig.NetworkPlugin == "" {
o.KubernetesConfig.NetworkPlugin = DefaultNetworkPlugin
}
}
if o.KubernetesConfig.NetworkPlugin == NetworkPluginAzure {
if o.KubernetesConfig.NetworkMode == "" {
o.KubernetesConfig.NetworkMode = NetworkModeTransparent
}
}
if o.KubernetesConfig.ContainerRuntime == "" {
o.KubernetesConfig.ContainerRuntime = DefaultContainerRuntime
if a.IsAzureStackCloud() && common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.24.0") {
log.Warnf("The docker runtime is no longer supported for v1.24+ clusters, setting ContainerRuntime to 'containerd'")
o.KubernetesConfig.ContainerRuntime = Containerd
}
}
switch o.KubernetesConfig.ContainerRuntime {
case Docker:
if o.KubernetesConfig.MobyVersion == "" || isUpdate {
if o.KubernetesConfig.MobyVersion != DefaultMobyVersion {
if isUpgrade {
log.Warnf("Moby will be upgraded to version %s\n", DefaultMobyVersion)
} else if isScale {
log.Warnf("Any new nodes will have Moby version %s\n", DefaultMobyVersion)
}
}
o.KubernetesConfig.MobyVersion = DefaultMobyVersion
}
// Moby versions >= 19.03 depend on containerd packaging (instead of the moby packages supplying their own containerd)
// For that case we'll need to specify the containerd version.
if versions.GreaterThanOrEqualTo(o.KubernetesConfig.MobyVersion, "19.03") && (o.KubernetesConfig.ContainerdVersion == "" || isUpdate) {
if o.KubernetesConfig.ContainerdVersion != DefaultContainerdVersion {
if isUpgrade {
log.Warnf("containerd will be upgraded to version %s\n", DefaultContainerdVersion)
}
if isScale {
log.Warnf("Any new nodes will have containerd version %s\n", DefaultContainerdVersion)
}
}
o.KubernetesConfig.ContainerdVersion = DefaultContainerdVersion
}
case Containerd:
if o.KubernetesConfig.ContainerdVersion == "" || isUpdate {
if o.KubernetesConfig.ContainerdVersion != DefaultContainerdVersion {
if isUpgrade {
log.Warnf("containerd will be upgraded to version %s\n", DefaultContainerdVersion)
} else if isScale {
log.Warnf("Any new nodes will have containerd version %s\n", DefaultContainerdVersion)
}
}
o.KubernetesConfig.ContainerdVersion = DefaultContainerdVersion
}
if o.KubernetesConfig.WindowsContainerdURL == "" || isUpdate {
o.KubernetesConfig.WindowsContainerdURL = DefaultWindowsContainerdURL
}
}
if o.KubernetesConfig.ClusterSubnet == "" {
if o.IsAzureCNI() {
// When Azure CNI is enabled, all masters, agents and pods share the same large subnet.
// Except when master is VMSS, then masters and agents have separate subnets within the same large subnet.
o.KubernetesConfig.ClusterSubnet = DefaultKubernetesSubnet
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6DualStack") {
o.KubernetesConfig.ClusterSubnet = strings.Join([]string{DefaultKubernetesSubnet, cs.getDefaultKubernetesClusterSubnetIPv6()}, ",")
}
} else {
o.KubernetesConfig.ClusterSubnet = DefaultKubernetesClusterSubnet
// ipv6 only cluster
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6Only") {
o.KubernetesConfig.ClusterSubnet = DefaultKubernetesClusterSubnetIPv6
}
// ipv4 and ipv6 subnet for dual stack
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6DualStack") {
o.KubernetesConfig.ClusterSubnet = strings.Join([]string{DefaultKubernetesClusterSubnet, cs.getDefaultKubernetesClusterSubnetIPv6()}, ",")
}
}
} else {
// ensure 2 subnets exists if ipv6 dual stack feature is enabled
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6DualStack") {
clusterSubnets := strings.Split(o.KubernetesConfig.ClusterSubnet, ",")
if len(clusterSubnets) == 1 {
// if error exists, then it'll be caught by validate
ip, _, err := net.ParseCIDR(clusterSubnets[0])
if err == nil {
if ip.To4() != nil {
// the first cidr block is ipv4, so append ipv6
clusterSubnets = append(clusterSubnets, cs.getDefaultKubernetesClusterSubnetIPv6())
} else {
// first cidr has to be ipv4
if o.IsAzureCNI() {
clusterSubnets = append([]string{DefaultKubernetesSubnet}, clusterSubnets...)
} else {
clusterSubnets = append([]string{DefaultKubernetesClusterSubnet}, clusterSubnets...)
}
}
// only set the cluster subnet if no error has been encountered
}
o.KubernetesConfig.ClusterSubnet = strings.Join(clusterSubnets, ",")
}
}
}
if o.KubernetesConfig.GCHighThreshold == 0 {
o.KubernetesConfig.GCHighThreshold = DefaultKubernetesGCHighThreshold
}
if o.KubernetesConfig.GCLowThreshold == 0 {
o.KubernetesConfig.GCLowThreshold = DefaultKubernetesGCLowThreshold
}
if o.KubernetesConfig.DNSServiceIP == "" {
o.KubernetesConfig.DNSServiceIP = DefaultKubernetesDNSServiceIP
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6Only") {
o.KubernetesConfig.DNSServiceIP = DefaultKubernetesDNSServiceIPv6
}
}
if o.KubernetesConfig.DockerBridgeSubnet == "" {
o.KubernetesConfig.DockerBridgeSubnet = DefaultDockerBridgeSubnet
}
if o.KubernetesConfig.ServiceCIDR == "" {
o.KubernetesConfig.ServiceCIDR = DefaultKubernetesServiceCIDR
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6Only") {
o.KubernetesConfig.ServiceCIDR = DefaultKubernetesServiceCIDRIPv6
}
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6DualStack") {
o.KubernetesConfig.ServiceCIDR = strings.Join([]string{DefaultKubernetesServiceCIDR, DefaultKubernetesServiceCIDRIPv6}, ",")
}
} else {
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6DualStack") {
serviceAddrs := strings.Split(o.KubernetesConfig.ServiceCIDR, ",")
if len(serviceAddrs) == 1 {
ip, _, err := net.ParseCIDR(serviceAddrs[0])
if err == nil {
if ip.To4() != nil {
// the first cidr block is ipv4, so append ipv6
serviceAddrs = append(serviceAddrs, DefaultKubernetesServiceCIDRIPv6)
} else {
// first cidr has to be ipv4
serviceAddrs = append([]string{DefaultKubernetesServiceCIDR}, serviceAddrs...)
}
}
o.KubernetesConfig.ServiceCIDR = strings.Join(serviceAddrs, ",")
}
}
}
if common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.14.0") {
o.KubernetesConfig.CloudProviderBackoffMode = CloudProviderBackoffModeV2
if o.KubernetesConfig.CloudProviderBackoff == nil {
o.KubernetesConfig.CloudProviderBackoff = to.BoolPtr(true)
}
} else {
o.KubernetesConfig.CloudProviderBackoffMode = "v1"
if o.KubernetesConfig.CloudProviderBackoff == nil {
o.KubernetesConfig.CloudProviderBackoff = to.BoolPtr(false)
}
}
// Enforce sane cloudprovider backoff defaults.
a.SetCloudProviderBackoffDefaults()
if o.KubernetesConfig.CloudProviderRateLimit == nil {
o.KubernetesConfig.CloudProviderRateLimit = to.BoolPtr(DefaultKubernetesCloudProviderRateLimit)
}
// Enforce sane cloudprovider rate limit defaults.
a.SetCloudProviderRateLimitDefaults()
if o.KubernetesConfig.PrivateCluster == nil {
o.KubernetesConfig.PrivateCluster = &PrivateCluster{}
}
if o.KubernetesConfig.PrivateCluster.Enabled == nil {
o.KubernetesConfig.PrivateCluster.Enabled = to.BoolPtr(DefaultPrivateClusterEnabled)
}
if o.KubernetesConfig.PrivateCluster.EnableHostsConfigAgent == nil {
o.KubernetesConfig.PrivateCluster.EnableHostsConfigAgent = to.BoolPtr(DefaultPrivateClusterHostsConfigAgentEnabled)
}
if "" == a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB {
switch {
case a.TotalNodes() > 20:
if a.IsAzureStackCloud() {
// Currently on Azure Stack max size of managed disk size is 1023GB.
a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB = MaxAzureStackManagedDiskSize
} else {
a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB = DefaultEtcdDiskSizeGT20Nodes
}
case a.TotalNodes() > 10:
if a.IsAzureStackCloud() {
// Currently on Azure Stack max size of managed disk size is 1023GB.
a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB = MaxAzureStackManagedDiskSize
} else {
a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB = DefaultEtcdDiskSizeGT10Nodes
}
case a.TotalNodes() > 3:
a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB = DefaultEtcdDiskSizeGT3Nodes
default:
a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB = DefaultEtcdDiskSize
}
}
if a.OrchestratorProfile.KubernetesConfig.EtcdStorageLimitGB == 0 {
a.OrchestratorProfile.KubernetesConfig.EtcdStorageLimitGB = DefaultEtcdStorageLimitGB
}
if to.Bool(o.KubernetesConfig.EnableDataEncryptionAtRest) {
if "" == a.OrchestratorProfile.KubernetesConfig.EtcdEncryptionKey {
a.OrchestratorProfile.KubernetesConfig.EtcdEncryptionKey = generateEtcdEncryptionKey()
}
}
if a.OrchestratorProfile.KubernetesConfig.PrivateJumpboxProvision() && a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.OSDiskSizeGB == 0 {
a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.OSDiskSizeGB = DefaultJumpboxDiskSize
}
if a.OrchestratorProfile.KubernetesConfig.PrivateJumpboxProvision() && a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.Username == "" {
a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.Username = DefaultJumpboxUsername
}
if a.OrchestratorProfile.KubernetesConfig.PrivateJumpboxProvision() && a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile == "" {
a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile = ManagedDisks
}
if a.OrchestratorProfile.KubernetesConfig.EnableRbac == nil {
a.OrchestratorProfile.KubernetesConfig.EnableRbac = to.BoolPtr(DefaultRBACEnabled)
}
if a.OrchestratorProfile.KubernetesConfig.MicrosoftAptRepositoryURL == "" {
a.OrchestratorProfile.KubernetesConfig.MicrosoftAptRepositoryURL = DefaultMicrosoftAptRepositoryURL
}
// Upgrade scenario:
// We need to force set EnableRbac to true for upgrades to 1.15.0 and greater if it was previously set to false (AKS Engine only)
if !a.OrchestratorProfile.KubernetesConfig.IsRBACEnabled() && common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.15.0") && isUpgrade {
log.Warnf("RBAC will be enabled during upgrade to version %s\n", o.OrchestratorVersion)
a.OrchestratorProfile.KubernetesConfig.EnableRbac = to.BoolPtr(true)
}
if a.OrchestratorProfile.KubernetesConfig.IsRBACEnabled() {
a.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs = true
} else if isUpdate && a.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs {
// Upgrade scenario:
// We need to force set EnableAggregatedAPIs to false if RBAC was previously disabled
a.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs = false
}
if a.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet == nil {
a.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet = to.BoolPtr(DefaultSecureKubeletEnabled)
}
if a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata == nil {
if a.IsAzureStackCloud() {
a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata = to.BoolPtr(DefaultAzureStackUseInstanceMetadata)
} else {
a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata = to.BoolPtr(DefaultUseInstanceMetadata)
}
}
if a.IsAzureStackCloud() && a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku != DefaultAzureStackLoadBalancerSku {
if a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku != "" {
log.Warnf("apimodel: orchestratorProfile.kubernetesConfig.LoadBalancerSku forced to \"%s\"\n", DefaultAzureStackLoadBalancerSku)
}
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = DefaultAzureStackLoadBalancerSku
} else if a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "" {
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = StandardLoadBalancerSku
}
if strings.EqualFold(a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, BasicLoadBalancerSku) {
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = BasicLoadBalancerSku
} else if strings.EqualFold(a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, StandardLoadBalancerSku) {
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = StandardLoadBalancerSku
}
if a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == StandardLoadBalancerSku && a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB == nil {
a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = to.BoolPtr(DefaultExcludeMasterFromStandardLB)
}
if a.OrchestratorProfile.IsAzureCNI() {
if a.HasWindows() {
a.OrchestratorProfile.KubernetesConfig.AzureCNIVersion = AzureCniPluginVerWindows
} else {
a.OrchestratorProfile.KubernetesConfig.AzureCNIVersion = AzureCniPluginVerLinux
}
}
if a.OrchestratorProfile.KubernetesConfig.MaximumLoadBalancerRuleCount == 0 {
a.OrchestratorProfile.KubernetesConfig.MaximumLoadBalancerRuleCount = DefaultMaximumLoadBalancerRuleCount
}
if a.OrchestratorProfile.KubernetesConfig.ProxyMode == "" {
a.OrchestratorProfile.KubernetesConfig.ProxyMode = DefaultKubeProxyMode
}
if a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == StandardLoadBalancerSku &&
a.OrchestratorProfile.KubernetesConfig.OutboundRuleIdleTimeoutInMinutes == 0 {
a.OrchestratorProfile.KubernetesConfig.OutboundRuleIdleTimeoutInMinutes = DefaultOutboundRuleIdleTimeoutInMinutes
}
if o.KubernetesConfig.LoadBalancerSku == StandardLoadBalancerSku {
if o.KubernetesConfig.CloudProviderDisableOutboundSNAT == nil {
o.KubernetesConfig.CloudProviderDisableOutboundSNAT = to.BoolPtr(false)
}
} else {
// CloudProviderDisableOutboundSNAT is only valid in the context of Standard LB, statically set to false if not Standard LB
o.KubernetesConfig.CloudProviderDisableOutboundSNAT = to.BoolPtr(false)
}
if o.KubernetesConfig.ContainerRuntimeConfig == nil {
o.KubernetesConfig.ContainerRuntimeConfig = make(map[string]string)
}
// Master-specific defaults that depend upon OrchestratorProfile defaults
if cs.Properties.MasterProfile != nil {
if !cs.Properties.MasterProfile.IsCustomVNET() {
if cs.Properties.OrchestratorProfile.IsAzureCNI() {
// When VNET integration is enabled, all masters, agents and pods share the same large subnet.
cs.Properties.MasterProfile.Subnet = o.KubernetesConfig.ClusterSubnet
clusterSubnets := strings.Split(o.KubernetesConfig.ClusterSubnet, ",")
if cs.Properties.IsAzureCNIDualStack() && len(clusterSubnets) > 1 {
cs.Properties.MasterProfile.Subnet = clusterSubnets[0]
}
cs.Properties.MasterProfile.SubnetIPv6 = DefaultKubernetesMasterSubnetIPv6
// FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
if !isUpgrade || len(cs.Properties.MasterProfile.FirstConsecutiveStaticIP) == 0 {
if cs.Properties.MasterProfile.IsVirtualMachineScaleSets() {
cs.Properties.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIPVMSS
cs.Properties.MasterProfile.Subnet = DefaultKubernetesMasterSubnet
cs.Properties.MasterProfile.AgentSubnet = DefaultKubernetesAgentSubnetVMSS
} else {
cs.Properties.MasterProfile.FirstConsecutiveStaticIP = cs.Properties.MasterProfile.GetFirstConsecutiveStaticIPAddress(cs.Properties.MasterProfile.Subnet)
}
}
} else {
cs.Properties.MasterProfile.Subnet = DefaultKubernetesMasterSubnet
cs.Properties.MasterProfile.SubnetIPv6 = DefaultKubernetesMasterSubnetIPv6
// FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
if !isUpgrade || len(cs.Properties.MasterProfile.FirstConsecutiveStaticIP) == 0 {
if cs.Properties.MasterProfile.IsVirtualMachineScaleSets() {
cs.Properties.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIPVMSS
cs.Properties.MasterProfile.AgentSubnet = DefaultKubernetesAgentSubnetVMSS
} else {
cs.Properties.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIP
}
}
}
}
// Distro assignment for masterProfile
if cs.Properties.MasterProfile.ImageRef == nil {
if cs.Properties.MasterProfile.Distro == "" {
cs.Properties.MasterProfile.Distro = AKSUbuntu1804
if cs.Properties.IsAzureStackCloud() {
cs.Properties.MasterProfile.Distro = AKSUbuntu2204
}
} else if isUpgrade || isScale {
if cs.Properties.MasterProfile.Distro == AKSDockerEngine || cs.Properties.MasterProfile.Distro == AKS1604Deprecated {
cs.Properties.MasterProfile.Distro = AKSUbuntu1604
} else if cs.Properties.MasterProfile.Distro == AKS1804Deprecated {
cs.Properties.MasterProfile.Distro = AKSUbuntu1804
}
}
// The AKS Distro is not available in Azure German Cloud.
if cloudSpecConfig.CloudName == AzureGermanCloud {
cs.Properties.MasterProfile.Distro = Ubuntu1804
if cs.Properties.IsAzureStackCloud() {
cs.Properties.MasterProfile.Distro = Ubuntu2204
}
}
}
}
// Pool-specific defaults that depend upon OrchestratorProfile defaults
for _, profile := range cs.Properties.AgentPoolProfiles {
// configure the subnets if not in custom VNET
if cs.Properties.MasterProfile != nil && !cs.Properties.MasterProfile.IsCustomVNET() {
subnetCounter := 0
for _, profile := range cs.Properties.AgentPoolProfiles {
if !cs.Properties.MasterProfile.IsVirtualMachineScaleSets() {
profile.Subnet = cs.Properties.MasterProfile.Subnet
}
subnetCounter++
}
}
// Distro assignment for pools
if profile.OSType != Windows {
if profile.ImageRef == nil {
if profile.Distro == "" {
if profile.OSDiskSizeGB != 0 && profile.OSDiskSizeGB < VHDDiskSizeAKS {
profile.Distro = Ubuntu1804
if cs.Properties.IsAzureStackCloud() {
profile.Distro = Ubuntu2204
}
} else {
profile.Distro = AKSUbuntu1804
if cs.Properties.IsAzureStackCloud() {
profile.Distro = AKSUbuntu2204
}
}
// Ensure deprecated distros are overridden
// Previous versions of aks-engine required the docker-engine distro for N series vms,
// so we need to hard override it in order to produce a working cluster in upgrade/scale contexts.
} else if isUpgrade || isScale {
if profile.Distro == AKSDockerEngine || profile.Distro == AKS1604Deprecated {
profile.Distro = AKSUbuntu1604
} else if profile.Distro == AKS1804Deprecated {
profile.Distro = AKSUbuntu1804
}
}
// The AKS Distro is not available in Azure German Cloud.
if cloudSpecConfig.CloudName == AzureGermanCloud {
profile.Distro = Ubuntu1804
if cs.Properties.IsAzureStackCloud() {
profile.Distro = Ubuntu2204
}
}
}
}
// Ensure that all VMSS pools have SinglePlacementGroup set to false in Standard LB cluster scenarios
if profile.AvailabilityProfile == VirtualMachineScaleSets && profile.SinglePlacementGroup == nil {
if cs.Properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == StandardLoadBalancerSku {
profile.SinglePlacementGroup = to.BoolPtr(false)
} else {
profile.SinglePlacementGroup = to.BoolPtr(DefaultSinglePlacementGroup)
}
}
}
// Configure kubelet
cs.setKubeletConfig(isUpgrade)
// Configure addons
cs.setAddonsConfig(isUpgrade)
// Master-specific defaults that depend upon kubelet defaults
// Set the default number of IP addresses allocated for masters.
if cs.Properties.MasterProfile != nil {
if cs.Properties.MasterProfile.IPAddressCount == 0 {
// Allocate one IP address for the node.
cs.Properties.MasterProfile.IPAddressCount = 1
// Allocate IP addresses for pods if VNET integration is enabled.
if cs.Properties.OrchestratorProfile.IsAzureCNI() {
masterMaxPods, _ := strconv.Atoi(cs.Properties.MasterProfile.KubernetesConfig.KubeletConfig["--max-pods"])
cs.Properties.MasterProfile.IPAddressCount += masterMaxPods
}
}
}
// Pool-specific defaults that depend upon kubelet defaults
for _, profile := range cs.Properties.AgentPoolProfiles {
// Set the default number of IP addresses allocated for agents.
if profile.IPAddressCount == 0 {
// Allocate one IP address for the node.
profile.IPAddressCount = 1
// Allocate IP addresses for pods if VNET integration is enabled.
if cs.Properties.OrchestratorProfile.IsAzureCNI() {
agentPoolMaxPods, _ := strconv.Atoi(profile.KubernetesConfig.KubeletConfig["--max-pods"])
if profile.IsWindows() {
profile.IPAddressCount += agentPoolMaxPods
} else {
profile.IPAddressCount = getPodIPAddressCountForAzureCNI(agentPoolMaxPods, o.KubernetesConfig)
}
}
}
}
// Configure controller-manager
cs.setControllerManagerConfig()
// Configure cloud-controller-manager
cs.setCloudControllerManagerConfig()
// Configure apiserver
cs.setAPIServerConfig()
// Configure scheduler
cs.setSchedulerConfig()
// Configure components
cs.setComponentsConfig(isUpgrade)
// Configure Linux kernel runtime values via sysctl.d
cs.setSysctlDConfig()
}
}