Skip to content

[AKS] Support creating Windows server container in AKS #11403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Aks/Aks.Test/Aks.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>Aks</PsModuleName>
Expand All @@ -12,6 +12,7 @@

<ItemGroup>
<PackageReference Include="YamlDotNet.Signed" Version="5.2.1" />
<PackageReference Include="Microsoft.Azure.Management.ContainerService" Version="1.0.0-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Aks/Aks.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Xunit;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand Down Expand Up @@ -34,3 +35,4 @@
// [assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: CollectionBehavior(DisableTestParallelization = true)]
13 changes: 11 additions & 2 deletions src/Aks/Aks.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@

<#
.SYNOPSIS
Gets container registry name
Gets container service name
#>
function Get-RandomClusterName
{
return 'kube' + (getAssetName)
}

<#
.SYNOPSIS
Gets container registry name
#>
function Get-RandomRegistryName
{
return 'acr' + (getAssetName)
}

<#
.SYNOPSIS
Gets resource group name
Expand All @@ -30,7 +39,7 @@ function Get-RandomResourceGroupName
return 'rg' + (getAssetName)
}

function isLive
function IsLive
{
return [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback
}
Expand Down
27 changes: 27 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/GetAksVersionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Xunit;
using Xunit.Abstractions;

namespace Commands.Aks.Test.ScenarioTests
{
public class GetAksVersionTests : RMTestBase
{
XunitTracingInterceptor _logger;
public GetAksVersionTests(ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAksVersion()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAksVersion");
}
}
}
12 changes: 12 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/GetAksVersionTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function Test-GetAksVersion {

$version = Get-AzAksVersion -Location westus

Assert-AreEqual 8 $version.Count
Assert-AreEqual 0 ($version | Where-Object { $_.OrchestratorType -ne 'Kubernetes'}).Count

$chosenVersion = $version | Where-Object { $_.OrchestratorVersion -eq '1.15.7'}
Assert-AreEqual '1.15.7' $chosenVersion.OrchestratorVersion
Assert-AreEqual 2 $chosenVersion.Upgrades.Count
Assert-AreEqual '1.15.10' $chosenVersion.Upgrades[0].OrchestratorVersion
}
9 changes: 8 additions & 1 deletion src/Aks/Aks.Test/ScenarioTests/KubernetesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ public KubernetesTests(ITestOutputHelper output)
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSimpleAzureKubernetes()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAksSimple");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAzureKubernetes()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzureRmKubernetes");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAks");
}
}
}
146 changes: 128 additions & 18 deletions src/Aks/Aks.Test/ScenarioTests/KubernetesTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,146 @@
.SYNOPSIS
Test Kubernetes stuff
#>
function Test-AzureRmKubernetes
function Test-NewAzAksSimple
{
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
$nodeVmSize = "Standard_A2"

try
{
New-AzResourceGroup -Name $resourceGroupName -Location $location

if (isLive) {
$cred = $(createTestCredential "Unicorns" "Puppies")
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -ClientIdAndSecret $cred
} else {
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
}
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-NotNull $cluster.Fqdn
Assert-NotNull $cluster.DnsPrefix
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
Assert-AreEqual "1.8.1" $cluster.KubernetesVersion
Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count;
$cluster = $cluster | Set-AzAks -NodeCount 2
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].Count;
$cluster | Import-AzAksCredential -Force
$cluster | Remove-AzAks -Force
if (IsLive) {
$cred = $(createTestCredential "Unicorns" "Puppies")
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -ClientIdAndSecret $cred
} else {
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize
}
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-NotNull $cluster.Fqdn
Assert-NotNull $cluster.DnsPrefix
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count;
$cluster = $cluster | Set-AzAks -NodeCount 2
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].Count;
$cluster | Import-AzAksCredential -Force
$cluster | Remove-AzAks -Force
}
finally
{
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}
}

