This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
// cannot-be-validated-with-arg | ||
// Azure Resource Graph Query | ||
// Returns each AKS cluster with nodepools that have user nodepools with a subnetmask that does not match autoscale configured max-nodes | ||
// Subtracting the network address, broadcast address, and default 3 addresses Azure reserves within each subnet | ||
|
||
resources | ||
| where type == "microsoft.containerservice/managedclusters" | ||
| extend nodePools = properties['agentPoolProfiles'] | ||
| mv-expand nodePools = properties.agentPoolProfiles | ||
| where nodePools.enableAutoScaling == true | ||
| extend nodePoolName=nodePools.name, maxNodes = nodePools.maxCount, subnetId = tostring(nodePools.vnetSubnetID) | ||
| project clusterId = id, clusterName=name, nodePoolName=nodePools.name, toint(maxNodes), subnetId | ||
| join kind = leftouter ( | ||
resources | ||
| where type == 'microsoft.network/virtualnetworks' | ||
| extend subnets = properties.subnets | ||
| mv-expand subnets | ||
| project id = tostring(subnets.id), addressPrefix = tostring(subnets.properties['addressPrefix']) | ||
| extend subnetmask = toint(substring(addressPrefix, indexof(addressPrefix, '/')+1, string_size(addressPrefix))) | ||
| extend possibleMaxNodeCount = toint(exp2(32-subnetmask) - 5) | ||
) on $left.subnetId == $right.id | ||
| project-away id, subnetmask | ||
| where possibleMaxNodeCount <= maxNodes | ||
| extend param1 = strcat(nodePoolName, " autoscaler upper limit: ", maxNodes) | ||
| extend param2 = strcat("ip addresses on subnet: ", possibleMaxNodeCount) | ||
| project recommendationId="aks-23", name=clusterName, id=clusterId, param1, param2 |