Skip to content

Commit 29c712d

Browse files
authored
[AKS] Fixed the issue of Enable-AzAksAddon when there are no addons (#21706)
* [AKS] support parameter OutboundType * [AKS] Fixed the issue of Enable-AzAksAddon when there are no addons
1 parent ac5bb1b commit 29c712d

File tree

6 files changed

+5101
-716
lines changed

6 files changed

+5101
-716
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ public void TestAzureKubernetesAddons()
3838
TestRunner.RunTestScript("Test-NewAzAksAddons");
3939
}
4040

41+
[Fact]
42+
[Trait(Category.AcceptanceType, Category.CheckIn)]
43+
public void TestAzureKubernetesAddonsEnableAndDisable()
44+
{
45+
TestRunner.RunTestScript("Test-EnableAndDisableAzAksAddons");
46+
}
47+
4148
[Fact(Skip = "Please make sure you have graph directory.read permission which is required for grant acrpull permission.")]
4249
[Trait(Category.AcceptanceType, Category.CheckIn)]
4350
public void TestNewAzAksWithAcr()

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,42 @@ function Test-NewAzAksAddons
198198
}
199199
}
200200

201+
function Test-EnableAndDisableAzAksAddons
202+
{
203+
# Setup
204+
$resourceGroupName = Get-RandomResourceGroupName
205+
$kubeClusterName = Get-RandomClusterName
206+
$kubeClusterName2 = Get-RandomClusterName
207+
208+
try
209+
{
210+
New-AzResourceGroup -Name $resourceGroupName -Location 'eastus'
211+
212+
$cluster = New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
213+
Assert-Null $cluster.AddonProfiles
214+
215+
$cluster = $cluster | Enable-AzAksAddon -Name HttpApplicationRouting
216+
Assert-AreEqual $true $cluster.AddonProfiles['httpapplicationrouting'].Enabled
217+
$cluster = $cluster | Disable-AzAksAddon -Name HttpApplicationRouting
218+
Assert-AreEqual $false $cluster.AddonProfiles['httpapplicationrouting'].Enabled
219+
220+
$cluster2 = New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName2
221+
Assert-Null $cluster2.AddonProfiles
222+
#$workspace = New-AzOperationalInsightsWorkspace -Location $location -Name 'akstestws' -ResourceGroupName $resourceGroupName
223+
#$workspaceId = $workspace.ResourceId
224+
$workspaceId = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/akstestgroup/providers/Microsoft.OperationalInsights/workspaces/akstestws'
225+
226+
$cluster2 = Enable-AzAksAddon -Name 'Monitoring' -WorkspaceResourceId $workspaceId -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName2
227+
Assert-AreEqual $true $cluster2.AddonProfiles['omsagent'].Enabled
228+
$cluster2 = Disable-AzAksAddon -Name 'Monitoring' -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName2
229+
Assert-AreEqual $false $cluster2.AddonProfiles['omsagent'].Enabled
230+
}
231+
finally
232+
{
233+
Remove-AzResourceGroup -Name $resourceGroupName -Force
234+
}
235+
}
236+
201237

202238
<#
203239
.SYNOPSIS

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

Lines changed: 368 additions & 716 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)