-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2593 from janegilring/arcbox_3.0
ArcBox 3.0 - Updated workbooks and improved monitoring of the deployment status of clusters in DataOps
- Loading branch information
Showing
8 changed files
with
195 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 33 additions & 18 deletions
51
azure_jumpstart_arcbox/artifacts/MonitorWorkbookLogonScript.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,50 @@ | ||
$ArcBoxDir = "C:\ArcBox" | ||
$ArcBoxDir = 'C:\ArcBox' | ||
$ArcBoxLogsDir = "$ArcBoxDir\Logs" | ||
|
||
Start-Transcript -Path $ArcBoxLogsDir\MonitorWorkbookLogonScript.log | ||
|
||
# Required for CLI commands | ||
Write-Header "Az CLI Login" | ||
Write-Header 'Az CLI Login' | ||
az login --identity | ||
az account set -s $env:subscriptionId | ||
|
||
Write-Host "[$(Get-Date -Format t)] INFO: Configuring Azure Monitor Workbook ARM template for $($env:flavor)" | ||
|
||
# Configure mgmtMonitorWorkbook.json template with subscription ID and resource group values | ||
Write-Host "Configuring Azure Monitor Workbook ARM template." | ||
Write-Host "`n" | ||
$monitorWorkbook = "$ArcBoxDir\mgmtMonitorWorkbook.json" | ||
(Get-Content -Path $monitorWorkbook) -replace '<subscriptionId>',$Env:subscriptionId | Set-Content -Path $monitorWorkbook | ||
(Get-Content -Path $monitorWorkbook) -replace '<resourceGroup>',$Env:resourceGroup | Set-Content -Path $monitorWorkbook | ||
(Get-Content -Path $monitorWorkbook) -replace '<workspaceName>',$Env:workspaceName | Set-Content -Path $monitorWorkbook | ||
|
||
# Configure mgmtMonitorWorkbook.parameters.json template with workspace resource id | ||
$monitorWorkbookParameters = "$ArcBoxDir\mgmtMonitorWorkbook.parameters.json" | ||
$workspaceResourceId = $(az resource show --resource-group $Env:resourceGroup --name $Env:workspaceName --resource-type "Microsoft.OperationalInsights/workspaces" --query id -o tsv) | ||
(Get-Content -Path $monitorWorkbookParameters) -replace 'workbookResourceId-stage',$workspaceResourceId | Set-Content -Path $monitorWorkbookParameters | ||
if ($env:flavor -eq 'ITPro') { | ||
|
||
Write-Host "Deploying Azure Monitor Workbook ARM template." | ||
Write-Host "`n" | ||
az deployment group create --resource-group $Env:resourceGroup --template-file "$ArcBoxDir\mgmtMonitorWorkbook.json" --parameters "$ArcBoxDir\mgmtMonitorWorkbook.parameters.json" | ||
Write-Host "`n" | ||
Deploy-Workbook -MonitoringDir C:\ArcBox -workbookFileName arc-inventory-workbook.json | ||
Deploy-Workbook -MonitoringDir C:\ArcBox -workbookFileName arc-osperformance-workbook.json | ||
|
||
|
||
} else { | ||
|
||
|
||
Write-Host "`n" | ||
|
||
# Configure mgmtMonitorWorkbook.json template with subscription ID and resource group values | ||
|
||
$monitorWorkbook = "$ArcBoxDir\mgmtMonitorWorkbook.json" | ||
(Get-Content -Path $monitorWorkbook) -replace '<subscriptionId>', $Env:subscriptionId | Set-Content -Path $monitorWorkbook | ||
(Get-Content -Path $monitorWorkbook) -replace '<resourceGroup>', $Env:resourceGroup | Set-Content -Path $monitorWorkbook | ||
(Get-Content -Path $monitorWorkbook) -replace '<workspaceName>', $Env:workspaceName | Set-Content -Path $monitorWorkbook | ||
|
||
# Configure mgmtMonitorWorkbook.parameters.json template with workspace resource id | ||
$monitorWorkbookParameters = "$ArcBoxDir\mgmtMonitorWorkbook.parameters.json" | ||
$workspaceResourceId = $(az resource show --resource-group $Env:resourceGroup --name $Env:workspaceName --resource-type 'Microsoft.OperationalInsights/workspaces' --query id -o tsv) | ||
(Get-Content -Path $monitorWorkbookParameters) -replace 'workbookResourceId-stage', $workspaceResourceId | Set-Content -Path $monitorWorkbookParameters | ||
|
||
Write-Host 'Deploying Azure Monitor Workbook ARM template.' | ||
Write-Host "`n" | ||
az deployment group create --resource-group $Env:resourceGroup --template-file "$ArcBoxDir\mgmtMonitorWorkbook.json" --parameters "$ArcBoxDir\mgmtMonitorWorkbook.parameters.json" | ||
Write-Host "`n" | ||
|
||
} | ||
|
||
# Removing the LogonScript Scheduled Task so it won't run on next reboot | ||
if ($null -ne (Get-ScheduledTask -TaskName "MonitorWorkbookLogonScript" -ErrorAction SilentlyContinue)) { | ||
Unregister-ScheduledTask -TaskName "MonitorWorkbookLogonScript" -Confirm:$false | ||
if ($null -ne (Get-ScheduledTask -TaskName 'MonitorWorkbookLogonScript' -ErrorAction SilentlyContinue)) { | ||
Unregister-ScheduledTask -TaskName 'MonitorWorkbookLogonScript' -Confirm:$false | ||
} | ||
|
||
Start-Sleep -Seconds 5 |
57 changes: 57 additions & 0 deletions
57
azure_jumpstart_arcbox/artifacts/monitoring/arc-inventory-workbook.json
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
azure_jumpstart_arcbox/artifacts/monitoring/arc-osperformance-workbook.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ifacts/powershell/modules/Azure.Arc.Jumpstart.Common/Functions/Public/Deploy-Workbook.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function Deploy-Workbook { | ||
param( | ||
[string]$MonitoringDir, | ||
[string]$workbookFileName | ||
) | ||
|
||
Write-Host "[$(Get-Date -Format t)] INFO: Deploying Azure Workbook $workbookFileName." | ||
Write-Host "`n" | ||
$workbookTemplateFilePath = "$MonitoringDir\$workbookFileName" | ||
# Read the content of the workbook template-file | ||
$content = Get-Content -Path $workbookTemplateFilePath -Raw | ||
# Replace placeholders with actual values | ||
$updatedContent = $content -replace 'rg-placeholder', $env:resourceGroup | ||
$updatedContent = $updatedContent -replace '/subscriptions/00000000-0000-0000-0000-000000000000', "/subscriptions/$($env:subscriptionId)" | ||
$updatedContent = $updatedContent -replace "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/$env:resourceGroup/providers/Microsoft.OperationalInsights/workspaces/xxxx", "/subscriptions/$($env:subscriptionId)/resourceGroups/$($env:resourceGroup)/providers/Microsoft.OperationalInsights/workspaces/$($env:workspaceName)" | ||
|
||
# Write the updated content back to the file | ||
Set-Content -Path $workbookTemplateFilePath -Value $updatedContent | ||
|
||
# Deploy the workbook | ||
try { | ||
New-AzResourceGroupDeployment -ResourceGroupName $Env:resourceGroup -TemplateFile $workbookTemplateFilePath -ErrorAction Stop | ||
Write-Host "[$(Get-Date -Format t)] INFO: Deployment of template-file $workbookTemplateFilePath succeeded." | ||
} catch { | ||
Write-Error "[$(Get-Date -Format t)] ERROR: Deployment of template-file $workbookTemplateFilePath failed. Error details: $PSItem.Exception.Message" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...acts/powershell/modules/Azure.Arc.Jumpstart.Common/Functions/Public/Show-K8sPodStatus.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function Show-K8sPodStatus { | ||
param ( | ||
[string]$kubeconfig, | ||
[string]$clusterName | ||
) | ||
|
||
while ($true) { | ||
Write-Host "Status for $clusterName at $(Get-Date)" -ForegroundColor Green | ||
kubectl get pods -n arc --kubeconfig $kubeconfig | ||
Start-Sleep -Seconds 5 | ||
Clear-Host | ||
} | ||
} |