Skip to content

Commit c283104

Browse files
authored
[AKS] support EnableEncryptionAtHost and EnableUltraSSD (#20405)
* [AKS] support EnableEncryptionAtHost * [AKS] support EnableUltraSSD * update changelog
1 parent d687600 commit c283104

File tree

9 files changed

+5672
-14
lines changed

9 files changed

+5672
-14
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,19 @@ public void TestNodeTaints()
100100
{
101101
TestRunner.RunTestScript("Test-NodeTaints");
102102
}
103+
104+
[Fact]
105+
[Trait(Category.AcceptanceType, Category.CheckIn)]
106+
public void TestEnableEncryptionAtHost()
107+
{
108+
TestRunner.RunTestScript("Test-EnableEncryptionAtHost");
109+
}
110+
111+
[Fact]
112+
[Trait(Category.AcceptanceType, Category.CheckIn)]
113+
public void TestEnableUltraSSD()
114+
{
115+
TestRunner.RunTestScript("Test-EnableUltraSSD");
116+
}
103117
}
104118
}

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,80 @@ function Test-NodeTaints {
537537
finally {
538538
Remove-AzResourceGroup -Name $resourceGroupName -Force
539539
}
540+
}
541+
542+
function Test-EnableEncryptionAtHost {
543+
# Setup
544+
$resourceGroupName = Get-RandomResourceGroupName
545+
$kubeClusterName = Get-RandomClusterName
546+
$location = 'eastus'
547+
# not all vmSize support EnableEncryptionAtHost. For more information, see: https://docs.microsoft.com/azure/aks/enable-host-encryption
548+
$nodeVmSize = "Standard_D2_v5"
549+
550+
try {
551+
New-AzResourceGroup -Name $resourceGroupName -Location $location
552+
553+
# create aks cluster with default nodepool
554+
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -NodeCount 1 -EnableEncryptionAtHost
555+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
556+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count
557+
Assert-True {$cluster.AgentPoolProfiles[0].EnableEncryptionAtHost}
558+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
559+
Assert-AreEqual 1 $pools.Count
560+
Assert-True {$pools[0].EnableEncryptionAtHost}
561+
562+
# create a 2nd nodepool
563+
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name "pool2" -VmSize $nodeVmSize -Count 1 -EnableEncryptionAtHost
564+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
565+
Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count
566+
Assert-True {$cluster.AgentPoolProfiles[0].EnableEncryptionAtHost}
567+
Assert-True {$cluster.AgentPoolProfiles[1].EnableEncryptionAtHost}
568+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
569+
Assert-AreEqual 2 $pools.Count
570+
Assert-True {$pools[0].EnableEncryptionAtHost}
571+
Assert-True {$pools[1].EnableEncryptionAtHost}
572+
573+
$cluster | Remove-AzAksCluster -Force
574+
}
575+
finally {
576+
Remove-AzResourceGroup -Name $resourceGroupName -Force
577+
}
578+
}
579+
580+
function Test-EnableUltraSSD {
581+
# Setup
582+
$resourceGroupName = Get-RandomResourceGroupName
583+
$kubeClusterName = Get-RandomClusterName
584+
$location = 'eastus'
585+
# 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
586+
$nodeVmSize = "Standard_D2_v5"
587+
588+
try {
589+
New-AzResourceGroup -Name $resourceGroupName -Location $location
590+
591+
# create aks cluster with default nodepool
592+
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -NodeCount 1 -AvailabilityZone @(1,2, 3) -EnableUltraSSD
593+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
594+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count
595+
Assert-True {$cluster.AgentPoolProfiles[0].EnableUltraSSD}
596+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
597+
Assert-AreEqual 1 $pools.Count
598+
Assert-True {$pools[0].EnableUltraSSD}
599+
600+
# create a 2nd nodepool
601+
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name pool2 -VmSize $nodeVmSize -Count 1 -AvailabilityZone @(1,2, 3) -EnableUltraSSD
602+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
603+
Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count
604+
Assert-True {$cluster.AgentPoolProfiles[0].EnableUltraSSD}
605+
Assert-True {$cluster.AgentPoolProfiles[1].EnableUltraSSD}
606+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
607+
Assert-AreEqual 2 $pools.Count
608+
Assert-True {$pools[0].EnableUltraSSD}
609+
Assert-True {$pools[1].EnableUltraSSD}
610+
611+
$cluster | Remove-AzAksCluster -Force
612+
}
613+
finally {
614+
Remove-AzResourceGroup -Name $resourceGroupName -Force
615+
}
540616
}

