Skip to content

Commit 21489bc

Browse files
authored
[AKS] support parameter EnableOidcIssuer (#21423)
* [AKS] support parameter EnableOidcIssuer * remove unnecessary test case part
1 parent 6e72c94 commit 21489bc

File tree

8 files changed

+4592
-8
lines changed

8 files changed

+4592
-8
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,12 @@ public void TestPodSubnetID()
198198
{
199199
TestRunner.RunTestScript("Test-PodSubnetID");
200200
}
201+
202+
[Fact]
203+
[Trait(Category.AcceptanceType, Category.CheckIn)]
204+
public void TestEnableOidcIssuer()
205+
{
206+
TestRunner.RunTestScript("Test-EnableOidcIssuer");
207+
}
201208
}
202209
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,4 +1161,36 @@ function Test-PodSubnetID {
11611161
finally {
11621162
Remove-AzResourceGroup -Name $resourceGroupName -Force
11631163
}
1164+
}
1165+
1166+
function Test-EnableOidcIssuer {
1167+
# Setup
1168+
$resourceGroupName = Get-RandomResourceGroupName
1169+
$kubeClusterName1 = Get-RandomClusterName
1170+
$kubeClusterName2 = Get-RandomClusterName
1171+
$location = 'eastus'
1172+
$nodeVmSize = "Standard_D2_v2"
1173+
1174+
try {
1175+
New-AzResourceGroup -Name $resourceGroupName -Location $location
1176+
1177+
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName1 -NodeVmSize $nodeVmSize -NodeCount 1 -EnableOidcIssuer
1178+
$cluster1 = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName1
1179+
Assert-True {$cluster1.OidcIssuerProfile.Enabled}
1180+
Assert-True {$cluster1.OidcIssuerProfile.IssuerURL.StartsWith("https://eastus.oic.prod-aks.azure.com")}
1181+
1182+
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName2 -NodeCount 1
1183+
$cluster2 = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName2
1184+
Assert-False {$cluster2.OidcIssuerProfile.Enabled}
1185+
Assert-Null $cluster2.OidcIssuerProfile.IssuerURL
1186+
1187+
Set-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName2 -EnableOidcIssuer
1188+
$cluster2 = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName2
1189+
Assert-True {$cluster2.OidcIssuerProfile.Enabled}
1190+
Assert-True {$cluster2.OidcIssuerProfile.IssuerURL.StartsWith("https://eastus.oic.prod-aks.azure.com")}
1191+
1192+
}
1193+
finally {
1194+
Remove-AzResourceGroup -Name $resourceGroupName -Force
1195+
}
11641196
}

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

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

src/Aks/Aks/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added parameter `-EnableOidcIssuer` for `New-AzAksCluster` and `Set-AzAksCluster`
2122
* Added parameter `-NodePodSubnetID` for `New-AzAksCluster`, `-PodSubnetID` for `New-AzAksNodePool`
2223

2324
## Version 5.3.2

src/Aks/Aks/Commands/NewAzureRmAks.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ public class NewAzureRmAks : CreateOrUpdateKubeBase
179179
[Parameter(Mandatory = false, HelpMessage = "The ID of the subnet which pods will join when launched.")]
180180
public string NodePodSubnetID { get; set; }
181181

182+
[Parameter(Mandatory = false, HelpMessage = "Whether to enalbe OIDC issuer feature.")]
183+
public SwitchParameter EnableOidcIssuer { get; set; }
184+
182185
private AcsServicePrincipal acsServicePrincipal;
183186

184187
public override void ExecuteCmdlet()
@@ -429,6 +432,11 @@ private ManagedCluster BuildNewCluster()
429432
managedCluster.ExtendedLocation = new ExtendedLocation(name: EdgeZone, type: "EdgeZone");
430433
}
431434

435+
if (EnableOidcIssuer.IsPresent)
436+
{
437+
managedCluster.OidcIssuerProfile = new ManagedClusterOIDCIssuerProfile(enabled: true);
438+
}
439+
432440
return managedCluster;
433441
}
434442

src/Aks/Aks/Commands/SetAzureRmAks.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public class SetAzureRmAks : CreateOrUpdateKubeBase
8080
[Parameter(Mandatory = false, HelpMessage = "Whether to use use Uptime SLA.")]
8181
public SwitchParameter EnableUptimeSLA { get; set; }
8282

