manifests/collectors/Containers/AKS.psd1
|
# # GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Containers/AKS.ps1 (AB#5660). # Field expressions are copied verbatim from the original collector and evaluate in an # equivalent scope -- see docs/design/decisions/declarative-collectors.md. # Review before trusting; regenerate rather than hand-patch if the source collector changes. # @{ ResourceTypes = @( 'microsoft.containerservice/managedclusters' ) ResourceTypeMatching = 'Grouped' AdditionalFilter = $null FilterPreamble = '' RowLoopVariable = '1' SetupPreamble = @' $AKS = $Resources | Where-Object {$_.TYPE -eq 'microsoft.containerservice/managedclusters'} $VMExtraDetails = $Resources | Where-Object { $_.TYPE -eq 'AZSC/VM/SKU' } $VMQuotas = $Resources | Where-Object { $_.TYPE -eq 'AZSC/VM/Quotas' } '@ SetupVariables = @( 'AKS' 'VMExtraDetails' 'VMQuotas' ) Preamble = @' $ResUCount = 1 $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId } $data = $1.PROPERTIES $Retired = Foreach ($Retirement in $Retirements) { if ($Retirement.id -eq $1.id) { $Retirement } } if ($Retired) { $RetiredFeature = foreach ($Retire in $Retired) { $RetiredServiceID = $Unsupported | Where-Object {$_.Id -eq $Retired.ServiceID} $tmp0 = [pscustomobject]@{ 'RetiredFeature' = $RetiredServiceID.RetiringFeature 'RetiredDate' = $RetiredServiceID.RetirementDate } $tmp0 } $RetiringFeature = if (@($RetiredFeature.RetiredFeature).count -gt 1) { $RetiredFeature.RetiredFeature | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredFeature} $RetiringFeature = [string]$RetiringFeature $RetiringFeature = if ($RetiringFeature -like '* ,*') { $RetiringFeature -replace ".$" }else { $RetiringFeature } $RetiringDate = if (@($RetiredFeature.RetiredDate).count -gt 1) { $RetiredFeature.RetiredDate | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredDate} $RetiringDate = [string]$RetiringDate $RetiringDate = if ($RetiringDate -like '* ,*') { $RetiringDate -replace ".$" }else { $RetiringDate } } else { $RetiringFeature = $null $RetiringDate = $null } if([string]::IsNullOrEmpty($data.addonProfiles.omsagent.config.logAnalyticsWorkspaceResourceID)){$Insights = $false}else{$Insights = (Get-AZSCIdSegment -Id $data.addonProfiles.omsagent.config.logAnalyticsWorkspaceResourceID -Index 8)} $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'} $NetworkPlugin = if($data.networkprofile.networkplugin -eq 'azure'){'Azure CNI'}else{$data.networkprofile.networkplugin} $LocalAccounts = if($data.disablelocalaccounts -eq $true){$false}else{$true} $GroupsChosen = if($data.aadprofile.admingroupobjectids){[string]@($data.aadprofile.admingroupobjectids).count}else{'0'} $GroupsChosen = ($GroupsChosen+' groups chosen') $NodeChannel = if([string]::IsNullOrEmpty($data.autoupgradeprofile.nodeosupgradechannel)){'None'}else{$data.autoupgradeprofile.nodeosupgradechannel} $UpgradeChannel = if([string]::IsNullOrEmpty($data.autoUpgradeProfile.upgradeChannel)){'Disabled'}else{$data.autoUpgradeProfile.upgradeChannel} $NetPolicy = if(![string]::IsNullOrEmpty($data.networkProfile.networkPolicy)){$data.networkProfile.networkPolicy}else{'None'} $PubliAccess = if([string]::IsNullOrEmpty($data.publicNetworkAccess)){'Enabled'}else{if($data.publicNetworkAccess -eq 'Disabled'){'Disabled'}else{'Enabled'}} $Identity = if(![string]::IsNullOrEmpty($data.identityprofile.kubeletidentity.resourceid)){(Get-AZSCIdSegment -Id $data.identityprofile.kubeletidentity.resourceid -Index 8)}else{''} $Ingress = if([string]::IsNullOrEmpty($data.addonProfiles.ingressApplicationGateway.config.applicationGatewayName)){'Not enabled'}else{$data.addonProfiles.ingressApplicationGateway.config.applicationGatewayName} $PrivateCluster = if([string]::IsNullOrEmpty($data.apiServerAccessProfile.enablePrivateCluster)){$false}else{$data.apiServerAccessProfile.enablePrivateCluster} '@ AdditionalRowLoops = @( @{ Variable = '2' Source = '$data.agentPoolProfiles' # AB#6845: without this, a cluster whose payload carries no `agentPoolProfiles` # produces NO ROW AT ALL and vanishes from the worksheet -- the customer counts one # cluster fewer with nothing to tell them why. An AKS cluster is a first-class # resource whose existence is the point of an inventory; the pools are detail. Emit # the cluster with blank pool columns instead of dropping it. # # Every real cluster has at least a system node pool, so this changes nothing for a # healthy estate -- and all 236 golden records are unchanged by it. It is the # truncated, failed and mid-creation payloads that were silently disappearing. EmitNullWhenEmpty = $true Preamble = @' $AutoScale = if([string]::IsNullOrEmpty($2.enableAutoScaling)){$false}else{if($2.enableautoscaling -eq $true){$true}else{$false}} $AVZone = if([string]::IsNullOrEmpty($2.availabilityZones)){'None'}else{[string]$2.availabilityZones} $Taints = if (@($2.nodetaints).count -gt 1) { $2.nodetaints | ForEach-Object { $_ + ' ,' } }else { $2.nodetaints } $Taints = [string]$Taints $Taints = if ($Taints -like '* ,*') { $Taints -replace ".$" }else { $Taints } $Labels = if (@($2.nodelabels).count -gt 1) { $2.nodelabels | ForEach-Object { $_ + ' ,' } }else { $2.nodelabels } $Labels = [string]$Labels $Labels = if ($Labels -like '* ,*') { $Labels -replace ".$" }else { $Labels } # Extra VM Details $vCPUs = $null; $vCPUsPerCore = $null; $RAM = $null $VMExtraDetail = @(Get-AZSCCollectedValue -InputObject $VMExtraDetails -Name 'properties') | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'Location') -eq $1.location } $VMExtraDetail = @(Get-AZSCCollectedValue -InputObject $VMExtraDetail -Name 'SKUs') | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'Name') -eq $2.vmSize } foreach ($Capability in @(Get-AZSCCollectedValue -InputObject $VMExtraDetail -Name 'Capabilities')) { if ($Capability.Name -eq 'vCPUs') {$vCPUs = $Capability.Value} if ($Capability.Name -eq 'vCPUsPerCore') {$vCPUsPerCore = $Capability.Value} if ($Capability.Name -eq 'MemoryGB') {$RAM = $Capability.Value} } # Quotas $Size = Get-AZSCCollectedValue -InputObject $VMExtraDetail -Name 'Family' $Quota = @(Get-AZSCCollectedValue -InputObject $VMQuotas -Name 'properties') | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'SubId') -eq $1.subscriptionId } $Quota = $Quota | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'Location') -eq $1.location } $QuotaData = @(Get-AZSCCollectedValue -InputObject $Quota -Name 'Data') | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'Name.Value') -eq $Size } $RemainingQuota = (Get-AZSCCollectedValue -InputObject $QuotaData -Name 'Limit') - (Get-AZSCCollectedValue -InputObject $QuotaData -Name 'CurrentValue') '@ } ) TagLoop = @{ Variable = 'Tag' Source = '$Tags' Preamble = '' } Fields = @( @{ Name = 'ID' Expression = '$1.id' } @{ Name = 'Subscription' Expression = '$sub1.Name' } @{ Name = 'Resource Group' Expression = '$1.RESOURCEGROUP' } @{ Name = 'Clusters' Expression = '$1.NAME' } @{ Name = 'Location' Expression = '$1.LOCATION' } @{ Name = 'Retiring Feature' Expression = '$RetiringFeature' } @{ Name = 'Retiring Date' Expression = '$RetiringDate' } @{ Name = 'AKS Pricing Tier' Expression = '$1.sku.tier' } @{ Name = 'Kubernetes Version' Expression = '[string]$data.kubernetesVersion' } @{ Name = 'Cluster Power State' Expression = '$data.powerstate.code' } @{ Name = 'Role-Based Access Control' Expression = '$data.enableRBAC' } @{ Name = 'AAD Enabled' Expression = 'if ($data.aadProfile) { $true }else { $false }' } @{ Name = 'Kubernetes Local Accounts' Expression = '$LocalAccounts' } @{ Name = 'Cluster Admin ClusterRoleBinding' Expression = '$GroupsChosen' } @{ Name = 'Network Type (Plugin)' Expression = '$NetworkPlugin' } @{ Name = 'Plugin Mode' Expression = '$data.networkprofile.networkpluginmode' } @{ Name = 'Pod CIDR' Expression = '$data.networkProfile.podCidr' } @{ Name = 'Network Policy' Expression = '$NetPolicy' } @{ Name = 'Outbound Type' Expression = '$data.networkProfile.outboundType' } @{ Name = 'Infrastructure Resource Group' Expression = '$data.noderesourcegroup' } @{ Name = 'Cluster Managed Identity' Expression = '$Identity' } @{ Name = 'App Gateway Ingress Controller' Expression = '$Ingress' } @{ Name = 'Private Cluster' Expression = '$PrivateCluster' } @{ Name = 'Private Cluster FQDN' Expression = '$data.privatefqdn' } @{ Name = 'Public Network Access' Expression = '$PubliAccess' } @{ Name = 'Automatic Upgrade Type' Expression = '$UpgradeChannel' } @{ Name = 'Node Security Channel Type' Expression = '$NodeChannel' } @{ Name = 'Container Insights' Expression = '$Insights' } @{ Name = 'API Server Address' Expression = '$data.fqdn' } @{ Name = 'Node Pool Name' Expression = '$2.name' } @{ Name = 'Node Pool Power State' Expression = '$2.powerstate.code' } @{ Name = 'Node Pool Version' Expression = '[string]$2.orchestratorVersion' } @{ Name = 'Node Pool Mode' Expression = '$2.mode' } @{ Name = 'Node Pool OS Type' Expression = '$2.osType' } @{ Name = 'Node Pool OS' Expression = '$2.ossku' } @{ Name = 'Node Pool Image' Expression = '$2.nodeimageversion' } @{ Name = 'Node Pool Size' Expression = '$2.vmSize' } @{ Name = 'vCPUs (Per Node)' Expression = '$vCPUs' } @{ Name = 'vCPUs Per Core (Per Node)' Expression = '$vCPUsPerCore' } @{ Name = 'RAM (GB) Per Node' Expression = '$RAM' } @{ Name = 'Remaining Quota' Expression = '$RemainingQuota' } @{ Name = 'OS Disk Size (GB)' Expression = '$2.osDiskSizeGB' } @{ Name = 'Target Nodes' Expression = '$2.count' } @{ Name = 'Availability Zones' Expression = '$AVZone' } @{ Name = 'Zones Available in the Region' Expression = '[string](Get-AZSCSafeProperty -InputObject $VMExtraDetail -Path ''LocationInfo.ZoneDetails.Name'' -Enumerate)' } @{ Name = 'Autoscale' Expression = '$AutoScale' } @{ Name = 'Autoscale Minimum Node Count' Expression = '$2.minCount' } @{ Name = 'Autoscale Maximum Node Count' Expression = '$2.maxCount' } @{ Name = 'Max Pods Per Node' Expression = '$2.maxPods' } @{ Name = 'Virtual Network' Expression = 'if($2.vnetSubnetID){(Get-AZSCIdSegment -Id $2.vnetSubnetID -Index 8)}else{$false}' } @{ Name = 'Subnet' Expression = 'if($2.vnetSubnetID){(Get-AZSCIdSegment -Id $2.vnetSubnetID -Index 10)}else{$false}' } @{ Name = 'Enable Node Public IP' Expression = '$2.enableNodePublicIP' } @{ Name = 'Taints' Expression = '$Taints' } @{ Name = 'Labels' Expression = '$Labels' } @{ Name = 'Resource U' Expression = '$ResUCount' } @{ Name = 'Tag Name' Expression = '[string]$Tag.Name' } @{ Name = 'Tag Value' Expression = '[string]$Tag.Value' } ) Export = @{ WorksheetName = 'AKS' TableNamePrefix = 'AKSTable_' Columns = @( 'Subscription' 'Resource Group' 'Clusters' 'Location' 'Retiring Feature' 'Retiring Date' 'AKS Pricing Tier' 'Kubernetes Version' 'Cluster Power State' 'Role-Based Access Control' 'AAD Enabled' 'Kubernetes Local Accounts' 'Cluster Admin ClusterRoleBinding' 'Network Type (Plugin)' 'Plugin Mode' 'Pod CIDR' 'Network Policy' 'Outbound Type' 'Infrastructure Resource Group' 'Cluster Managed Identity' 'App Gateway Ingress Controller' 'Private Cluster' 'Private Cluster FQDN' 'Public Network Access' 'Automatic Upgrade Type' 'Node Security Channel Type' 'Container Insights' 'API Server Address' 'Node Pool Name' 'Node Pool Power State' 'Node Pool Version' 'Node Pool Mode' 'Node Pool OS Type' 'Node Pool OS' 'Node Pool Image' 'Node Pool Size' 'Target Nodes' 'vCPUs (Per Node)' 'vCPUs Per Core (Per Node)' 'RAM (GB) Per Node' 'Remaining Quota' 'Availability Zones' 'Zones Available in the Region' 'Max Pods Per Node' 'OS Disk Size (GB)' 'Autoscale' 'Autoscale Minimum Node Count' 'Autoscale Maximum Node Count' 'Virtual Network' 'Subnet' 'Enable Node Public IP' 'Taints' 'Labels' 'Resource U' ) TagColumns = @( 'Tag Name' 'Tag Value' ) TagColumnsBefore = 'Resource U' NumberFormat = '0' ConditionalText = @() } SourceCollector = 'Modules/Public/InventoryModules/Containers/AKS.ps1' } |