Skip to content

Commit da5fbf3

Browse files
authored
[AKS] support EnableFIPS and AutoScalerProfile (#20521)
* [AKS] support EnableFIPS * [AKS] support AutoScalerProfile
1 parent ccd91a6 commit da5fbf3

File tree

11 files changed

+5668
-32
lines changed

11 files changed

+5668
-32
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,19 @@ public void TestSpot()
142142
{
143143
TestRunner.RunTestScript("Test-Spot");
144144
}
145+
146+
[Fact]
147+
[Trait(Category.AcceptanceType, Category.CheckIn)]
148+
public void TestEnableFIPS()
149+
{
150+
TestRunner.RunTestScript("Test-EnableFIPS");
151+
}
152+
153+
[Fact]
154+
[Trait(Category.AcceptanceType, Category.CheckIn)]
155+
public void TestAutoScalerProfile()
156+
{
157+
TestRunner.RunTestScript("Test-AutoScalerProfile");
158+
}
145159
}
146160
}

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

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,4 +804,95 @@ function Test-Spot {
804804
finally {
805805
Remove-AzResourceGroup -Name $resourceGroupName -Force
806806
}
807+
}
808+
809+
function Test-EnableFIPS {
810+
# Setup
811+
$resourceGroupName = Get-RandomResourceGroupName
812+
$kubeClusterName = Get-RandomClusterName
813+
$location = 'eastus'
814+
$nodeVmSize = "Standard_D2_v2"
815+
816+
try {
817+
New-AzResourceGroup -Name $resourceGroupName -Location $location
818+
819+
# create aks cluster with default nodepool
820+
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -NodeVmSize $nodeVmSize -NodeCount 1 -EnableFIPS
821+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
822+
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Count
823+
Assert-True {$cluster.AgentPoolProfiles[0].EnableFIPS}
824+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
825+
Assert-AreEqual 1 $pools.Count
826+
Assert-True {$pools[0].EnableFIPS}
827+
828+
# create a 2nd nodepool
829+
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name pool2 -VmSize $nodeVmSize -Count 1 -EnableFIPS
830+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
831+
Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count
832+
Assert-True {$cluster.AgentPoolProfiles[0].EnableFIPS}
833+
Assert-True {$cluster.AgentPoolProfiles[1].EnableFIPS}
834+
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
835+
Assert-AreEqual 2 $pools.Count
836+
Assert-True {$pools[0].EnableFIPS}
837+
Assert-True {$pools[1].EnableFIPS}
838+
839+
$cluster | Remove-AzAksCluster -Force
840+
}
841+
finally {
842+
Remove-AzResourceGroup -Name $resourceGroupName -Force
843+
}
844+
}
845+
846+
function Test-AutoScalerProfile {
847+
# Setup
848+
$resourceGroupName = Get-RandomResourceGroupName
849+
$kubeClusterName = Get-RandomClusterName
850+
$location = 'eastus'
851+
$nodeVmSize = "Standard_D2_v2"
852+
853+
try {
854+
New-AzResourceGroup -Name $resourceGroupName -Location $location
855+
856+
# create aks cluster with default nodepool
857+
$aksParameters=@{
858+
ResourceGroupName = $resourceGroupName
859+
Name = $kubeClusterName
860+
NodeVmSize = $nodeVmSize
861+
NodeMinCount = 1
862+
NodeMaxCount = 3
863+
}
864+
$AutoScalerProfile=@{
865+
ScanInterval="30s"
866+
Expander="least-waste"
867+
MaxTotalUnreadyPercentage="50"
868+
NewPodScaleUpDelay="800s"
869+
}
870+
$AutoScalerProfile=[Microsoft.Azure.Management.ContainerService.Models.ManagedClusterPropertiesAutoScalerProfile]$AutoScalerProfile
871+
New-AzAksCluster @aksParameters -EnableNodeAutoScaling -AutoScalerProfile $AutoScalerProfile
872+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
873+
Assert-AreEqual "30s" $cluster.AutoScalerProfile.ScanInterval
874+
Assert-AreEqual "least-waste" $cluster.AutoScalerProfile.Expander
875+
Assert-AreEqual "50" $cluster.AutoScalerProfile.MaxTotalUnreadyPercentage
876+
Assert-AreEqual "800s" $cluster.AutoScalerProfile.NewPodScaleUpDelay
877+
878+
# update aks cluster
879+
$AutoScalerProfile2=@{
880+
ScanInterval="40s"
881+
Expander="most-pods"
882+
MaxTotalUnreadyPercentage="45"
883+
NewPodScaleUpDelay="600s"
884+
}
885+
$AutoScalerProfile2=[Microsoft.Azure.Management.ContainerService.Models.ManagedClusterPropertiesAutoScalerProfile]$AutoScalerProfile2
886+
Set-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -AutoScalerProfile $AutoScalerProfile2
887+
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
888+
Assert-AreEqual "40s" $cluster.AutoScalerProfile.ScanInterval
889+
Assert-AreEqual "most-pods" $cluster.AutoScalerProfile.Expander
890+
Assert-AreEqual "45" $cluster.AutoScalerProfile.MaxTotalUnreadyPercentage
891+
Assert-AreEqual "600s" $cluster.AutoScalerProfile.NewPodScaleUpDelay
892+
893+
$cluster | Remove-AzAksCluster -Force
894+
}
895+
finally {
896+
Remove-AzResourceGroup -Name $resourceGroupName -Force
897+
}
807898
}

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

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

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

