@@ -60,6 +60,22 @@ func (s *Service) GetDefaultLinuxImage(ctx context.Context, _, k8sVersion string
6060 return nil , errors .Wrapf (err , "unable to parse Kubernetes version \" %s\" " , k8sVersion )
6161 }
6262
63+ // Use the Azure Marketplace for specific older versions, to keep "clusterctl upgrade" from rolling new machines.
64+ marketplaceVersionRange := semver .MustParseRange ("<=1.28.12 || >=1.29.1 <=1.29.7 || >=1.30.0 <=1.30.3" )
65+ if marketplaceVersionRange (v ) {
66+ if version , ok := oldUbuntu2204Versions [v .String ()]; ok {
67+ return & infrav1.Image {
68+ Marketplace : & infrav1.AzureMarketplaceImage {
69+ ImagePlan : infrav1.ImagePlan {
70+ Publisher : "cncf-upstream" ,
71+ Offer : "capi" ,
72+ SKU : "ubuntu-2204-gen1" ,
73+ },
74+ Version : version ,
75+ },
76+ }, nil
77+ }
78+ }
6379 return & infrav1.Image {
6480 ComputeGallery : & infrav1.AzureComputeGalleryImage {
6581 Gallery : azure .DefaultPublicGalleryName ,
@@ -93,6 +109,22 @@ func (s *Service) GetDefaultWindowsImage(ctx context.Context, _, k8sVersion, run
93109 imageName = strings .Replace (imageName , "2019" , match [1 ], 1 )
94110 }
95111
112+ // Use the Azure Marketplace for specific older versions, to keep "clusterctl upgrade" from rolling new machines.
113+ marketplaceVersionRange := semver .MustParseRange ("<=1.28.12 || >=1.29.1 <=1.29.7 || >=1.30.0 <=1.30.3" )
114+ if marketplaceVersionRange (v ) {
115+ if version , ok := oldWindows2019Versions [v .String ()]; ok {
116+ return & infrav1.Image {
117+ Marketplace : & infrav1.AzureMarketplaceImage {
118+ ImagePlan : infrav1.ImagePlan {
119+ Publisher : "cncf-upstream" ,
120+ Offer : "capi-windows" ,
121+ SKU : "windows-2019-containerd-gen1" ,
122+ },
123+ Version : version ,
124+ },
125+ }, nil
126+ }
127+ }
96128 return & infrav1.Image {
97129 ComputeGallery : & infrav1.AzureComputeGalleryImage {
98130 Gallery : azure .DefaultPublicGalleryName ,
@@ -101,3 +133,65 @@ func (s *Service) GetDefaultWindowsImage(ctx context.Context, _, k8sVersion, run
101133 },
102134 }, nil
103135}
136+
137+ // oldUbuntu2204Versions maps Kubernetes versions to Azure Marketplace image versions.
138+ // The Marketplace offer is deprecated and won't be updated, so these values are
139+ // hard-coded here to simplify lookup.
140+ var oldUbuntu2204Versions = map [string ]string {
141+ "1.27.14" : "127.14.20240517" ,
142+ "1.27.15" : "127.15.20240612" ,
143+ "1.27.16" : "127.16.20240717" ,
144+ "1.28.1" : "128.1.20230829" ,
145+ "1.28.2" : "128.2.20230918" ,
146+ "1.28.3" : "128.3.20231023" ,
147+ "1.28.4" : "128.4.20231130" ,
148+ "1.28.5" : "128.5.20240102" ,
149+ "1.28.6" : "128.6.20240201" ,
150+ "1.28.7" : "128.7.20240223" ,
151+ "1.28.8" : "128.8.20240327" ,
152+ "1.28.9" : "128.9.20240418" ,
153+ "1.28.10" : "128.10.20240517" ,
154+ "1.28.11" : "128.11.20240612" ,
155+ "1.28.12" : "128.12.20240717" ,
156+ "1.29.1" : "129.1.20240206" ,
157+ "1.29.2" : "129.2.20240223" ,
158+ "1.29.3" : "129.3.20240327" ,
159+ "1.29.4" : "129.4.20240418" ,
160+ "1.29.5" : "129.5.20240517" ,
161+ "1.29.6" : "129.6.20240612" ,
162+ "1.29.7" : "129.7.20240717" ,
163+ "1.30.0" : "130.0.20240506" ,
164+ "1.30.1" : "130.1.20240517" ,
165+ "1.30.2" : "130.2.20240612" ,
166+ "1.30.3" : "130.3.20240717" ,
167+ }
168+
169+ // oldWindows2019Versions maps Kubernetes versions to Azure Marketplace image versions.
170+ // The Marketplace offer is deprecated and won't be updated, so these values are
171+ // hard-coded here to simplify lookup.
172+ var oldWindows2019Versions = map [string ]string {
173+ "1.27.14" : "127.14.20240515" ,
174+ "1.28.1" : "128.1.20230830" ,
175+ "1.28.2" : "128.2.20230918" ,
176+ "1.28.3" : "128.3.20231023" ,
177+ "1.28.4" : "128.4.20231122" ,
178+ "1.28.5" : "128.5.20240102" ,
179+ "1.28.6" : "128.6.20240201" ,
180+ "1.28.7" : "128.7.20240223" ,
181+ "1.28.8" : "128.8.20240327" ,
182+ "1.28.9" : "128.9.20240418" ,
183+ "1.28.10" : "128.10.20240515" ,
184+ "1.28.11" : "128.11.20240612" ,
185+ "1.28.12" : "128.12.20240717" ,
186+ "1.29.1" : "129.1.20240201" ,
187+ "1.29.2" : "129.2.20240223" ,
188+ "1.29.3" : "129.3.20240327" ,
189+ "1.29.4" : "129.4.20240418" ,
190+ "1.29.5" : "129.5.20240515" ,
191+ "1.29.6" : "129.6.20240612" ,
192+ "1.29.7" : "129.7.20240717" ,
193+ "1.30.0" : "130.0.20240418" ,
194+ "1.30.1" : "130.1.20240515" ,
195+ "1.30.2" : "130.2.20240612" ,
196+ "1.30.3" : "130.3.20240717" ,
197+ }
0 commit comments