function Test-NewAzAksWithAcr
{
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$acrName = Get-RandomRegistryName
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
$nodeVmSize = "Standard_A2"

try
{
New-AzResourceGroup -Name $resourceGroupName -Location $location

New-AzContainerRegistry -ResourceGroupName $resourceGroupName -Name $acrName -Sku Standard

if (IsLive) {
$cred = $(createTestCredential "Unicorns" "Puppies")
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -ClientIdAndSecret $cred -AcrNameToAttach $acrName
} else {
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -AcrNameToAttach $acrName
}
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-NotNull $cluster.Fqdn
Assert-NotNull $cluster.DnsPrefix
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count;
$cluster = $cluster | Set-AzAks -NodeCount 2
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].Count;
$cluster | Import-AzAksCredential -Force
$cluster | Remove-AzAks -Force
}
finally
{
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}

function Test-NewAzAks
{
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
$kubeVersion = "1.15.7"
$nodeVmSize = "Standard_A2"
$maxPodCount = 25
$nodeName = "defnode"
$nodeCount = 2
$nodeMinCount = 1
$nodeMaxCount = 30
$nodeDiskSize = 100
$nodeVmSetType = "VirtualMachineScaleSets"
$nodeOsType = "Linux"
$enableAutoScaling = $true
$enableRbac = $true
$networkPlugin = "kubenet"
$loadBalancerSku = "Standard"
$linuxAdminUser = "linuxuser"
$dnsNamePrefix = "mypre"
$updatedKubeVersion = "1.15.10"

try
{
New-AzResourceGroup -Name $resourceGroupName -Location $location

if (IsLive) {
$cred = $(createTestCredential "Unicorns" "Puppies")
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -ClientIdAndSecret $cred -NetworkPlugin $networkPlugin `
-KubernetesVersion $kubeVersion -EnableRbac -LoadBalancerSku $loadBalancerSku -LinuxProfileAdminUserName $linuxAdminUser -DnsNamePrefix $dnsNamePrefix `
-NodeName $nodeName -NodeOsType $nodeOsType -EnableNodeAutoScaling -NodeCount $nodeCount -NodeOsDiskSize $nodeDiskSize -NodeVmSize $nodeVmSize `
-NodeMaxCount $nodeMaxCount -NodeMinCount $nodeMinCount -NodeMaxPodCount $maxPodCount -NodeSetPriority Regular -NodeScaleSetEvictionPolicy Deallocate -NodeVmSetType VirtualMachineScaleSets
} else {
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NetworkPlugin $networkPlugin `
-KubernetesVersion $kubeVersion -EnableRbac -LoadBalancerSku $loadBalancerSku -LinuxProfileAdminUserName $linuxAdminUser -DnsNamePrefix $dnsNamePrefix `
-NodeName $nodeName -NodeOsType $nodeOsType -EnableNodeAutoScaling -NodeCount $nodeCount -NodeOsDiskSize $nodeDiskSize -NodeVmSize $nodeVmSize `
-NodeMaxCount $nodeMaxCount -NodeMinCount $nodeMinCount -NodeMaxPodCount $maxPodCount -NodeSetPriority Regular -NodeScaleSetEvictionPolicy Deallocate -NodeVmSetType VirtualMachineScaleSets
}
$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-NotNull $cluster.Fqdn
Assert-AreEqual $dnsNamePrefix $cluster.DnsPrefix
Assert-AreEqual $kubeVersion $cluster.KubernetesVersion
Assert-AreEqual $enableRbac $cluster.EnableRBAC
Assert-AreEqual $networkPlugin $cluster.NetworkProfile.NetworkPlugin
Assert-AreEqual $loadBalancerSku $cluster.NetworkProfile.LoadBalancerSku
Assert-AreEqual $linuxAdminUser $cluster.LinuxProfile.AdminUsername
Assert-AreEqual $nodeName $cluster.AgentPoolProfiles[0].Name
Assert-AreEqual $nodeVmSize $cluster.AgentPoolProfiles[0].VmSize
Assert-AreEqual $maxPodCount $cluster.AgentPoolProfiles[0].MaxPods
Assert-AreEqual $nodeCount $cluster.AgentPoolProfiles[0].Count
Assert-AreEqual $nodeMinCount $cluster.AgentPoolProfiles[0].MinCount
Assert-AreEqual $nodeMaxCount $cluster.AgentPoolProfiles[0].MaxCount
Assert-AreEqual $nodeDiskSize $cluster.AgentPoolProfiles[0].OsDiskSizeGB
Assert-AreEqual $nodeVmSetType $cluster.AgentPoolProfiles[0].Type
Assert-AreEqual $nodeOsType $cluster.AgentPoolProfiles[0].OsType
Assert-AreEqual $enableAutoScaling $cluster.AgentPoolProfiles[0].EnableAutoScaling

Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
$cluster = $cluster | Set-AzAks -NodeName $nodeName -NodeMinCount 2 -NodeMaxCount 28 -KubernetesVersion $updatedKubeVersion
Assert-AreEqual 2 $cluster.AgentPoolProfiles[0].MinCount
Assert-AreEqual 28 $cluster.AgentPoolProfiles[0].MaxCount;
Assert-AreEqual $updatedKubeVersion $cluster.KubernetesVersion
$cluster | Import-AzAksCredential -Force
$cluster | Remove-AzAks -Force
}
finally
{
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}
27 changes: 27 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/NodePoolTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Xunit;
using Xunit.Abstractions;

namespace Commands.Aks.Test.ScenarioTests
{
public class NodePoolTests : RMTestBase
{
XunitTracingInterceptor _logger;
public NodePoolTests(ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAksNodePool()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewNodePool");
}
}
}
62 changes: 62 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/NodePoolTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

function Test-NewNodePool
{
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$location = Get-ProviderLocation "Microsoft.ContainerService/managedClusters"
$kubeVersion = "1.15.10"
$nodeVmSize = "Standard_A2"
$nodeVmSetType = "VirtualMachineScaleSets"
$nodeOsType = "Linux"
$networkPlugin = "azure"
$nodeVmSetType = "VirtualMachineScaleSets"
$winAdminUser = "winuser"
$winPassword = ConvertTo-SecureString -AsPlainText "Password!!123" -Force
$winNodeName = "windef"
$winNodeOsType = "Windows"

$poolKubeVersion = "1.15.7"

try
{
New-AzResourceGroup -Name $resourceGroupName -Location $location

#new cluster
if (IsLive) {
$cred = $(createTestCredential "Unicorns" "Puppies")
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -ClientIdAndSecret $cred -NetworkPlugin $networkPlugin `
-KubernetesVersion $kubeVersion -NodeVmSetType $nodeVmSetType -WindowsProfileAdminUserName $winAdminUser `
-WindowsProfileAdminUserPassword $winPassword
} else {
New-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NetworkPlugin $networkPlugin -KubernetesVersion $kubeVersion
}

$cluster = Get-AzAks -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual $networkPlugin $cluster.NetworkProfile.NetworkPlugin
Assert-AreEqual $nodeOsType $cluster.AgentPoolProfiles[0].OsType
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count

#add new windows cluster
$cluster | New-AzAksNodePool -Name $winNodeName -VmSize $nodeVmSize -OsType $winNodeOsType -VmSetType $nodeVmSetType -KubernetesVersion $poolKubeVersion

$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Assert-AreEqual 2 $pools.Count

$winPool = $cluster | Get-AzAksNodePool -Name $winNodeName
Assert-AreEqual $nodeVmSize $winPool.VmSize
Assert-AreEqual $winNodeOsType $winPool.OsType
Assert-AreEqual $nodeVmSetType $winPool.AgentPoolType
Assert-AreEqual $poolKubeVersion $winPool.OrchestratorVersion

$updatedWinPool = $winPool | Update-AzAksNodePool -KubernetesVersion $kubeVersion
Assert-AreEqual $kubeVersion $updatedWinPool.OrchestratorVersion

$updatedWinPool | Remove-AzAksNodePool -Force
$cluster | Remove-AzAks -Force
}
finally
{
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}
Loading