Lines changed: 2677 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
@@ -25,6 +25,8 @@
2525
* Added parameter `-NodeMaxSurge` for `New-AzAksCluster`, `-MaxSurge` for `New-AzAksNodePool` and `Update-AzAksNodePool`
2626
* Added parameter `-PPG` for `New-AzAksCluster` and `New-AzAksNodePool`
2727
* Added parameter `-SpotMaxPrice` for `New-AzAksNodePool`
28+
* Added parameter `-EnableFIPS` for `New-AzAksCluster` and `New-AzAksNodePool`
29+
* Added parameter `-AutoScalerProfile` for `New-AzAksCluster` and `Set-AzAksCluster`
2830

2931
## Version 5.1.0
3032
* Bumped API version to 2022-09-01

src/Aks/Aks/Commands/NewAzureRmAks.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public class NewAzureRmAks : CreateOrUpdateKubeBase
140140
[Parameter(Mandatory = false, HelpMessage = "Whether to enable host based OS and data drive")]
141141
public SwitchParameter EnableEncryptionAtHost { get; set; }
142142

143-
[Parameter(Mandatory = false, HelpMessage = "whether to enable UltraSSD")]
143+
[Parameter(Mandatory = false, HelpMessage = "Whether to enable UltraSSD")]
144144
public SwitchParameter EnableUltraSSD { get; set; }
145145

146146
[Parameter(Mandatory = false, HelpMessage = "The OS configuration of Linux agent nodes.")]
@@ -155,6 +155,12 @@ public class NewAzureRmAks : CreateOrUpdateKubeBase
155155
[Parameter(Mandatory = false, HelpMessage = "The ID for Proximity Placement Group.")]
156156
public string PPG { get; set; }
157157

158+
[Parameter(Mandatory = false, HelpMessage = "Whether to use a FIPS-enabled OS.")]
159+
public SwitchParameter EnableFIPS { get; set; }
160+
161+
[Parameter(Mandatory = false, HelpMessage = "The parameters to be applied to the cluster-autoscaler.")]
162+
public ManagedClusterPropertiesAutoScalerProfile AutoScalerProfile { get; set; }
163+
158164
private AcsServicePrincipal acsServicePrincipal;
159165

