Skip to content

Commit

Permalink
support for customlocation oid addition (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
parameshbabu authored Jan 26, 2023
1 parent 9e3ca9b commit 6bdd1af
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions tools/aide-userconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"ResourceGroupName": "aksedge-rg",
"ServicePrincipalName": "aksedge-sp",
"Location": "EastUS",
"CustomLocationOID":"",
"Auth": {
"ServicePrincipalId": "",
"Password": ""
Expand Down
14 changes: 5 additions & 9 deletions tools/modules/AksEdgeDeploy/AksEdge-Arc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ function Connect-AideArcServer {
"--tenant-id", "$($aicfg.TenantId)",
"--location", "$($aicfg.Location)",
"--subscription-id", "$($aicfg.SubscriptionId)",
"--cloud", "$($arciotSession.azSession.environmentName)",
#"--cloud", "$($arciotSession.azSession.environmentName)",
"--service-principal-id", "$($creds.Username)",
"--service-principal-secret", "$($creds.Password)"
)
Expand Down Expand Up @@ -833,6 +833,9 @@ function Connect-AideArcKubernetes {
"--infrastructure","TBF"
)
#>
if ($($aicfg.CustomLocationOID)) {
$connectargs += @( "--custom-locations-oid", "$($aicfg.CustomLocationOID)")
}
$tags = @("SKU=AKSEdgeEssentials")
$modVersion = (Get-Module AksEdge).Version
if ($modVersion) { $tags += @("Version=$modVersion") }
Expand Down Expand Up @@ -951,14 +954,7 @@ function Get-AideArcKubernetesServiceToken {
Get-AideArcKubernetesServiceToken
#>
$seraccs = $(kubectl get serviceaccounts)
if (!($seraccs | Where-Object { $_.Contains('aksedge-admin-user') })) {
kubectl create serviceaccount aksedge-admin-user | Write-Host
kubectl create clusterrolebinding aksedge-admin-user --clusterrole cluster-admin --serviceaccount default:aksedge-admin-user | Write-Host
}
$secretname = $(kubectl get serviceaccount aksedge-admin-user -o jsonpath='{$.secrets[0].name}')
$token = $(kubectl get secret ${secretname} -o jsonpath='{$.data.token}')
$servicetoken = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($token))
$servicetoken = Get-AksEdgeManagedServiceToken
$servicetokenfile = "$($arciotSession.WorkspacePath)\servicetoken.txt"
Set-Content -Path $servicetokenfile -Value "$servicetoken"
return $servicetoken
Expand Down
Binary file modified tools/modules/AksEdgeDeploy/AksEdgeDeploy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tools/modules/AksEdgeDeploy/AksEdgeDeploy.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AksEdgeDeploy.psm1'

# Version number of this module.
ModuleVersion = '1.0.230123.1500'
ModuleVersion = '1.0.230124.1100'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
5 changes: 3 additions & 2 deletions tools/modules/AksEdgeDeploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ Find below the details of the supported parameters in the json file.
| ResourceGroupName | Mandatory | String | ResourceGroupName |
| ServicePrincipalName | Mandatory | String | ServicePrincipalName |
| Location | Mandatory | String | Location |
| `Auth`.ServicePrincipalId |Optional | String | Specify service principal appID to use|
| `Auth`.Password |Optional| String | Specify the password (clear) |
| CustomLocationOID | Optional | GUID | ObjectID for the custom location resource provider |
| `Auth`.ServicePrincipalId |Mandatory | GUID | Specify service principal appID to use|
| `Auth`.Password |Mandatory| String | Specify the password (clear) |
</details>
</details>
<details><summary>AksEdgeDeploy Config Visual</summary>
Expand Down
4 changes: 4 additions & 0 deletions tools/modules/AksEdgeDeploy/aide-ucschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
"type": "string",
"description": "ServicePrincipalName to be used for creating service principal to onboard Arc-enabled Server/Kubernetes"
},
"CustomLocationOID":{
"type": "string",
"description": "ObjectID for the custom locations resource provider to be used for creating custom locations "
},
"Auth": {
"type": "object",
"propertires": {
Expand Down
3 changes: 2 additions & 1 deletion tools/modules/AksEdgeDeploy/aide-userconfig.puml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ jsonDiagram {
"ResourceGroupName": "String",
"ServicePrincipalName" : "String",
"Location" : "String",
"CustomLocationOID":"GUID",
"Auth": {
"ServicePrincipalId" : "String",
"ServicePrincipalId" : "GUID",
"Password" : "String"
}
}
Expand Down
4 changes: 3 additions & 1 deletion tools/scripts/AksEdgeAzureSetup/AksEdgeAzureSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Param(
)

#Requires -RunAsAdministrator
New-Variable -Name gAksEdgeAzureSetup -Value "1.0.230109.1600" -Option Constant -ErrorAction SilentlyContinue
New-Variable -Name gAksEdgeAzureSetup -Value "1.0.230124.1100" -Option Constant -ErrorAction SilentlyContinue
New-Variable -Option Constant -ErrorAction SilentlyContinue -Name cliMinVersions -Value @{
"azure-cli" = "2.41.0"
"azure-cli-core" = "2.41.0"
Expand Down Expand Up @@ -345,6 +345,8 @@ if ($savePassword) {
$aicfg | Add-Member -MemberType NoteProperty -Name 'Auth' -Value @{"ServicePrincipalId" = "$($servicePrincipal.appId)"; "Password" = "$($servicePrincipal.password)"} -Force
Write-Host "WARNING: The Service Principal password is stored in clear at $jsonFile" -ForegroundColor Yellow
}
$customLocationRPOID=(az ad sp list --filter "displayname eq 'Custom Locations RP'" --query "[?appDisplayName=='Custom Locations RP'].id" -o tsv)
$jsonContent.Azure | Add-Member -MemberType NoteProperty -Name 'CustomLocationOID' -Value $customLocationRPOID -Force
$jsonContent | ConvertTo-Json | Format-Json | Set-Content -Path "$jsonFile" -Force
az logout
exit 0
1 change: 1 addition & 0 deletions tools/scripts/AksEdgeAzureSetup/AzureConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ResourceGroupName": "arciot-rg",
"ServicePrincipalName" : "arciot-sp",
"Location" : "EastUS",
"CustomLocationOID":"",
"Auth": {
"ServicePrincipalId" : "",
"Password" : ""
Expand Down

0 comments on commit 6bdd1af

Please sign in to comment.