Skip to content

Commit 196b9a4

Browse files
authored
Add windows container support in AKS (#11595)
* [AKS] Support creating Windows server container in AKS (#11403) * support using windows container to create AKS * upload to signed AKS sdk * update onlineversion for help of new cmdlets * add missing dll in psd1 * disable test parallelization in Aks.Test * update ContainerService SDK * fix Start-AzAksDashboard and update help files * update to official nuget package for containerservice
1 parent a349712 commit 196b9a4

File tree

83 files changed

+20755
-1212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+20755
-1212
lines changed

src/Aks/Aks.Test/Aks.Test.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<PsModuleName>Aks</PsModuleName>
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="YamlDotNet.Signed" Version="5.2.1" />
15+
<PackageReference Include="Microsoft.Azure.Management.ContainerService" Version="1.0.0" />
1516
</ItemGroup>
1617

1718
<ItemGroup>

src/Aks/Aks.Test/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
4+
using Xunit;
45

56
// General Information about an assembly is controlled through the following
67
// set of attributes. Change these attribute values to modify the information
@@ -34,3 +35,4 @@
3435
// [assembly: AssemblyVersion("1.0.0")]
3536
[assembly: AssemblyVersion("1.0.0")]
3637
[assembly: AssemblyFileVersion("1.0.0")]
38+
[assembly: CollectionBehavior(DisableTestParallelization = true)]

src/Aks/Aks.Test/ScenarioTests/Common.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,22 @@
1414

1515
<#
1616
.SYNOPSIS
17-
Gets container registry name
17+
Gets container service name
1818
#>
1919
function Get-RandomClusterName
2020
{
2121
return 'kube' + (getAssetName)
2222
}
2323

24+
<#
25+
.SYNOPSIS
26+
Gets container registry name
27+
#>
28+
function Get-RandomRegistryName
29+
{
30+
return 'acr' + (getAssetName)
31+
}
32+
2433
<#
2534
.SYNOPSIS
2635
Gets resource group name
@@ -30,7 +39,7 @@ function Get-RandomResourceGroupName
3039
return 'rg' + (getAssetName)
3140
}
3241

33-
function isLive
42+
function IsLive
3443
{
3544
return [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback
3645
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.Azure.Commands.ScenarioTest;
2+
using Microsoft.Azure.ServiceManagement.Common.Models;
3+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
4+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
namespace Commands.Aks.Test.ScenarioTests
9+
{
10+
public class GetAksVersionTests : RMTestBase
11+
{
12+
XunitTracingInterceptor _logger;
13+
public GetAksVersionTests(ITestOutputHelper output)
14+
{
15+
_logger = new XunitTracingInterceptor(output);
16+
XunitTracingInterceptor.AddToContext(_logger);
17+
TestExecutionHelpers.SetUpSessionAndProfile();
18+
}
19+
20+
[Fact]
21+
[Trait(Category.AcceptanceType, Category.CheckIn)]
22+
public void TestAksVersion()
23+
{
24+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAksVersion");
25+
}
26+
}
27+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function Test-GetAksVersion {
2+
3+
$version = Get-AzAksVersion -Location westus
4+
5+
Assert-AreEqual 8 $version.Count
6+
Assert-AreEqual 0 ($version | Where-Object { $_.OrchestratorType -ne 'Kubernetes'}).Count
7+
8+
$chosenVersion = $version | Where-Object { $_.OrchestratorVersion -eq '1.15.7'}
9+
Assert-AreEqual '1.15.7' $chosenVersion.OrchestratorVersion
10+
Assert-AreEqual 2 $chosenVersion.Upgrades.Count
11+
Assert-AreEqual '1.15.10' $chosenVersion.Upgrades[0].OrchestratorVersion
12+
}

src/Aks/Aks.Test/ScenarioTests/KubernetesTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ public KubernetesTests(ITestOutputHelper output)
1717
TestExecutionHelpers.SetUpSessionAndProfile();
1818
}
1919

20+
[Fact]
21+
[Trait(Category.AcceptanceType, Category.CheckIn)]
22+
public void TestSimpleAzureKubernetes()
23+
{
24+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAksSimple");
25+
}
26+
2027
[Fact]
2128
[Trait(Category.AcceptanceType, Category.CheckIn)]
2229
public void TestAzureKubernetes()
2330
{
24-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzureRmKubernetes");
31+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAks");
2532
}
2633
}
2734
}

src/Aks/Aks.Test/ScenarioTests/KubernetesTests.ps1

Lines changed: 128 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,146 @@
22
.SYNOPSIS
33
Test Kubernetes stuff
44
#>
5-
function Test-AzureRmKubernetes
5+
function Test-NewAzAksSimple
66
{
77
# Setup
88
$resourceGroupName = Get-RandomResourceGroupName
99
$kubeClusterName = Get-RandomClusterName
1010
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
11+
$nodeVmSize = "Standard_A2"
1112

1213
try
1314
{
1415
New-AzResourceGroup -Name $resourceGroupName -Location $location
1516

16-
if (isLive) {
17-
$cred = $(createTestCredential "Unicorns" "Puppies")
18-
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -ClientIdAndSecret $cred
19-
} else {
20-
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
21-
}
22-
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
23-
Assert-NotNull $cluster.Fqdn
24-
Assert-NotNull $cluster.DnsPrefix
25-
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
26-
Assert-AreEqual "1.8.1" $cluster.KubernetesVersion
27-
Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count;
28-
$cluster = $cluster | Set-AzAks -NodeCount 2
29-
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].Count;
30-
$cluster | Import-AzAksCredential -Force
31-
$cluster | Remove-AzAks -Force
17+
if (IsLive) {
18+
$cred = $(createTestCredential "Unicorns" "Puppies")
19+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -ClientIdAndSecret $cred
20+
} else {
21+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize
22+
}
23+
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
24+
Assert-NotNull $cluster.Fqdn
25+
Assert-NotNull $cluster.DnsPrefix
26+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
27+
Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count;
28+
$cluster = $cluster | Set-AzAks -NodeCount 2
29+
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].Count;
30+
$cluster | Import-AzAksCredential -Force
31+
$cluster | Remove-AzAks -Force
3232
}
3333
finally
3434
{
3535
Remove-AzResourceGroup -Name $resourceGroupName -Force
3636
}
37-
}
37+
}
38+
39+
function Test-NewAzAksWithAcr
40+
{
41+
# Setup
42+
$resourceGroupName = Get-RandomResourceGroupName
43+
$kubeClusterName = Get-RandomClusterName
44+
$acrName = Get-RandomRegistryName
45+
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
46+
$nodeVmSize = "Standard_A2"
47+
48+
try
49+
{
50+
New-AzResourceGroup -Name $resourceGroupName -Location $location
51+
52+
New-AzContainerRegistry -ResourceGroupName $resourceGroupName -Name $acrName -Sku Standard
53+
54+
if (IsLive) {
55+
$cred = $(createTestCredential "Unicorns" "Puppies")
56+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -ClientIdAndSecret $cred -AcrNameToAttach $acrName
57+
} else {
58+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -AcrNameToAttach $acrName
59+
}
60+
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
61+
Assert-NotNull $cluster.Fqdn
62+
Assert-NotNull $cluster.DnsPrefix
63+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
64+
Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count;
65+
$cluster = $cluster | Set-AzAks -NodeCount 2
66+
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].Count;
67+
$cluster | Import-AzAksCredential -Force
68+
$cluster | Remove-AzAks -Force
69+
}
70+
finally
71+
{
72+
Remove-AzResourceGroup -Name $resourceGroupName -Force
73+
}
74+
}
75+
76+
function Test-NewAzAks
77+
{
78+
# Setup
79+
$resourceGroupName = Get-RandomResourceGroupName
80+
$kubeClusterName = Get-RandomClusterName
81+
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
82+
$kubeVersion = "1.15.7"
83+
$nodeVmSize = "Standard_A2"
84+
$maxPodCount = 25
85+
$nodeName = "defnode"
86+
$nodeCount = 2
87+
$nodeMinCount = 1
88+
$nodeMaxCount = 30
89+
$nodeDiskSize = 100
90+
$nodeVmSetType = "VirtualMachineScaleSets"
91+
$nodeOsType = "Linux"
92+
$enableAutoScaling = $true
93+
$enableRbac = $true
94+
$networkPlugin = "kubenet"
95+
$loadBalancerSku = "Standard"
96+
$linuxAdminUser = "linuxuser"
97+
$dnsNamePrefix = "mypre"
98+
$updatedKubeVersion = "1.15.10"
99+
100+
try
101+
{
102+
New-AzResourceGroup -Name $resourceGroupName -Location $location
103+
104+
if (IsLive) {
105+
$cred = $(createTestCredential "Unicorns" "Puppies")
106+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -ClientIdAndSecret $cred -NetworkPlugin $networkPlugin `
107+
-KubernetesVersion $kubeVersion -EnableRbac -LoadBalancerSku $loadBalancerSku -LinuxProfileAdminUserName $linuxAdminUser -DnsNamePrefix $dnsNamePrefix `
108+
-NodeName $nodeName -NodeOsType $nodeOsType -EnableNodeAutoScaling -NodeCount $nodeCount -NodeOsDiskSize $nodeDiskSize -NodeVmSize $nodeVmSize `
109+
-NodeMaxCount $nodeMaxCount -NodeMinCount $nodeMinCount -NodeMaxPodCount $maxPodCount -NodeSetPriority Regular -NodeScaleSetEvictionPolicy Deallocate -NodeVmSetType VirtualMachineScaleSets
110+
} else {
111+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NetworkPlugin $networkPlugin `
112+
-KubernetesVersion $kubeVersion -EnableRbac -LoadBalancerSku $loadBalancerSku -LinuxProfileAdminUserName $linuxAdminUser -DnsNamePrefix $dnsNamePrefix `
113+
-NodeName $nodeName -NodeOsType $nodeOsType -EnableNodeAutoScaling -NodeCount $nodeCount -NodeOsDiskSize $nodeDiskSize -NodeVmSize $nodeVmSize `
114+
-NodeMaxCount $nodeMaxCount -NodeMinCount $nodeMinCount -NodeMaxPodCount $maxPodCount -NodeSetPriority Regular -NodeScaleSetEvictionPolicy Deallocate -NodeVmSetType VirtualMachineScaleSets
115+
}
116+
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
117+
Assert-NotNull $cluster.Fqdn
118+
Assert-AreEqual $dnsNamePrefix $cluster.DnsPrefix
119+
Assert-AreEqual $kubeVersion $cluster.KubernetesVersion
120+
Assert-AreEqual $enableRbac $cluster.EnableRBAC
121+
Assert-AreEqual $networkPlugin $cluster.NetworkProfile.NetworkPlugin
122+
Assert-AreEqual $loadBalancerSku $cluster.NetworkProfile.LoadBalancerSku
123+
Assert-AreEqual $linuxAdminUser $cluster.LinuxProfile.AdminUsername
124+
Assert-AreEqual $nodeName $cluster.AgentPoolProfiles[0].Name
125+
Assert-AreEqual $nodeVmSize $cluster.AgentPoolProfiles[0].VmSize
126+
Assert-AreEqual $maxPodCount $cluster.AgentPoolProfiles[0].MaxPods
127+
Assert-AreEqual $nodeCount $cluster.AgentPoolProfiles[0].Count
128+
Assert-AreEqual $nodeMinCount $cluster.AgentPoolProfiles[0].MinCount
129+
Assert-AreEqual $nodeMaxCount $cluster.AgentPoolProfiles[0].MaxCount
130+
Assert-AreEqual $nodeDiskSize $cluster.AgentPoolProfiles[0].OsDiskSizeGB
131+
Assert-AreEqual $nodeVmSetType $cluster.AgentPoolProfiles[0].Type
132+
Assert-AreEqual $nodeOsType $cluster.AgentPoolProfiles[0].OsType
133+
Assert-AreEqual $enableAutoScaling $cluster.AgentPoolProfiles[0].EnableAutoScaling
134+
135+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
136+
$cluster = $cluster | Set-AzAks -NodeName $nodeName -NodeMinCount 2 -NodeMaxCount 28 -KubernetesVersion $updatedKubeVersion
137+
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].MinCount
138+
Assert-AreEqual 28 $cluster.AgentPoolProfiles[0].MaxCount;
139+
Assert-AreEqual $updatedKubeVersion $cluster.KubernetesVersion
140+
$cluster | Import-AzAksCredential -Force
141+
$cluster | Remove-AzAks -Force
142+
}
143+
finally
144+
{
145+
Remove-AzResourceGroup -Name $resourceGroupName -Force
146+
}
147+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.Azure.Commands.ScenarioTest;
2+
using Microsoft.Azure.ServiceManagement.Common.Models;
3+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
4+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
namespace Commands.Aks.Test.ScenarioTests
9+
{
10+
public class NodePoolTests : RMTestBase
11+
{
12+
XunitTracingInterceptor _logger;
13+
public NodePoolTests(ITestOutputHelper output)
14+
{
15+
_logger = new XunitTracingInterceptor(output);
16+
XunitTracingInterceptor.AddToContext(_logger);
17+
TestExecutionHelpers.SetUpSessionAndProfile();
18+
}
19+
20+
[Fact]
21+
[Trait(Category.AcceptanceType, Category.CheckIn)]
22+
public void TestAksNodePool()
23+
{
24+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewNodePool");
25+
}
26+
}
27+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
function Test-NewNodePool
3+
{
4+
# Setup
5+
$resourceGroupName = Get-RandomResourceGroupName
6+
$kubeClusterName = Get-RandomClusterName
7+
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
8+
$kubeVersion = "1.15.10"
9+
$nodeVmSize = "Standard_A2"
10+
$nodeVmSetType = "VirtualMachineScaleSets"
11+
$nodeOsType = "Linux"
12+
$networkPlugin = "azure"
13+
$nodeVmSetType = "VirtualMachineScaleSets"
14+
$winAdminUser = "winuser"
15+
$winPassword = ConvertTo-SecureString -AsPlainText "Password!!123" -Force
16+
$winNodeName = "windef"
17+
$winNodeOsType = "Windows"
18+
19+
$poolKubeVersion = "1.15.7"
20+
21+
try
22+
{
23+
New-AzResourceGroup -Name $resourceGroupName -Location $location
24+
25+
#new cluster
26+
if (IsLive) {
27+
$cred = $(createTestCredential "Unicorns" "Puppies")
28+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -ClientIdAndSecret $cred -NetworkPlugin $networkPlugin `
29+
-KubernetesVersion $kubeVersion -NodeVmSetType $nodeVmSetType -WindowsProfileAdminUserName $winAdminUser `
30+
-WindowsProfileAdminUserPassword $winPassword
31+
} else {
32+
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NetworkPlugin $networkPlugin -KubernetesVersion $kubeVersion
33+
}
34+
35+
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
36+
Assert-AreEqual $networkPlugin $cluster.NetworkProfile.NetworkPlugin
37+
Assert-AreEqual $nodeOsType $cluster.AgentPoolProfiles[0].OsType
38+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count
39+
40+
#add new windows cluster
41+
$cluster | New-AzAksNodePool -Name $winNodeName -VmSize $nodeVmSize -OsType $winNodeOsType -VmSetType $nodeVmSetType -KubernetesVersion $poolKubeVersion
42+
43+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
44+
Assert-AreEqual 2 $pools.Count
45+
46+
$winPool = $cluster | Get-AzAksNodePool -Name $winNodeName
47+
Assert-AreEqual $nodeVmSize $winPool.VmSize
48+
Assert-AreEqual $winNodeOsType $winPool.OsType
49+
Assert-AreEqual $nodeVmSetType $winPool.AgentPoolType
50+
Assert-AreEqual $poolKubeVersion $winPool.OrchestratorVersion
51+
52+
$updatedWinPool = $winPool | Update-AzAksNodePool -KubernetesVersion $kubeVersion
53+
Assert-AreEqual $kubeVersion $updatedWinPool.OrchestratorVersion
54+
55+
$updatedWinPool | Remove-AzAksNodePool -Force
56+
$cluster | Remove-AzAks -Force
57+
}
58+
finally
59+
{
60+
Remove-AzResourceGroup -Name $resourceGroupName -Force
61+
}
62+
}

0 commit comments

Comments
 (0)