src/Aks/Aks.Test/SessionRecords/Commands.Aks.Test.ScenarioTests.KubernetesTests/TestEnableEncryptionAtHost.json

Lines changed: 2857 additions & 0 deletions
Large diffs are not rendered by default.

src/Aks/Aks.Test/SessionRecords/Commands.Aks.Test.ScenarioTests.KubernetesTests/TestEnableUltraSSD.json

Lines changed: 2620 additions & 0 deletions
Large diffs are not rendered by default.

src/Aks/Aks/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added parameter `-EnableEncryptionAtHost` for `New-AzAksCluster` and `New-AzAksNodePool`
22+
* Added parameter `-EnableUltraSSD` for `New-AzAksCluster` and `New-AzAksNodePool`
2123

2224
## Version 5.1.0
2325
* Bumped API version to 2022-09-01

src/Aks/Aks/Commands/NewAzureRmAks.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ public class NewAzureRmAks : CreateOrUpdateKubeBase
137137
[Parameter(Mandatory = false, HelpMessage = "The resource group containing agent pool.")]
138138
public string NodeResourceGroup { get; set; }
139139

140+
[Parameter(Mandatory = false, HelpMessage = "Whether to enable host based OS and data drive")]
141+
public SwitchParameter EnableEncryptionAtHost { get; set; }
142+
143+
[Parameter(Mandatory = false, HelpMessage = "whether to enable UltraSSD")]
144+
public SwitchParameter EnableUltraSSD { get; set; }
145+
140146
private AcsServicePrincipal acsServicePrincipal;
141147

142148
public override void ExecuteCmdlet()
@@ -484,6 +490,14 @@ private ManagedClusterAgentPoolProfile GetAgentPoolProfile()
484490
{
485491
defaultAgentPoolProfile.AvailabilityZones = AvailabilityZone;
486492
}
493+
if (EnableEncryptionAtHost.IsPresent)
494+
{
495+
defaultAgentPoolProfile.EnableEncryptionAtHost = EnableEncryptionAtHost.ToBool();
496+
}
497+
if (EnableUltraSSD.IsPresent)
498+
{
499+
defaultAgentPoolProfile.EnableUltraSSD = EnableUltraSSD.ToBool();
500+
}
487501

488502
defaultAgentPoolProfile.Mode = NodePoolMode;
489503

src/Aks/Aks/Commands/NewAzureRmAksNodePool.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ public class NewAzureRmAksNodePool : NewOrUpdateAgentPoolBase
9797
[Parameter(Mandatory = false, HelpMessage = "Create node pool even if it already exists")]
9898
public SwitchParameter Force { get; set; }
9999

100+
[Parameter(Mandatory = false, HelpMessage = "Whether to enable host based OS and data drive")]
101+
public SwitchParameter EnableEncryptionAtHost { get; set; }
102+
103+
[Parameter(Mandatory = false, HelpMessage = "whether to enable UltraSSD")]
104+
public SwitchParameter EnableUltraSSD { get; set; }
105+
100106
public override void ExecuteCmdlet()
101107
{
102108
base.ExecuteCmdlet();
@@ -214,6 +220,14 @@ private AgentPool GetAgentPool()
214220
{
215221
agentPool.NodeTaints = NodeTaint;
216222
}
223+
if (EnableEncryptionAtHost.IsPresent)
224+
{
225+
agentPool.EnableEncryptionAtHost = EnableEncryptionAtHost.ToBool();
226+
}
227+
if (EnableUltraSSD.IsPresent)
228+
{
229+
agentPool.EnableUltraSSD = EnableUltraSSD.ToBool();
230+
}
217231

218232
return agentPool;
219233
}