160166
public override void ExecuteCmdlet()
@@ -387,6 +393,10 @@ private ManagedCluster BuildNewCluster()
387393
//{
388394
// managedCluster.EnablePodSecurityPolicy = EnablePodSecurityPolicy;
389395
//}
396+
if (this.IsParameterBound(c => c.AutoScalerProfile))
397+
{
398+
managedCluster.AutoScalerProfile = AutoScalerProfile;
399+
}
390400

391401
return managedCluster;
392402
}
@@ -526,6 +536,10 @@ private ManagedClusterAgentPoolProfile GetAgentPoolProfile()
526536
{
527537
defaultAgentPoolProfile.ProximityPlacementGroupID = PPG;
528538
}
539+
if (EnableFIPS.IsPresent)
540+
{
541+
defaultAgentPoolProfile.EnableFIPS = EnableFIPS.ToBool();
542+
}
529543

530544
defaultAgentPoolProfile.Mode = NodePoolMode;
531545

src/Aks/Aks/Commands/NewAzureRmAksNodePool.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public class NewAzureRmAksNodePool : NewOrUpdateAgentPoolBase
119119
[Parameter(Mandatory = false, HelpMessage = "The max price (in US Dollars) you are willing to pay for spot instances. Possible values are any decimal value greater than zero or -1 which indicates default price to be up-to on-demand.")]
120120
public double? SpotMaxPrice { get; set; }
121121

122+
[Parameter(Mandatory = false, HelpMessage = "Whether to use a FIPS-enabled OS")]
123+
public SwitchParameter EnableFIPS { get; set; }
124+
122125
public override void ExecuteCmdlet()
123126
{
124127
base.ExecuteCmdlet();
@@ -264,6 +267,10 @@ private AgentPool GetAgentPool()
264267
{
265268
agentPool.SpotMaxPrice = SpotMaxPrice;
266269
}
270+
if (EnableFIPS.IsPresent)
271+
{
272+
agentPool.EnableFIPS = EnableFIPS.ToBool();
273+
}
267274

268275
return agentPool;
269276
}

src/Aks/Aks/Commands/SetAzureRmAks.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public class SetAzureRmAks : CreateOrUpdateKubeBase
7474
[Alias("ResourceId")]
7575
public string Id { get; set; }
7676

