Skip to content

Commit 487bfcb

Browse files
azure-pipelines[bot]azure-powershell-botNickcandy
authored
Migrate AksArc from generation to main (#26343)
* Move AksArc to main * Update ChangeLog.md --------- Co-authored-by: azure-powershell-bot <[email protected]> Co-authored-by: NanxiangLiu <[email protected]>
1 parent c575a2d commit 487bfcb

File tree

55 files changed

+607
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+607
-313
lines changed

src/AksArc/AksArc.Autorest/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ directive:
8989
transform: >-
9090
$["operationId"] = "KubernetesVersions_Create"
9191
92+
# Fix fields in Get-KubernetesVersion
93+
- from: swagger-document
94+
where: $.definitions.KubernetesVersionReadiness.properties.osType
95+
transform: >-
96+
delete $.readOnly
97+
- from: swagger-document
98+
where: $.definitions.KubernetesVersionReadiness.properties.ready
99+
transform: >-
100+
delete $.readOnly
101+
- from: swagger-document
102+
where: $.definitions.KubernetesVersionReadiness.properties.errorMessage
103+
transform: >-
104+
delete $.readOnly
105+
92106
# Rename Subjects
93107
- where:
94108
subject: AgentPool

src/AksArc/AksArc.Autorest/build-module.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ if(-not $NotIsolated -and -not $Debugger) {
7575
$binFolder = Join-Path $PSScriptRoot 'bin'
7676
$objFolder = Join-Path $PSScriptRoot 'obj'
7777

78+
$isAzure = [System.Convert]::ToBoolean('true')
79+
7880
if(-not $Debugger) {
7981
Write-Host -ForegroundColor Green 'Cleaning build folders...'
8082
$null = Remove-Item -Recurse -ErrorAction SilentlyContinue -Path $binFolder, $objFolder
@@ -151,7 +153,7 @@ if($NoDocs) {
151153
$null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
152154
}
153155
$null = New-Item -ItemType Directory -Force -Path $docsFolder
154-
$addComplexInterfaceInfo = ![System.Convert]::ToBoolean('true')
156+
$addComplexInterfaceInfo = !$isAzure
155157
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ModuleDescription $moduleDescription -DocsFolder $docsFolder -ExamplesFolder $examplesFolder -ModuleGuid $guid -AddComplexInterfaceInfo:$addComplexInterfaceInfo
156158
}
157159

@@ -186,5 +188,4 @@ if (-not $DisableAfterBuildTasks){
186188
}
187189
}
188190

189-
190-
Write-Host -ForegroundColor Green '-------------Done-------------'
191+
Write-Host -ForegroundColor Green '-------------Done-------------'

src/AksArc/AksArc.Autorest/custom/New-AzAksArcCluster.ps1

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function New-AzAksArcCluster {
8383
# /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}
8484
${VnetId},
8585

86-
[Parameter(Mandatory)]
86+
[Parameter()]
8787
[Microsoft.Azure.PowerShell.Cmdlets.AksArc.Category('Body')]
8888
[System.String]
8989
# IP address of the Kubernetes API server
@@ -418,7 +418,7 @@ function New-AzAksArcCluster {
418418

419419
# Network Validations
420420
# Logical Network
421-
if ($VnetId -match $logicalNetworkArmIDRegex) {
421+
if (($PSBoundParameters.ContainsKey('ControlPlaneIP')) -And ($VnetId -match $logicalNetworkArmIDRegex)) {
422422
$response = Invoke-AzRestMethod -Path "$VnetId/?api-version=2024-01-01" -Method GET
423423
if ($response.StatusCode -eq 200) {
424424
$lnet = ($response.Content | ConvertFrom-Json)
@@ -467,16 +467,38 @@ function New-AzAksArcCluster {
467467
# Configure Agent Pool
468468
$AgentPoolProfile = CreateAgentPoolProfile -EnableAutoScaling:$EnableAutoScaling -MinCount $MinCount -MaxCount $MaxCount -MaxPod $MaxPod -NodeTaint $NodeTaint -NodeLabel $NodeLabel
469469
$null = $PSBoundParameters.Add("AgentPoolProfile", $AgentPoolProfile)
470+
471+
if ($PSBoundParameters.ContainsKey('EnableAzureHybridBenefit')) {
472+
$null = $PSBoundParameters.Remove("EnableAzureHybridBenefit")
473+
}
474+
475+
if ($PSBoundParameters.ContainsKey('NodeTaint')) {
476+
$null = $PSBoundParameters.Remove("NodeTaint")
477+
}
478+
479+
if ($PSBoundParameters.ContainsKey('NodeLabel')) {
480+
$null = $PSBoundParameters.Remove("NodeLabel")
481+
}
482+
483+
if ($PSBoundParameters.ContainsKey('MinCount')) {
484+
$null = $PSBoundParameters.Remove("MinCount")
485+
}
486+
487+
if ($PSBoundParameters.ContainsKey('MaxCount')) {
488+
$null = $PSBoundParameters.Remove("MaxCount")
489+
}
490+
491+
if ($PSBoundParameters.ContainsKey('MaxPod')) {
492+
$null = $PSBoundParameters.Remove("MaxPod")
493+
}
470494

471495
# Create Provisioned Cluster
472496
if ($EnableAzureHybridBenefit) {
473497
$null = $PSBoundParameters.Add("LicenseProfileAzureHybridBenefit", $true)
474498
} else {
475499
$null = $PSBoundParameters.Add("LicenseProfileAzureHybridBenefit", $false)
476500
}
477-
$null = $PSBoundParameters.Remove("EnableAzureHybridBenefit")
478-
$null = $PSBoundParameters.Remove("NodeTaint")
479-
$null = $PSBoundParameters.Remove("NodeLabel")
501+
480502
Az.AksArc.internal\New-AzAksArcCluster @PSBoundParameters
481503
}
482504
}

src/AksArc/AksArc.Autorest/custom/Remove-AzAksArcCluster.ps1

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,20 @@ param(
110110
)
111111

112112
process {
113-
$APIVersion = "2024-01-01"
114-
$null = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$APIVersion" -Method DELETE
115-
116113
# Query status until delete is complete
117114
$stopLoop = $false
118115
do
119116
{
120-
$response = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$APIVersion" -Method GET
121-
122-
if ($response.StatusCode -eq 404) {
123-
$stopLoop = $true
124-
return
117+
try {
118+
$null = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$ConnectedClusterAPIVersion" -Method DELETE
119+
$response = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$ConnectedClusterAPIVersion" -Method GET
120+
if (!$response -or ($response.StatusCode -eq 404)) {
121+
$stopLoop = $true
122+
return
123+
}
124+
}
125+
catch {
126+
Write-Error $_
125127
}
126128

127129
Start-Sleep -Seconds 30

src/AksArc/AksArc.Autorest/custom/Update-AzAksArcCluster.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ process {
309309

310310
if ($ShouldUpdateConnectedCluster) {
311311
UpdateConnectedCluster -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName -AdminGroupObjectID $AdminGroupObjectID
312+
$null = $PSBoundParameters.Remove("AdminGroupObjectID")
312313
}
313314

314315
# Update Default Nodepool

src/AksArc/AksArc.Autorest/custom/helpers/Helpers.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function CreateConnectedCluster {
5353
$EnableAzureRbacStr = "true"
5454
}
5555

56-
$APIVersion = "2024-01-01"
5756
$json =
5857
@"
5958
{
@@ -75,7 +74,7 @@ function CreateConnectedCluster {
7574
}
7675
}
7776
"@
78-
$null = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$APIVersion" -Method PUT -payload $json
77+
$null = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$ConnectedClusterAPIVersion" -Method PUT -payload $json
7978
}
8079

8180
function UpdateConnectedCluster {
@@ -87,9 +86,7 @@ function UpdateConnectedCluster {
8786
[System.String[]] ${AdminGroupObjectID}
8887
)
8988

90-
91-
$APIVersion = "2024-01-01"
92-
$ConnectedClusterResource = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$APIVersion" -Method GET
89+
$ConnectedClusterResource = Invoke-AzRestMethod -Path "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Kubernetes/connectedClusters/$ClusterName/?api-version=$ConnectedClusterAPIVersion" -Method GET
9390

9491
$Location = ($ConnectedClusterResource.Content | ConvertFrom-Json).location
9592
$EnableAzureRbac = ($ConnectedClusterResource.Content | ConvertFrom-Json).properties.aadProfile.enableAzureRBAC
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Connected Cluster API Version to use
2+
$ConnectedClusterAPIVersion = "2024-01-01"

src/AksArc/AksArc.Autorest/exports/New-AzAksArcCluster.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ param(
100100
# /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}
101101
${VnetId},
102102

103-
[Parameter(Mandatory)]
103+
[Parameter()]
104104
[Microsoft.Azure.PowerShell.Cmdlets.AksArc.Category('Body')]
105105
[System.String]
106106
# IP address of the Kubernetes API server

src/AksArc/AksArc.Autorest/exports/ProxyCmdletDefinitions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ param(
21122112
# /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}
21132113
${VnetId},
21142114

2115-
[Parameter(Mandatory)]
2115+
[Parameter()]
21162116
[Microsoft.Azure.PowerShell.Cmdlets.AksArc.Category('Body')]
21172117
[System.String]
21182118
# IP address of the Kubernetes API server

0 commit comments

Comments
 (0)