src/Aks/Aks/help/New-AzAksCluster.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ New-AzAksCluster [-NodeVmSetType <String>] [-NodeVnetSubnetID <String>] [-NodeMa
2424
[-WindowsProfileAdminUserPassword <SecureString>] [-NetworkPlugin <String>] [-NetworkPolicy <String>]
2525
[-PodCidr <String>] [-ServiceCidr <String>] [-DnsServiceIP <String>] [-DockerBridgeCidr <String>]
2626
[-LoadBalancerSku <String>] [-Force] [-GenerateSshKey] [-EnableNodePublicIp] [-NodePublicIPPrefixID <String>]
27-
[-AvailabilityZone <String[]>] [-NodeResourceGroup <String>] [-ResourceGroupName] <String> [-Name] <String>
28-
[[-ServicePrincipalIdAndSecret] <PSCredential>] [-Location <String>] [-LinuxProfileAdminUserName <String>]
29-
[-DnsNamePrefix <String>] [-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>]
30-
[-NodeMaxCount <Int32>] [-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>]
31-
[-NodeVmSize <String>] [-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>]
32-
[-AcrNameToAttach <String>] [-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
27+
[-AvailabilityZone <String[]>] [-NodeResourceGroup <String>] [-EnableEncryptionAtHost] [-EnableUltraSSD]
28+
[-ResourceGroupName] <String> [-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>]
29+
[-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
30+
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
31+
[-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>]
32+
[-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>] [-AcrNameToAttach <String>]
33+
[-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
3334
[-LoadBalancerManagedOutboundIpCount <Int32>] [-LoadBalancerOutboundIp <String[]>]
3435
[-LoadBalancerOutboundIpPrefix <String[]>] [-LoadBalancerIdleTimeoutInMinute <Int32>]
3536
[-ApiServerAccessAuthorizedIpRange <String[]>] [-EnableApiServerAccessPrivateCluster]
@@ -320,6 +321,21 @@ Accept pipeline input: False
320321
Accept wildcard characters: False
321322
```
322323
324+
### -EnableEncryptionAtHost
325+
Whether to enable host based OS and data drive
326+
327+
```yaml
328+
Type: System.Management.Automation.SwitchParameter
329+
Parameter Sets: (All)
330+
Aliases:
331+
332+
Required: False
333+
Position: Named
334+
Default value: None
335+
Accept pipeline input: False
336+
Accept wildcard characters: False
337+
```
338+
323339
### -EnableManagedIdentity
324340
Using a managed identity to manage cluster resource group.
325341
@@ -380,6 +396,21 @@ Accept pipeline input: False
380396
Accept wildcard characters: False
381397
```
382398
399+
### -EnableUltraSSD
400+
whether to enable UltraSSD
401+
402+
```yaml
403+
Type: System.Management.Automation.SwitchParameter
404+
Parameter Sets: (All)
405+
Aliases:
406+
407+
Required: False
408+
Position: Named
409+
Default value: None
410+
Accept pipeline input: False
411+
Accept wildcard characters: False
412+
```
413+
383414
### -Force
384415
Create cluster even if it already exists
385416

src/Aks/Aks/help/New-AzAksNodePool.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ New-AzAksNodePool -ResourceGroupName <String> -ClusterName <String> -Name <Strin
1818
[-OsDiskSize <Int32>] [-VmSize <String>] [-VnetSubnetID <String>] [-MaxPodCount <Int32>] [-OsType <String>]
1919
[-OsSKU <String>] [-EnableNodePublicIp] [-NodePublicIPPrefixID <String>] [-ScaleSetPriority <String>]
2020
[-ScaleSetEvictionPolicy <String>] [-VmSetType <String>] [-AvailabilityZone <String[]>] [-Force]
21-
[-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>]
22-
[-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
23-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
24-
[<CommonParameters>]
21+
[-EnableEncryptionAtHost] [-EnableUltraSSD] [-KubernetesVersion <String>] [-MinCount <Int32>]
22+
[-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>] [-Tag <Hashtable>]
23+
[-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
24+
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
2525
```
2626

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

3939
## DESCRIPTION
@@ -160,6 +160,21 @@ Accept pipeline input: False
160160
Accept wildcard characters: False
161161
```
162162
163+
### -EnableEncryptionAtHost
164+
Whether to enable host based OS and data drive
165+
166+
```yaml
167+
Type: System.Management.Automation.SwitchParameter
168+
Parameter Sets: (All)
169+
Aliases:
170+
171+
Required: False
172+
Position: Named
173+
Default value: None
174+
Accept pipeline input: False
175+
Accept wildcard characters: False
176+
```
177+
163178
### -EnableNodePublicIp
164179
Whether to enable public IP for nodes.
165180
@@ -175,6 +190,21 @@ Accept pipeline input: False
175190
Accept wildcard characters: False
176191
```
177192
193+
### -EnableUltraSSD
194+
whether to enable UltraSSD
195+
196+
```yaml
197+
Type: System.Management.Automation.SwitchParameter
198+
Parameter Sets: (All)
199+
Aliases:
200+
201+
Required: False
202+
Position: Named
203+
Default value: None
204+
Accept pipeline input: False
205+
Accept wildcard characters: False
206+
```
207+
178208
### -Force
179209
Create node pool even if it already exists
180210

0 commit comments

Comments
 (0)