77+
[Parameter(Mandatory = false, HelpMessage = "The parameters to be applied to the cluster-autoscaler.")]
78+
public ManagedClusterPropertiesAutoScalerProfile AutoScalerProfile { get; set; }
79+
7780
private ManagedCluster BuildNewCluster()
7881
{
7982
BeforeBuildNewCluster();
@@ -395,6 +398,10 @@ public override void ExecuteCmdlet()
395398
{
396399
cluster.FqdnSubdomain = FqdnSubdomain;
397400
}
401+
if (this.IsParameterBound(c => c.AutoScalerProfile))
402+
{
403+
cluster.AutoScalerProfile = AutoScalerProfile;
404+
}
398405
SetIdentity(cluster);
399406

400407
var kubeCluster = this.CreateOrUpdate(ResourceGroupName, Name, cluster);

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ New-AzAksCluster [-NodeVmSetType <String>] [-NodeVnetSubnetID <String>] [-NodeMa
2626
[-LoadBalancerSku <String>] [-Force] [-GenerateSshKey] [-EnableNodePublicIp] [-NodePublicIPPrefixID <String>]
2727
[-AvailabilityZone <String[]>] [-NodeResourceGroup <String>] [-EnableEncryptionAtHost] [-EnableUltraSSD]
2828
[-NodeLinuxOSConfig <LinuxOSConfig>] [-NodeKubeletConfig <KubeletConfig>] [-NodeMaxSurge <String>]
29-
[-PPG <String>] [-ResourceGroupName] <String> [-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>]
29+
[-PPG <String>] [-EnableFIPS] [-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>]
30+
[-ResourceGroupName] <String> [-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>]
3031
[-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
3132
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
3233
[-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>]
@@ -93,6 +94,19 @@ $kubeletConfig = [Microsoft.Azure.Management.ContainerService.Models.KubeletConf
9394
New-AzAksCluster -ResourceGroupName myResourceGroup -Name myAKSCluster -NodeLinuxOSConfig $linuxOsConfig -NodeKubeletConfig $kubeletConfig
9495
```
9596

97+
### Create an AKS cluster with AutoScalerProfile.
98+
When you create an AKS cluster, you can configure granular details of the cluster autoscaler by changing the default values in the cluster-wide autoscaler profile.
99+
100+
```powershell
101+
$AutoScalerProfile=@{
102+
ScanInterval="30s"
103+
Expander="least-waste"
104+
}
105+
$AutoScalerProfile=[Microsoft.Azure.Management.ContainerService.Models.ManagedClusterPropertiesAutoScalerProfile]$AutoScalerProfile
106+
107+
New-AzAksCluster -ResourceGroupName myResourceGroup -Name myAKSCluster -AutoScalerProfile $AutoScalerProfile
108+
```
109+
96110
## PARAMETERS
97111

98112
### -AcrNameToAttach
@@ -200,6 +214,21 @@ Accept pipeline input: False
200214
Accept wildcard characters: False
201215
```
202216
217+
### -AutoScalerProfile
218+
The parameters to be applied to the cluster-autoscaler.
219+
220+
```yaml
221+
Type: Microsoft.Azure.Management.ContainerService.Models.ManagedClusterPropertiesAutoScalerProfile
222+
Parameter Sets: (All)
223+
Aliases:
224+
225+
Required: False
226+
Position: Named
227+
Default value: None
228+
Accept pipeline input: False
229+
Accept wildcard characters: False
230+
```
231+
203232
### -AutoUpgradeChannel
204233
The upgrade channel for auto upgrade. For more information see https://docs.microsoft.com/azure/aks/upgrade-cluster#set-auto-upgrade-channel.
205234
@@ -365,6 +394,21 @@ Accept pipeline input: False
365394
Accept wildcard characters: False
366395
```
367396
397+
### -EnableFIPS
398+
Whether to use a FIPS-enabled OS
399+
400+
```yaml
401+
Type: System.Management.Automation.SwitchParameter
402+
Parameter Sets: (All)
403+
Aliases:
404+
405+
Required: False
406+
Position: Named
407+
Default value: None
408+
Accept pipeline input: False
409+
Accept wildcard characters: False
410+
```
411+
368412
### -EnableManagedIdentity
369413
Using a managed identity to manage cluster resource group.
370414

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ 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>] [-KubernetesVersion <String>]
22+
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-KubernetesVersion <String>]
2323
[-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>]
2424
[-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
2525
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
@@ -33,7 +33,7 @@ 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>] [-KubernetesVersion <String>]
36+
[-MaxSurge <String>] [-PPG <String>] [-SpotMaxPrice <Double>] [-EnableFIPS] [-KubernetesVersion <String>]
3737
[-MinCount <Int32>] [-MaxCount <Int32>] [-EnableAutoScaling] [-Mode <String>] [-NodeLabel <Hashtable>]
3838
[-Tag <Hashtable>] [-NodeTaint <String[]>] [-AksCustomHeader <Hashtable>]
3939
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
@@ -207,6 +207,21 @@ Accept pipeline input: False
207207
Accept wildcard characters: False
208208
```
209209
210+
### -EnableFIPS
211+
Whether to use a FIPS-enabled OS
212+
213+
```yaml
214+
Type: System.Management.Automation.SwitchParameter
215+
Parameter Sets: (All)
216+
Aliases:
217+
218+
Required: False
219+
Position: Named
220+
Default value: None
221+
Accept pipeline input: False
222+
Accept wildcard characters: False
223+
```
224+
210225
### -EnableNodePublicIp
211226
Whether to enable public IP for nodes.
212227

0 commit comments

Comments
 (0)