Skip to content

Commit 0807093

Browse files
authored
[AKS] support GpuInstanceProfile and EnableUptimeSLA (#20531)
* [AKS] support GpuInstanceProfile * [AKS] support EnableUptimeSLA * update help message * update help message in help markdown files
1 parent 813d3f9 commit 0807093

File tree

11 files changed

+6566
-40
lines changed

11 files changed

+6566
-40
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,19 @@ public void TestAutoScalerProfile()
156156
{
157157
TestRunner.RunTestScript("Test-AutoScalerProfile");
158158
}
159+
160+
[Fact]
161+
[Trait(Category.AcceptanceType, Category.CheckIn)]
162+
public void TestGpuInstanceProfile()
163+
{
164+
TestRunner.RunTestScript("Test-GpuInstanceProfile");
165+
}
166+
167+
[Fact]
168+
[Trait(Category.AcceptanceType, Category.CheckIn)]
169+
public void TestEnableUptimeSLA()
170+
{
171+
TestRunner.RunTestScript("Test-EnableUptimeSLA");
172+
}
159173
}
160174
}

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,4 +895,75 @@ function Test-AutoScalerProfile {
895895
finally {
896896
Remove-AzResourceGroup -Name $resourceGroupName -Force
897897
}
898+
}
899+
900+
function Test-GpuInstanceProfile {
901+
# Setup
902+
$resourceGroupName = Get-RandomResourceGroupName
903+
$kubeClusterName = Get-RandomClusterName
904+
$location = 'eastus'
905+
$nodeVmSize = "standard_nc24ads_a100_v4"
906+
907+
try {
908+
New-AzResourceGroup -Name $resourceGroupName -Location $location
909+
910+
# create aks cluster with default nodepool
911+
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -NodeCount 1 -GpuInstanceProfile MIG1g
912+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
913+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count
914+
Assert-AreEqual "MIG1g" $cluster.AgentPoolProfiles[0].GpuInstanceProfile
915+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
916+
Assert-AreEqual 1 $pools.Count
917+
Assert-AreEqual "MIG1g" $pools[0].GpuInstanceProfile
918+
919+
# create a 2nd nodepool
920+
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name pool2 -VmSize $nodeVmSize -Count 1 -GpuInstanceProfile MIG3g
921+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
922+
Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count
923+
Assert-AreEqual "MIG1g" ($cluster.AgentPoolProfiles | where {$_.Name -eq "default"}).GpuInstanceProfile
924+
Assert-AreEqual "MIG3g" ($cluster.AgentPoolProfiles | where {$_.Name -eq "pool2"}).GpuInstanceProfile
925+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
926+
Assert-AreEqual 2 $pools.Count
927+
Assert-AreEqual "MIG1g" ($pools | where {$_.Name -eq "default"}).GpuInstanceProfile
928+
Assert-AreEqual "MIG3g" ($pools | where {$_.Name -eq "pool2"}).GpuInstanceProfile
929+
930+
$cluster | Remove-AzAksCluster -Force
931+
}
932+
finally {
933+
Remove-AzResourceGroup -Name $resourceGroupName -Force
934+
}
935+
}
936+
937+
938+
function Test-EnableUptimeSLA {
939+
# Setup
940+
$resourceGroupName = Get-RandomResourceGroupName
941+
$kubeClusterName = Get-RandomClusterName
942+
$location = 'eastus'
943+
944+
try {
945+
New-AzResourceGroup -Name $resourceGroupName -Location $location
946+
947+
# create aks cluster with default nodepool
948+
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeCount 1 -EnableUptimeSLA
949+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
950+
Assert-AreEqual "Basic" $cluster.Sku.Name
951+
Assert-AreEqual "Paid" $cluster.Sku.Tier
952+
953+
# create a 2nd nodepool
954+
Set-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -EnableUptimeSLA:$false
955+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
956+
Assert-AreEqual "Basic" $cluster.Sku.Name
957+
Assert-AreEqual "Free" $cluster.Sku.Tier
958+
959+
Set-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -EnableUptimeSLA
960+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
961+
Assert-AreEqual "Basic" $cluster.Sku.Name
962+
Assert-AreEqual "Paid" $cluster.Sku.Tier
963+
964+
$cluster | Remove-AzAksCluster -Force
965+
}
966+
finally {
967+
Remove-AzResourceGroup -Name $resourceGroupName -Force
968+
}
898969
}

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

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

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

