Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
feat: Windows containerd VHD support (#4137)
Browse files Browse the repository at this point in the history
* Add VHD release notes and ImageConfig for  WS2019 containerd VHD

* Updating logic for selecting default image values based on containerRuntime

* adding reminding to update cmd/upgrade.go to handle containerd windows VHD

* Adding contianerd test casses to TestWindowsProfileDefaults

* adding windows containerd info to cmd/upgrade.go

* DRY'ing up check for image publisher/offer when setting default VHD values for windows

* exporting ImagePublisherAndOfferMatch and using in cmd/upgrade.go logic

* removing hardcoded windows/containerd related values in test/e2e/engine/template.go

* removing hardcoded image ref in test/e2e/test_cluster_configs/containerd.json
  • Loading branch information
marosset committed Apr 12, 2021
1 parent fa12ee3 commit 3445c1b
Show file tree
Hide file tree
Showing 7 changed files with 693 additions and 80 deletions.
7 changes: 5 additions & 2 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,13 @@ func (uc *upgradeCmd) loadCluster() error {
// Use the Windows VHD associated with the aks-engine version if upgradeWindowsVHD is set to "true"
if uc.upgradeWindowsVHD && uc.containerService.Properties.WindowsProfile != nil {
windowsProfile := uc.containerService.Properties.WindowsProfile
if windowsProfile.WindowsPublisher == api.AKSWindowsServer2019OSImageConfig.ImagePublisher && windowsProfile.WindowsOffer == api.AKSWindowsServer2019OSImageConfig.ImageOffer {
if api.ImagePublisherAndOfferMatch(windowsProfile, api.AKSWindowsServer2019ContainerDOSImageConfig) {
windowsProfile.ImageVersion = api.AKSWindowsServer2019ContainerDOSImageConfig.ImageVersion
windowsProfile.WindowsSku = api.AKSWindowsServer2019ContainerDOSImageConfig.ImageSku
} else if api.ImagePublisherAndOfferMatch(windowsProfile, api.AKSWindowsServer2019OSImageConfig) {
windowsProfile.ImageVersion = api.AKSWindowsServer2019OSImageConfig.ImageVersion
windowsProfile.WindowsSku = api.AKSWindowsServer2019OSImageConfig.ImageSku
} else if windowsProfile.WindowsPublisher == api.WindowsServer2019OSImageConfig.ImagePublisher && windowsProfile.WindowsOffer == api.WindowsServer2019OSImageConfig.ImageOffer {
} else if api.ImagePublisherAndOfferMatch(windowsProfile, api.WindowsServer2019OSImageConfig) {
windowsProfile.ImageVersion = api.WindowsServer2019OSImageConfig.ImageVersion
windowsProfile.WindowsSku = api.WindowsServer2019OSImageConfig.ImageSku
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/api/azenvtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,23 @@ var (
ImageVersion: "2021.02.22",
}

// AKSWindowsServer2019OSImageConfig is the AKS image based on Windows Server 2019
// AKSWindowsServer2019OSImageConfig is the aks-engine image based on Windows Server 2019
AKSWindowsServer2019OSImageConfig = AzureOSImageConfig{
ImageOffer: "aks-windows",
ImageSku: "2019-datacenter-core-smalldisk-2103",
ImagePublisher: "microsoft-aks",
ImageVersion: "17763.1817.210317",
}

// AKSWindowsServer2019ContainerDOSImageConfig is the aks-engine image based on Windows Server 2019
// configured with containerd
AKSWindowsServer2019ContainerDOSImageConfig = AzureOSImageConfig{
ImageOffer: "aks-windows",
ImageSku: "2019-datacenter-core-ctrd-2012",
ImagePublisher: "microsoft-aks",
ImageVersion: "17763.1637.201210",
}

// WindowsServer2019OSImageConfig is the 'vanilla' Windows Server 2019 image
WindowsServer2019OSImageConfig = AzureOSImageConfig{
ImageOffer: "WindowsServer",
Expand Down
80 changes: 45 additions & 35 deletions pkg/api/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,11 @@ func (p *Properties) setAgentProfileDefaults(isUpgrade, isScale bool) {
}
}

// ImagePublisherAndOfferMatch returns true if image publisher and offer match for specified WindowsProfile and AzureOSImageConfig objects
func ImagePublisherAndOfferMatch(wp *WindowsProfile, imageConfig AzureOSImageConfig) bool {
return wp.WindowsPublisher == imageConfig.ImagePublisher && wp.WindowsOffer == imageConfig.ImageOffer
}

// setWindowsProfileDefaults sets default WindowsProfile values
func (cs *ContainerService) setWindowsProfileDefaults(isUpgrade, isScale bool) {
cloudSpecConfig := cs.GetCloudSpecConfig()
Expand All @@ -807,46 +812,51 @@ func (cs *ContainerService) setWindowsProfileDefaults(isUpgrade, isScale bool) {
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 windowsProfile.WindowsPublisher == AKSWindowsServer2019OSImageConfig.ImagePublisher && windowsProfile.WindowsOffer == AKSWindowsServer2019OSImageConfig.ImageOffer {
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = AKSWindowsServer2019OSImageConfig.ImageSku
}
if windowsProfile.ImageVersion == "" {
if windowsProfile.WindowsSku == AKSWindowsServer2019OSImageConfig.ImageSku {
windowsProfile.ImageVersion = AKSWindowsServer2019OSImageConfig.ImageVersion
} else {
windowsProfile.ImageVersion = "latest"
}
}
} else if windowsProfile.WindowsPublisher == WindowsServer2019OSImageConfig.ImagePublisher && windowsProfile.WindowsOffer == WindowsServer2019OSImageConfig.ImageOffer {
if ImagePublisherAndOfferMatch(windowsProfile, defaultImageConfig) {
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = WindowsServer2019OSImageConfig.ImageSku
windowsProfile.WindowsSku = defaultImageConfig.ImageSku
}
if windowsProfile.ImageVersion == "" {
if windowsProfile.WindowsSku == WindowsServer2019OSImageConfig.ImageSku {
windowsProfile.ImageVersion = WindowsServer2019OSImageConfig.ImageVersion
if windowsProfile.WindowsSku == defaultImageConfig.ImageSku {
windowsProfile.ImageVersion = defaultImageConfig.ImageVersion
} else {
windowsProfile.ImageVersion = "latest"
}
}
} else {
if windowsProfile.WindowsPublisher == "" {
windowsProfile.WindowsPublisher = AKSWindowsServer2019OSImageConfig.ImagePublisher
windowsProfile.WindowsPublisher = defaultImageConfig.ImagePublisher
}
if windowsProfile.WindowsOffer == "" {
windowsProfile.WindowsOffer = AKSWindowsServer2019OSImageConfig.ImageOffer
windowsProfile.WindowsOffer = defaultImageConfig.ImageOffer
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = AKSWindowsServer2019OSImageConfig.ImageSku
windowsProfile.WindowsSku = defaultImageConfig.ImageSku
}

if windowsProfile.ImageVersion == "" {
// default versions are specific to a publisher/offer/sku
if windowsProfile.WindowsPublisher == AKSWindowsServer2019OSImageConfig.ImagePublisher && windowsProfile.WindowsOffer == AKSWindowsServer2019OSImageConfig.ImageOffer && windowsProfile.WindowsSku == AKSWindowsServer2019OSImageConfig.ImageSku {
windowsProfile.ImageVersion = AKSWindowsServer2019OSImageConfig.ImageVersion
} else {
// 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"
}
}
Expand All @@ -864,19 +874,19 @@ func (cs *ContainerService) setWindowsProfileDefaults(isUpgrade, isScale bool) {

// 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
if windowsProfile.WindowsPublisher == AKSWindowsServer2019OSImageConfig.ImagePublisher && windowsProfile.WindowsOffer == AKSWindowsServer2019OSImageConfig.ImageOffer {
if windowsProfile.ImageVersion == "" {
windowsProfile.ImageVersion = AKSWindowsServer2019OSImageConfig.ImageVersion
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = AKSWindowsServer2019OSImageConfig.ImageSku
}
} else if windowsProfile.WindowsPublisher == WindowsServer2019OSImageConfig.ImagePublisher && windowsProfile.WindowsOffer == WindowsServer2019OSImageConfig.ImageOffer {
if windowsProfile.ImageVersion == "" {
windowsProfile.ImageVersion = WindowsServer2019OSImageConfig.ImageVersion
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = WindowsServer2019OSImageConfig.ImageSku
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
}
}
}
Expand Down
Loading

0 comments on commit 3445c1b

Please sign in to comment.