-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathscenario_win_test.go
More file actions
579 lines (547 loc) · 26.7 KB
/
scenario_win_test.go
File metadata and controls
579 lines (547 loc) · 26.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
package e2e
import (
"context"
"fmt"
"testing"
"time"
"github.com/Azure/agentbaker/e2e/components"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/stretchr/testify/require"
"github.com/Azure/agentbaker/e2e/config"
"github.com/Azure/agentbaker/pkg/agent/datamodel"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
func EmptyBootstrapConfigMutator(configuration *datamodel.NodeBootstrappingConfiguration) {}
func EmptyVMConfigMutator(vmss *armcompute.VirtualMachineScaleSet) {}
func DualStackConfigMutator(configuration *datamodel.NodeBootstrappingConfiguration) {
properties := configuration.ContainerService.Properties
properties.FeatureFlags.EnableIPv6DualStack = true
}
func Windows2019BootstrapConfigMutator(t *testing.T, configuration *datamodel.NodeBootstrappingConfiguration) {
// 2019 is not supported in 1.33+
version := components.GetKubeletVersionByMinorVersion("v1.32")
require.NotEmpty(t, version)
configuration.ContainerService.Properties.OrchestratorProfile.OrchestratorVersion = components.RemoveLeadingV(version)
}
func Windows2025BootstrapConfigMutator(t *testing.T, configuration *datamodel.NodeBootstrappingConfiguration) {
// 2025 supported in 1.32+ - a kubelet bug impacts networking in most of 1.32 and 1.33.0, .1
version := components.GetKubeletVersionByMinorVersion("v1.33")
require.NotEmpty(t, version)
configuration.ContainerService.Properties.OrchestratorProfile.OrchestratorVersion = components.RemoveLeadingV(version)
}
func DualStackVMConfigMutator(set *armcompute.VirtualMachineScaleSet) {
ip4Config := set.Properties.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].Properties.IPConfigurations[0]
ip6Config := &armcompute.VirtualMachineScaleSetIPConfiguration{
Name: to.Ptr(fmt.Sprintf("%s_1", *ip4Config.Name)),
Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.Ptr(false),
PrivateIPAddressVersion: to.Ptr(armcompute.IPVersionIPv6),
Subnet: &armcompute.APIEntityReference{
ID: ip4Config.Properties.Subnet.ID,
},
},
}
set.Properties.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].Properties.IPConfigurations = []*armcompute.VirtualMachineScaleSetIPConfiguration{
ip4Config,
ip6Config,
}
}
// WS2019 doesn't support IPv6, so we don't test it with dual-stack.
func Test_Windows2019AzureNetwork(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2019 Azure Network",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2019Containerd,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(configuration *datamodel.NodeBootstrappingConfiguration) {
Windows2019BootstrapConfigMutator(t, configuration)
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2019-containerd")
ValidateWindowsProductName(ctx, s, "Windows Server 2019 Datacenter")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-current.zip")
},
},
})
}
func Test_Windows2022_AzureNetwork(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2022 Azure Network",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022Containerd,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows2022AzureOverlayNetworkDualStack(t *testing.T) {
t.Skip("Dual stack tests are not working yet")
RunScenario(t, &Scenario{
Description: "Windows Server 2022 Azure Overlay Network Dual Stack",
Config: Config{
Cluster: ClusterAzureOverlayNetworkDualStack,
VHD: config.VHDWindows2022Containerd,
VMConfigMutator: DualStackVMConfigMutator,
BootstrapConfigMutator: DualStackConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows2022Gen2AzureNetwork(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2022 with Azure Network - hyperv gen2",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022ContainerdGen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-current.zip")
},
},
})
}
func Test_Windows2022Gen2AzureOverlayNetworkDualStack(t *testing.T) {
t.Skip("Dual stack tests are not working yet")
RunScenario(t, &Scenario{
Description: "Windows Server 2022 with Azure Overlay Network Dual Stack - hyperv gen 2",
Config: Config{
Cluster: ClusterAzureOverlayNetworkDualStack,
VHD: config.VHDWindows2022ContainerdGen2,
VMConfigMutator: DualStackVMConfigMutator,
BootstrapConfigMutator: DualStackConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-current.zip")
},
},
})
}
func Test_Windows23H2AzureNetwork(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 23H2 with Azure Network",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows23H2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "23H2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "23H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows23H2AzureOverlayNetworkDualStack(t *testing.T) {
t.Skip("Dual stack tests are not working yet")
RunScenario(t, &Scenario{
Description: "Windows Server 23H2 with Azure Overlay Network Dual Stack",
Config: Config{
Cluster: ClusterAzureOverlayNetworkDualStack,
VHD: config.VHDWindows23H2,
VMConfigMutator: DualStackVMConfigMutator,
BootstrapConfigMutator: DualStackConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "23H2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "23H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows23H2Gen2AzureNetwork(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 23H2 with Azure Network - hyperv gen2",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows23H2Gen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "23H2-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "23H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-current.zip")
},
},
})
}
func Test_Windows23H2Gen2AzureOverlayDualStack(t *testing.T) {
t.Skip("Dual stack tests are not working yet")
RunScenario(t, &Scenario{
Description: "Windows Server 23H2 with Azure Overlay Network Dual Stack - hyperv gen2",
Config: Config{
Cluster: ClusterAzureOverlayNetworkDualStack,
VHD: config.VHDWindows23H2Gen2,
VMConfigMutator: DualStackVMConfigMutator,
BootstrapConfigMutator: DualStackConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "23H2-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "23H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-current.zip")
},
},
})
}
func Test_Windows23H2Gen2CachingRegression(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows 23H2 VHD built before local cache enabled should still work - overwrite the CSE scripts package URL",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows23H2Gen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.WindowsProfile.CseScriptsPackageURL = "https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-v0.0.52.zip"
// Secure TLS Bootstrapping isn't supported on this CSE script package version
nbc.SecureTLSBootstrappingConfig.Enabled = false
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-v0.0.52.zip")
},
},
})
}
func Test_Windows2022CachingRegression(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows 2022 VHD built before local cache enabled should still work - overwrite the CSE scripts package URL",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022ContainerdGen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.WindowsProfile.CseScriptsPackageURL = "https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-v0.0.52.zip"
// Secure TLS Bootstrapping isn't supported on this CSE script package version
nbc.SecureTLSBootstrappingConfig.Enabled = false
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-v0.0.52.zip")
},
},
})
}
func Test_Windows2019CachingRegression(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows 2019 VHD built before local cache enabled should still work - overwrite the CSE scripts package URL",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2019Containerd,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.WindowsProfile.CseScriptsPackageURL = "https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-v0.0.52.zip"
// Secure TLS Bootstrapping isn't supported on this CSE script package version
nbc.SecureTLSBootstrappingConfig.Enabled = false
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateFileHasContent(ctx, s, "/AzureData/CustomDataSetupScript.log", "CSEScriptsPackageUrl used for provision is https://packages.aks.azure.com/aks/windows/cse/aks-windows-cse-scripts-v0.0.52.zip")
},
},
})
}
func Test_Windows2025(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2025 with Containerd",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2025,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(configuration *datamodel.NodeBootstrappingConfiguration) {
Windows2025BootstrapConfigMutator(t, configuration)
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2025")
ValidateWindowsProductName(ctx, s, "Windows Server 2025 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "24H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows2025Gen2(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2025 with Containerd - hyperv gen 2",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2025Gen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(configuration *datamodel.NodeBootstrappingConfiguration) {
Windows2025BootstrapConfigMutator(t, configuration)
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2025-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2025 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "24H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows2022_SecureTLSBootstrapping_BootstrapToken_Fallback(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2022 with Containerd 2- hyperv gen 2 using secure TLS bootstrapping bootstrap token fallback",
Tags: Tags{
BootstrapTokenFallback: true,
},
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022ContainerdGen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.SecureTLSBootstrappingConfig = &datamodel.SecureTLSBootstrappingConfig{
Enabled: true,
Deadline: (10 * time.Second).String(),
UserAssignedIdentityID: "invalid", // use an unexpected user-assigned identity ID to force a secure TLS bootstrapping failure
}
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows2022_DisableKubeletServingCertificateRotationWithTags(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2022 with Containerd 2- hyperv gen 2 with kubelet serving certificate rotation disabled by VMSS tag",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022ContainerdGen2,
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
if vmss.Tags == nil {
vmss.Tags = map[string]*string{}
}
vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true")
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows2022_VHDCaching(t *testing.T) {
RunScenario(t, &Scenario{
Description: "VHD Caching",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022Containerd, // gen1 is default for windows 2022
VHDCaching: true,
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
// If the VHD has incorrect settings (like network misconfiguration)
// deploying more than one VM may expose the issue.
// This check is not always reliable, since only one VM is created per test run in the current framework.
// Therefore, tests may incorrectly pass more often than they fail in these cases.
vmss.SKU.Capacity = to.Ptr[int64](2)
},
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows2022Gen2_k8s_133(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 2022 with Containerd 2- hyperv gen 2",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022ContainerdGen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(configuration *datamodel.NodeBootstrappingConfiguration) {
// 2025 supported in 1.32+ .
configuration.ContainerService.Properties.OrchestratorProfile.OrchestratorVersion = "1.33.1"
configuration.K8sComponents.WindowsPackageURL = fmt.Sprintf("https://packages.aks.azure.com/kubernetes/v%s/windowszip/v%s-1int.zip", "1.33.1", "1.33.1")
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2022 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "21H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateCiliumIsNotRunningWindows(ctx, s)
},
},
})
}
func Test_Windows23H2_Cilium2(t *testing.T) {
t.Skip("skipping test for Cilium on Windows 23H2, as it is not supported in production AKS yet")
RunScenario(t, &Scenario{
Description: "Windows Server 2022 with Containerd",
Config: Config{
Cluster: ClusterCiliumNetwork,
VHD: config.VHDWindows23H2Gen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(configuration *datamodel.NodeBootstrappingConfiguration) {
// cilium is only supported in 1.30 or greater.
configuration.ContainerService.Properties.OrchestratorProfile.OrchestratorVersion = "1.30.9"
configuration.ContainerService.Properties.OrchestratorProfile.KubernetesConfig.EbpfDataplane = datamodel.EbpfDataplane_cilium
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsRunningWindows(ctx, s)
},
},
})
}
func Test_Windows23H2Gen2_WindowsCiliumNetworking(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Windows Server 23H2 Gen2 with Windows Cilium Networking (WCN) enabled",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows23H2Gen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(configuration *datamodel.NodeBootstrappingConfiguration) {
if configuration.AgentPoolProfile.AgentPoolWindowsProfile == nil {
configuration.AgentPoolProfile.AgentPoolWindowsProfile = &datamodel.AgentPoolWindowsProfile{}
}
configuration.AgentPoolProfile.AgentPoolWindowsProfile.NextGenNetworkingEnabled = to.Ptr(true)
configuration.AgentPoolProfile.AgentPoolWindowsProfile.NextGenNetworkingConfig = to.Ptr("")
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsCiliumIsRunning(ctx, s)
},
},
})
}
func Test_Windows2022_McrChinaCloud_Windows(t *testing.T) {
RunScenario(t, &Scenario{
Tags: Tags{
MockAzureChinaCloud: true,
},
Description: "Windows Server 2022 Azure Network Containerd - v1 to test Azure China Cloud MCR host",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2022Containerd,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
Validator: func(ctx context.Context, s *Scenario) {
ValidateFileExists(ctx, s, `C:\ProgramData\containerd\certs.d\docker.io\hosts.toml`)
ValidateFileExists(ctx, s, `C:\ProgramData\containerd\certs.d\mcr.azk8s.cn\hosts.toml`)
ValidateFileHasContent(ctx, s,
`C:\ProgramData\containerd\certs.d\docker.io\hosts.toml`,
`https://docker.io`)
ValidateFileHasContent(ctx, s,
`C:\ProgramData\containerd\certs.d\mcr.azk8s.cn\hosts.toml`,
`https://mcr.azk8s.cn`)
},
},
})
}
func Test_Windows2025Gen2_McrChinaCloud_Windows(t *testing.T) {
RunScenario(t, &Scenario{
Tags: Tags{
MockAzureChinaCloud: true,
},
Description: "Windows Server 2025 with Containerd - hyperv gen 2 to test Azure China Cloud MCR host",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDWindows2025Gen2,
VMConfigMutator: EmptyVMConfigMutator,
BootstrapConfigMutator: func(configuration *datamodel.NodeBootstrappingConfiguration) {
Windows2025BootstrapConfigMutator(t, configuration)
},
Validator: func(ctx context.Context, s *Scenario) {
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2025-gen2")
ValidateWindowsProductName(ctx, s, "Windows Server 2025 Datacenter")
ValidateWindowsDisplayVersion(ctx, s, "24H2")
ValidateFileHasContent(ctx, s, "/k/kubeletstart.ps1", "--container-runtime=remote")
ValidateWindowsProcessHasCliArguments(ctx, s, "kubelet.exe", []string{"--rotate-certificates=true", "--client-ca-file=c:\\k\\ca.crt"})
ValidateCiliumIsNotRunningWindows(ctx, s)
ValidateFileExists(ctx, s, `C:\ProgramData\containerd\certs.d\docker.io\hosts.toml`)
ValidateFileExists(ctx, s, `C:\ProgramData\containerd\certs.d\mcr.azk8s.cn\hosts.toml`)
ValidateFileHasContent(ctx, s,
`C:\ProgramData\containerd\certs.d\docker.io\hosts.toml`,
`https://docker.io`)
ValidateFileHasContent(ctx, s,
`C:\ProgramData\containerd\certs.d\mcr.azk8s.cn\hosts.toml`,
`https://mcr.azk8s.cn`)
},
},
})
}
func Test_NetworkIsolatedCluster_Windows_WithEgress(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Tests that Windows nodes in network isolated clusters configure containerd to use the bootstrap profile container registry for MCR images",
Tags: Tags{
NetworkIsolated: true,
NonAnonymousACR: true,
},
Config: Config{
Cluster: ClusterAzureBootstrapProfileCache,
VHD: config.VHDWindows2025Gen2,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Enabled: true,
ContainerRegistryServer: fmt.Sprintf("%s.azurecr.io/aks-managed-repository", config.PrivateACRNameNotAnon(config.Config.DefaultLocation)),
},
}
},
Validator: func(ctx context.Context, s *Scenario) {
// Verify mcr.microsoft.com host config exist
ValidateFileExists(ctx, s, `C:\ProgramData\containerd\certs.d\mcr.microsoft.com\hosts.toml`)
ValidateFileDoesNotExist(ctx, s, `C:\ProgramData\containerd\certs.d\mcr.azk8s.cn\hosts.toml`)
},
},
})
}