Lines changed: 3037 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
@@ -27,6 +27,8 @@
2727
* Added parameter `-SpotMaxPrice` for `New-AzAksNodePool`
2828
* Added parameter `-EnableFIPS` for `New-AzAksCluster` and `New-AzAksNodePool`
2929
* Added parameter `-AutoScalerProfile` for `New-AzAksCluster` and `Set-AzAksCluster`
30+
* Added parameter `-GpuInstanceProfile` for `New-AzAksCluster` and `New-AzAksNodePool`
31+
* Added parameter `-EnableUptimeSLA` for `New-AzAksCluster` and `Set-AzAksCluster`
3032

3133
## Version 5.1.0
3234
* Bumped API version to 2022-09-01

src/Aks/Aks/Commands/NewAzureRmAks.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ public class NewAzureRmAks : CreateOrUpdateKubeBase
161161
[Parameter(Mandatory = false, HelpMessage = "The parameters to be applied to the cluster-autoscaler.")]
162162
public ManagedClusterPropertiesAutoScalerProfile AutoScalerProfile { get; set; }
163163

164+
[Parameter(
165+
Mandatory = false,
166+
HelpMessage = "The GpuInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.")]
167+
[PSArgumentCompleter("MIG1g", "MIG2g", "MIG3g", "MIG4g", "MIG7g")]
168+
public string GpuInstanceProfile { get; set; }
169+
170+
[Parameter(Mandatory = false, HelpMessage = "Whether to use use Uptime SLA.")]
171+
public SwitchParameter EnableUptimeSLA { get; set; }
172+
164173
private AcsServicePrincipal acsServicePrincipal;
165174

166175
public override void ExecuteCmdlet()
@@ -397,6 +406,17 @@ private ManagedCluster BuildNewCluster()
397406
{
398407
managedCluster.AutoScalerProfile = AutoScalerProfile;
399408
}
409+
if (this.IsParameterBound(c => c.EnableUptimeSLA))
410+
{
411+
if (EnableUptimeSLA.ToBool())
412+
{
413+
managedCluster.Sku = new ManagedClusterSKU(name: "Basic", tier: "Paid");
414+
}
415+
else
416+
{
417+
managedCluster.Sku = new ManagedClusterSKU(name: "Basic", tier: "Free");
418+
}
419+
}
400420

401421
return managedCluster;
402422
}
@@ -538,7 +558,11 @@ private ManagedClusterAgentPoolProfile GetAgentPoolProfile()
538558
}
539559
if (EnableFIPS.IsPresent)
540560
{
541-
defaultAgentPoolProfile.EnableFIPS = EnableFIPS.ToBool();
561+
defaultAgentPoolProfile.EnableFIPS = EnableFIPS.ToBool();
562+
}
563+
if (this.IsParameterBound(c => c.GpuInstanceProfile))
564+
{
565+
defaultAgentPoolProfile.GpuInstanceProfile = GpuInstanceProfile;
542566
}
543567

544568
defaultAgentPoolProfile.Mode = NodePoolMode;

src/Aks/Aks/Commands/NewAzureRmAksNodePool.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ public class NewAzureRmAksNodePool : NewOrUpdateAgentPoolBase
122122
[Parameter(Mandatory = false, HelpMessage = "Whether to use a FIPS-enabled OS")]
123123
public SwitchParameter EnableFIPS { get; set; }
124124