83+
[Parameter(Mandatory = false, HelpMessage = "Whether to enalbe OIDC issuer feature.")]
84+
public SwitchParameter EnableOidcIssuer { get; set; }
85+
8386
private ManagedCluster BuildNewCluster()
8487
{
8588
BeforeBuildNewCluster();
@@ -420,6 +423,10 @@ public override void ExecuteCmdlet()
420423
{
421424
cluster.AadProfile = AadProfile;
422425
}
426+
if (EnableOidcIssuer.IsPresent)
427+
{
428+
cluster.OidcIssuerProfile = new ManagedClusterOIDCIssuerProfile(enabled: true);
429+
}
423430
SetIdentity(cluster);
424431

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

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ New-AzAksCluster [-NodeVmSetType <String>] [-NodeVnetSubnetID <String>] [-NodeMa
2828
[-NodeLinuxOSConfig <LinuxOSConfig>] [-NodeKubeletConfig <KubeletConfig>] [-NodeMaxSurge <String>]
2929
[-PPG <String>] [-EnableFIPS] [-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>]
3030
[-GpuInstanceProfile <String>] [-EnableUptimeSLA] [-EdgeZone <String>] [-NodeHostGroupID <String>]
31-
[-NodePodSubnetID <String>] [-ResourceGroupName] <String> [-Name] <String>
31+
[-NodePodSubnetID <String>] [-EnableOidcIssuer] [-ResourceGroupName] <String> [-Name] <String>
3232
[[-ServicePrincipalIdAndSecret] <PSCredential>] [-Location <String>] [-LinuxProfileAdminUserName <String>]
3333
[-DnsNamePrefix <String>] [-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>]
3434
[-NodeMaxCount <Int32>] [-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>]
@@ -501,6 +501,21 @@ Accept pipeline input: False
501501
Accept wildcard characters: False
502502
```
503503
504+
### -EnableOidcIssuer
505+
Whether to enalbe OIDC issuer feature.
506+
507+
```yaml
508+
Type: System.Management.Automation.SwitchParameter
509+
Parameter Sets: (All)
510+
Aliases:
511+
512+
Required: False
513+
Position: Named
514+
Default value: None
515+
Accept pipeline input: False
516+
Accept wildcard characters: False
517+
```
518+
504519
### -EnableRbac
505520
Whether to enable Kubernetes Role-Based Access
506521

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Update or create a managed Kubernetes cluster.
1515
### defaultParameterSet (Default)
1616
```
1717
Set-AzAksCluster [-NodePoolMode <String>] [-AcrNameToDetach <String>] [-NodeImageOnly] [-ControlPlaneOnly]
18-
[-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>] [-EnableUptimeSLA]
18+
[-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>] [-EnableUptimeSLA] [-EnableOidcIssuer]
1919
[-ResourceGroupName] <String> [-Name] <String> [[-ServicePrincipalIdAndSecret] <PSCredential>]
2020
[-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
2121
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
@@ -38,11 +38,11 @@ Set-AzAksCluster [-NodePoolMode <String>] [-AcrNameToDetach <String>] [-NodeImag
3838
```
3939
Set-AzAksCluster -InputObject <PSKubernetesCluster> [-NodePoolMode <String>] [-AcrNameToDetach <String>]
4040
[-NodeImageOnly] [-ControlPlaneOnly] [-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>]
41-
[-EnableUptimeSLA] [-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
42-
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
43-
[-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>]
44-
[-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>] [-AcrNameToAttach <String>]
45-
[-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
41+
[-EnableUptimeSLA] [-EnableOidcIssuer] [-Location <String>] [-LinuxProfileAdminUserName <String>]
42+
[-DnsNamePrefix <String>] [-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>]
43+
[-NodeMaxCount <Int32>] [-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>]
44+
[-NodeVmSize <String>] [-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>]
45+
[-AcrNameToAttach <String>] [-AsJob] [-Tag <Hashtable>] [-LoadBalancerAllocatedOutboundPort <Int32>]
4646
[-LoadBalancerManagedOutboundIpCount <Int32>] [-LoadBalancerOutboundIp <String[]>]
4747
[-LoadBalancerOutboundIpPrefix <String[]>] [-LoadBalancerIdleTimeoutInMinute <Int32>]
4848
[-ApiServerAccessAuthorizedIpRange <String[]>] [-EnableApiServerAccessPrivateCluster]
@@ -59,7 +59,7 @@ Set-AzAksCluster -InputObject <PSKubernetesCluster> [-NodePoolMode <String>] [-A
5959
```
6060
Set-AzAksCluster [-NodePoolMode <String>] [-AcrNameToDetach <String>] [-NodeImageOnly] [-ControlPlaneOnly]
6161
[-Id] <String> [-AutoScalerProfile <ManagedClusterPropertiesAutoScalerProfile>] [-EnableUptimeSLA]
62-
[-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
62+
[-EnableOidcIssuer] [-Location <String>] [-LinuxProfileAdminUserName <String>] [-DnsNamePrefix <String>]
6363
[-KubernetesVersion <String>] [-NodeName <String>] [-NodeMinCount <Int32>] [-NodeMaxCount <Int32>]
6464
[-EnableNodeAutoScaling] [-NodeCount <Int32>] [-NodeOsDiskSize <Int32>] [-NodeVmSize <String>]
6565
[-NodePoolLabel <Hashtable>] [-NodePoolTag <Hashtable>] [-SshKeyValue <String>] [-AcrNameToAttach <String>]
@@ -403,6 +403,21 @@ Accept pipeline input: False
403403
Accept wildcard characters: False
404404
```
405405
406+
### -EnableOidcIssuer
407+
Whether to enalbe OIDC issuer feature.
408+
409+
```yaml
410+
Type: System.Management.Automation.SwitchParameter
411+
Parameter Sets: (All)
412+
Aliases:
413+
414+
Required: False
415+
Position: Named
416+
Default value: None
417+
Accept pipeline input: False
418+
Accept wildcard characters: False
419+
```
420+
406421
### -EnableUptimeSLA
407422
Whether to use use Uptime SLA.
408423

0 commit comments

Comments
 (0)