in pkg/api/defaults.go [831:928]
func (cs *ContainerService) setWindowsProfileDefaults(isUpgrade, isScale bool) {
cloudSpecConfig := cs.GetCloudSpecConfig()
windowsProfile := cs.Properties.WindowsProfile
if !isUpgrade && !isScale {
// Allow non-default values of windowsProfile.ProvisioningScriptsPackageURL to allow for testing of updates to the scripts.
if len(windowsProfile.ProvisioningScriptsPackageURL) == 0 {
windowsProfile.ProvisioningScriptsPackageURL = cloudSpecConfig.KubernetesSpecConfig.WindowsProvisioningScriptsPackageURL
}
if len(windowsProfile.WindowsPauseImageURL) == 0 {
windowsProfile.WindowsPauseImageURL = cloudSpecConfig.KubernetesSpecConfig.WindowsPauseImageURL
}
if windowsProfile.AlwaysPullWindowsPauseImage == nil {
windowsProfile.AlwaysPullWindowsPauseImage = to.BoolPtr(cloudSpecConfig.KubernetesSpecConfig.AlwaysPullWindowsPauseImage)
}
if windowsProfile.SSHEnabled == nil {
windowsProfile.SSHEnabled = to.BoolPtr(DefaultWindowsSSHEnabled)
}
// Default to aks-engine WIndows Server 2019 docker image
defaultImageConfig := AKSWindowsServer2019OSImageConfig
if ImagePublisherAndOfferMatch(windowsProfile, WindowsServer2019OSImageConfig) {
// Use 'vanilla' Windows Server 2019 images
defaultImageConfig = WindowsServer2019OSImageConfig
} else if cs.Properties.OrchestratorProfile.KubernetesConfig.NeedsContainerd() {
// Use to using aks-engine Windows Server 2019 conatinerD VHD
defaultImageConfig = AKSWindowsServer2019ContainerDOSImageConfig
}
// This allows caller to use the latest ImageVersion and WindowsSku for adding a new Windows pool to an existing cluster.
// We must assure that same WindowsPublisher and WindowsOffer are used in an existing cluster.
if ImagePublisherAndOfferMatch(windowsProfile, defaultImageConfig) {
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = defaultImageConfig.ImageSku
}
if windowsProfile.ImageVersion == "" {
if windowsProfile.WindowsSku == defaultImageConfig.ImageSku {
windowsProfile.ImageVersion = defaultImageConfig.ImageVersion
} else {
windowsProfile.ImageVersion = "latest"
}
}
} else {
if windowsProfile.WindowsPublisher == "" {
windowsProfile.WindowsPublisher = defaultImageConfig.ImagePublisher
}
if windowsProfile.WindowsOffer == "" {
windowsProfile.WindowsOffer = defaultImageConfig.ImageOffer
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = defaultImageConfig.ImageSku
}
if windowsProfile.ImageVersion == "" {
// default versions are specific to a publisher/offer/sku for aks-engine VHDs
aksEngineImageConfigs := []AzureOSImageConfig{AKSWindowsServer2019ContainerDOSImageConfig, AKSWindowsServer2019OSImageConfig}
for _, imageConfig := range aksEngineImageConfigs {
if ImagePublisherAndOfferMatch(windowsProfile, imageConfig) && windowsProfile.WindowsSku == imageConfig.ImageSku {
windowsProfile.ImageVersion = imageConfig.ImageVersion
break
}
}
// set imageVersion to 'latest' if still unset
if windowsProfile.ImageVersion == "" {
windowsProfile.ImageVersion = "latest"
}
}
}
} else if isUpgrade {
// Always set windowsProfile.ProvisioningScriptsPackerURL to the default value during upgrade.
// The contents on this package must stay in sync with other powershell code in /parts/k8s and the best way to ensure that is to update the value here.
windowsProfile.ProvisioningScriptsPackageURL = cloudSpecConfig.KubernetesSpecConfig.WindowsProvisioningScriptsPackageURL
if len(windowsProfile.WindowsPauseImageURL) == 0 {
windowsProfile.WindowsPauseImageURL = cloudSpecConfig.KubernetesSpecConfig.WindowsPauseImageURL
}
if windowsProfile.AlwaysPullWindowsPauseImage == nil {
windowsProfile.AlwaysPullWindowsPauseImage = to.BoolPtr(cloudSpecConfig.KubernetesSpecConfig.AlwaysPullWindowsPauseImage)
}
// Image reference publisher and offer only can be set when you create the scale set so we keep the old values.
// Reference: https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-scale-set#create-time-properties
windowsImageConfigs := []AzureOSImageConfig{AKSWindowsServer2019OSImageConfig, WindowsServer2019OSImageConfig}
if cs.Properties.OrchestratorProfile.KubernetesConfig.NeedsContainerd() {
windowsImageConfigs = []AzureOSImageConfig{AKSWindowsServer2019ContainerDOSImageConfig, WindowsServer2019OSImageConfig}
}
for _, imageConfig := range windowsImageConfigs {
if ImagePublisherAndOfferMatch(windowsProfile, imageConfig) {
if windowsProfile.ImageVersion == "" {
windowsProfile.ImageVersion = imageConfig.ImageVersion
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = imageConfig.ImageSku
}
break
}
}
}
// Scale: Keep the same version to match other nodes because we have no way to rollback
}