125+
[Parameter(
126+
Mandatory = false,
127+
HelpMessage = "The GpuInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.")]
128+
[PSArgumentCompleter("MIG1g", "MIG2g", "MIG3g", "MIG4g", "MIG7g")]
129+
public string GpuInstanceProfile { get; set; }
130+
125131
public override void ExecuteCmdlet()
126132
{
127133
base.ExecuteCmdlet();
@@ -271,6 +277,10 @@ private AgentPool GetAgentPool()
271277
{
272278
agentPool.EnableFIPS = EnableFIPS.ToBool();
273279
}
280+
if (this.IsParameterBound(c => c.GpuInstanceProfile))
281+
{
282+
agentPool.GpuInstanceProfile = GpuInstanceProfile;
283+
}
274284

275285
return agentPool;
276286
}

src/Aks/Aks/Commands/SetAzureRmAks.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public class SetAzureRmAks : CreateOrUpdateKubeBase
7777
[Parameter(Mandatory = false, HelpMessage = "The parameters to be applied to the cluster-autoscaler.")]
7878
public ManagedClusterPropertiesAutoScalerProfile AutoScalerProfile { get; set; }
7979

80+
[Parameter(Mandatory = false, HelpMessage = "Whether to use use Uptime SLA.")]
81+
public SwitchParameter EnableUptimeSLA { get; set; }
82+
8083
private ManagedCluster BuildNewCluster()
8184
{
8285
BeforeBuildNewCluster();
@@ -402,6 +405,17 @@ public override void ExecuteCmdlet()
402405
{
403406
cluster.AutoScalerProfile = AutoScalerProfile;
404407
}
408+
if (this.IsParameterBound(c => c.EnableUptimeSLA))
409+
{
410+
if (EnableUptimeSLA.ToBool())
411+
{
412+
cluster.Sku = new ManagedClusterSKU(name: "Basic", tier: "Paid");
413+
}
414+
else
415+
{
416+
cluster.Sku = new ManagedClusterSKU(name: "Basic", tier: "Free");
417+
}
418+
}
405419
SetIdentity(cluster);
406420

407421
var kubeCluster = this.CreateOrUpdate(ResourceGroupName, Name, cluster);
@@ -414,7 +428,6 @@ public override void ExecuteCmdlet()
414428
{
415429
cluster.DisableLocalAccounts = DisableLocalAccount;
416430
}
417-
418431
WriteObject(PSMapper.Instance.Map<PSKubernetesCluster>(kubeCluster));
419432
});
420433
}

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

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ New-AzAksCluster [-NodeVmSetType <String>] [-NodeVnetSubnetID <String>] [-NodeMa
2727
[-AvailabilityZone <String[]>] [-NodeResourceGroup <String>] [-EnableEncryptionAtHost] [-EnableUltraSSD]
2828
[-NodeLinuxOSConfig <LinuxOSConfig>] [-NodeKubeletConfig <KubeletConfig>] [-NodeMaxSurge <String>]
2929
[-PPG <String>] [-EnableFIPS] [-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>]
30-
[-ResourceGroupName] <String> [-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>]
31-
[-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
32-
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
33-
[-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>]
34-
[-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>] [-AcrNameToAttach <String>]
35-
[-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
30+
[-GpuInstanceProfile <String>] [-EnableUptimeSLA] [-ResourceGroupName] <String> [-Name] <String>
31+
[[-ServicePrincipalIdAndSecret] <PSCredential>] [-Location <String>] [-LinuxProfileAdminUserName <String>]
32+
[-DnsNamePrefix <String>] [-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>]
33+
[-NodeMaxCount <Int32>] [-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>]
34+
[-NodeVmSize <String>] [-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>]
35+
[-AcrNameToAttach <String>] [-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
3636
[-LoadBalancerManagedOutboundIpCount <Int32>] [-LoadBalancerOutboundIp <String[]>]
3737
[-LoadBalancerOutboundIpPrefix <String[]>] [-LoadBalancerIdleTimeoutInMinute <Int32>]
3838
[-ApiServerAccessAuthorizedIpRange <String[]>] [-EnableApiServerAccessPrivateCluster]
@@ -484,6 +484,21 @@ Accept pipeline input: False
484484
Accept wildcard characters: False
485485
```
486486
487+
### -EnableUptimeSLA
488+
Whether to use use Uptime SLA.
489+
490+
```yaml
491+
Type: System.Management.Automation.SwitchParameter
492+
Parameter Sets: (All)
493+
Aliases:
494+
495+
Required: False
496+
Position: Named
497+
Default value: None
498+
Accept pipeline input: False
499+
Accept wildcard characters: False
500+
```
501+
487502
### -Force
488503
Create cluster even if it already exists
489504
@@ -529,6 +544,21 @@ Accept pipeline input: False
529544
Accept wildcard characters: False
530545
```
531546
547+
### -GpuInstanceProfile
548+
The GpuInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.
549+
550+
```yaml
551+
Type: System.String
552+
Parameter Sets: (All)
553+
Aliases:
554+
555+
Required: False
556+
Position: Named
557+
Default value: None
558+
Accept pipeline input: False
559+
Accept wildcard characters: False
560+
```
561+
532562
### -HttpProxy
533563
The HTTP proxy server endpoint to use.
534564

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ New-AzAksNodePool -ResourceGroupName <String> -ClusterName <String> -Name <Strin
1919
[-OsSKU <String>] [-EnableNodePublicIp] [-NodePublicIPPrefixID <String>] [-ScaleSetPriority <String>]
2020
[-ScaleSetEvictionPolicy <String>] [-VmSetType <String>] [-AvailabilityZone <String[]>] [-Force]
2121
[-EnableEncryptionAtHost] [-EnableUltraSSD] [-LinuxOSConfig <LinuxOSConfig>] [-KubeletConfig <KubeletConfig>]
22-
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-KubernetesVersion <String>]
23-
[-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>]
24-
[-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
22+
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-GpuInstanceProfile <String>]
23+
[-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>]
24+
[-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
2525
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
2626
[<CommonParameters>]
2727
```
@@ -33,9 +33,9 @@ New-AzAksNodePool -Name <String> -ClusterObject <PSKubernetesCluster> [-Count <I
3333
[-EnableNodePublicIp] [-NodePublicIPPrefixID <String>] [-ScaleSetPriority <String>]
3434
[-ScaleSetEvictionPolicy <String>] [-VmSetType <String>] [-AvailabilityZone <String[]>] [-Force]
3535
[-EnableEncryptionAtHost] [-EnableUltraSSD] [-LinuxOSConfig <LinuxOSConfig>] [-KubeletConfig <KubeletConfig>]
36-
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-KubernetesVersion <String>]
37-
[-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>]
38-
[-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
36+
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-GpuInstanceProfile <String>]
37+
[-KubernetesVersion <String>] [-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>]
38+
[-NodeLabel <Hashtable>] [-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
3939
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
4040
[<CommonParameters>]
4141
```
@@ -267,6 +267,21 @@ Accept pipeline input: False
267267
Accept wildcard characters: False
268268
```
269269
270+
### -GpuInstanceProfile
271+
The GpuInstanceProfile to be used to specify GPU MIG instance profile for supported GPU VM SKU.
272+
273+
```yaml
274+
Type: System.String
275+
Parameter Sets: (All)
276+
Aliases:
277+
278+
Required: False
279+
Position: Named
280+
Default value: None
281+
Accept pipeline input: False
282+
Accept wildcard characters: False
283+
```
284+
270285
### -KubeletConfig
271286
The Kubelet configuration on the agent pool nodes.
272287

0 commit comments

Comments
 (0)