Skip to content

Commit

Permalink
[AKS] support EnableEncryptionAtHost and EnableUltraSSD (Azure#20405)
Browse files Browse the repository at this point in the history
* [AKS] support EnableEncryptionAtHost

* [AKS] support EnableUltraSSD

* update changelog
  • Loading branch information
YanaXu authored Dec 9, 2022
1 parent d687600 commit c283104
Show file tree
Hide file tree
Showing 9 changed files with 5,672 additions and 14 deletions.
14 changes: 14 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/KubernetesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,19 @@ public void TestNodeTaints()
{
TestRunner.RunTestScript("Test-NodeTaints");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEnableEncryptionAtHost()
{
TestRunner.RunTestScript("Test-EnableEncryptionAtHost");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEnableUltraSSD()
{
TestRunner.RunTestScript("Test-EnableUltraSSD");
}
}
}
76 changes: 76 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/KubernetesTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -537,4 +537,80 @@ function Test-NodeTaints {
finally {
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}

function Test-EnableEncryptionAtHost {
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$location = 'eastus'
# not all vmSize support EnableEncryptionAtHost. For more information, see: https://docs.microsoft.com/azure/aks/enable-host-encryption
$nodeVmSize = "Standard_D2_v5"

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

# create aks cluster with default nodepool
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -NodeCount 1 -EnableEncryptionAtHost
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count
Assert-True {$cluster.AgentPoolProfiles[0].EnableEncryptionAtHost}
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Assert-AreEqual 1 $pools.Count
Assert-True {$pools[0].EnableEncryptionAtHost}

# create a 2nd nodepool
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name "pool2" -VmSize $nodeVmSize -Count 1 -EnableEncryptionAtHost
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count
Assert-True {$cluster.AgentPoolProfiles[0].EnableEncryptionAtHost}
Assert-True {$cluster.AgentPoolProfiles[1].EnableEncryptionAtHost}
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Assert-AreEqual 2 $pools.Count
Assert-True {$pools[0].EnableEncryptionAtHost}
Assert-True {$pools[1].EnableEncryptionAtHost}

$cluster | Remove-AzAksCluster -Force
}
finally {
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}

function Test-EnableUltraSSD {
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$location = 'eastus'
# not all vmSize support EnableEncryptionAtHost. For more information, see: https://learn.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd?tabs=azure-portal
$nodeVmSize = "Standard_D2_v5"

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

# create aks cluster with default nodepool
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -NodeCount 1 -AvailabilityZone @(1,2, 3) -EnableUltraSSD
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count
Assert-True {$cluster.AgentPoolProfiles[0].EnableUltraSSD}
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Assert-AreEqual 1 $pools.Count
Assert-True {$pools[0].EnableUltraSSD}

# create a 2nd nodepool
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name pool2 -VmSize $nodeVmSize -Count 1 -AvailabilityZone @(1,2, 3) -EnableUltraSSD
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count
Assert-True {$cluster.AgentPoolProfiles[0].EnableUltraSSD}
Assert-True {$cluster.AgentPoolProfiles[1].EnableUltraSSD}
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Assert-AreEqual 2 $pools.Count
Assert-True {$pools[0].EnableUltraSSD}
Assert-True {$pools[1].EnableUltraSSD}

$cluster | Remove-AzAksCluster -Force
}
finally {
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Aks/Aks/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Additional information about change #1
-->
## Upcoming Release
* Added parameter `-EnableEncryptionAtHost` for `New-AzAksCluster` and `New-AzAksNodePool`
* Added parameter `-EnableUltraSSD` for `New-AzAksCluster` and `New-AzAksNodePool`

## Version 5.1.0
* Bumped API version to 2022-09-01
Expand Down
14 changes: 14 additions & 0 deletions src/Aks/Aks/Commands/NewAzureRmAks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ public class NewAzureRmAks : CreateOrUpdateKubeBase
[Parameter(Mandatory = false, HelpMessage = "The resource group containing agent pool.")]
public string NodeResourceGroup { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Whether to enable host based OS and data drive")]
public SwitchParameter EnableEncryptionAtHost { get; set; }

[Parameter(Mandatory = false, HelpMessage = "whether to enable UltraSSD")]
public SwitchParameter EnableUltraSSD { get; set; }

private AcsServicePrincipal acsServicePrincipal;

public override void ExecuteCmdlet()
Expand Down Expand Up @@ -484,6 +490,14 @@ private ManagedClusterAgentPoolProfile GetAgentPoolProfile()
{
defaultAgentPoolProfile.AvailabilityZones = AvailabilityZone;
}
if (EnableEncryptionAtHost.IsPresent)
{
defaultAgentPoolProfile.EnableEncryptionAtHost = EnableEncryptionAtHost.ToBool();
}
if (EnableUltraSSD.IsPresent)
{
defaultAgentPoolProfile.EnableUltraSSD = EnableUltraSSD.ToBool();
}

defaultAgentPoolProfile.Mode = NodePoolMode;

Expand Down
14 changes: 14 additions & 0 deletions src/Aks/Aks/Commands/NewAzureRmAksNodePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public class NewAzureRmAksNodePool : NewOrUpdateAgentPoolBase
[Parameter(Mandatory = false, HelpMessage = "Create node pool even if it already exists")]
public SwitchParameter Force { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Whether to enable host based OS and data drive")]
public SwitchParameter EnableEncryptionAtHost { get; set; }

[Parameter(Mandatory = false, HelpMessage = "whether to enable UltraSSD")]
public SwitchParameter EnableUltraSSD { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand Down Expand Up @@ -214,6 +220,14 @@ private AgentPool GetAgentPool()
{
agentPool.NodeTaints = NodeTaint;
}
if (EnableEncryptionAtHost.IsPresent)
{
agentPool.EnableEncryptionAtHost = EnableEncryptionAtHost.ToBool();
}
if (EnableUltraSSD.IsPresent)
{
agentPool.EnableUltraSSD = EnableUltraSSD.ToBool();
}

return agentPool;
}
Expand Down
43 changes: 37 additions & 6 deletions src/Aks/Aks/help/New-AzAksCluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ New-AzAksCluster [-NodeVmSetType <String>] [-NodeVnetSubnetID <String>] [-NodeMa
[-WindowsProfileAdminUserPassword <SecureString>] [-NetworkPlugin <String>] [-NetworkPolicy <String>]
[-PodCidr <String>] [-ServiceCidr <String>] [-DnsServiceIP <String>] [-DockerBridgeCidr <String>]
[-LoadBalancerSku <String>] [-Force] [-GenerateSshKey] [-EnableNodePublicIp] [-NodePublicIPPrefixID <String>]
[-AvailabilityZone <String[]>] [-NodeResourceGroup <String>] [-ResourceGroupName] <String> [-Name] <String>
[[-ServicePrincipalIdAndSecret] <PSCredential>] [-Location <String>] [-LinuxProfileAdminUserName <String>]
[-DnsNamePrefix <String>] [-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>]
[-NodeMaxCount <Int32>] [-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>]
[-NodeVmSize <String>] [-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>]
[-AcrNameToAttach <String>] [-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
[-AvailabilityZone <String[]>] [-NodeResourceGroup <String>] [-EnableEncryptionAtHost] [-EnableUltraSSD]
[-ResourceGroupName] <String> [-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>]
[-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
[-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>]
[-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>] [-AcrNameToAttach <String>]
[-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
[-LoadBalancerManagedOutboundIpCount <Int32>] [-LoadBalancerOutboundIp <String[]>]
[-LoadBalancerOutboundIpPrefix <String[]>] [-LoadBalancerIdleTimeoutInMinute <Int32>]
[-ApiServerAccessAuthorizedIpRange <String[]>] [-EnableApiServerAccessPrivateCluster]
Expand Down Expand Up @@ -320,6 +321,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableEncryptionAtHost
Whether to enable host based OS and data drive
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableManagedIdentity
Using a managed identity to manage cluster resource group.
Expand Down Expand Up @@ -380,6 +396,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableUltraSSD
whether to enable UltraSSD
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Force
Create cluster even if it already exists
Expand Down
46 changes: 38 additions & 8 deletions src/Aks/Aks/help/New-AzAksNodePool.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ New-AzAksNodePool -ResourceGroupName <String> -ClusterName <String> -Name <Strin
[-OsDiskSize <Int32>] [-VmSize <String>] [-VnetSubnetID <String>] [-MaxPodCount <Int32>] [-OsType <String>]
[-OsSKU <String>] [-EnableNodePublicIp] [-NodePublicIPPrefixID <String>] [-ScaleSetPriority <String>]
[-ScaleSetEvictionPolicy <String>] [-VmSetType <String>] [-AvailabilityZone <String[]>] [-Force]
[-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>]
[-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
[-EnableEncryptionAtHost] [-EnableUltraSSD] [-KubernetesVersion <String>] [-MinCount <Int32>]
[-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>] [-Tag <Hashtable>]
[-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
```

### ParentObjectParameterSet
Expand All @@ -30,10 +30,10 @@ New-AzAksNodePool -Name <String> -ClusterObject <PSKubernetesCluster> [-Count <I
[-VmSize <String>] [-VnetSubnetID <String>] [-MaxPodCount <Int32>] [-OsType <String>] [-OsSKU <String>]
[-EnableNodePublicIp] [-NodePublicIPPrefixID <String>] [-ScaleSetPriority <String>]
[-ScaleSetEvictionPolicy <String>] [-VmSetType <String>] [-AvailabilityZone <String[]>] [-Force]
[-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>]
[-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
[-EnableEncryptionAtHost] [-EnableUltraSSD] [-KubernetesVersion <String>] [-MinCount <Int32>]
[-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>] [-Tag <Hashtable>]
[-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -160,6 +160,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableEncryptionAtHost
Whether to enable host based OS and data drive
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableNodePublicIp
Whether to enable public IP for nodes.
Expand All @@ -175,6 +190,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableUltraSSD
whether to enable UltraSSD
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Force
Create node pool even if it already exists
Expand Down

0 comments on commit c283104

Please sign in to comment.