Skip to content

Commit ef9bc51

Browse files
rod-reisRodrigo Reis Santos (AZURE)
andauthored
fix: This PR resolves issues with AKS, VMSS and Load Balancers ARGs (#745)
Co-authored-by: Rodrigo Reis Santos (AZURE) <Rodrigo.REIS@microsoft.com>
1 parent 7958015 commit ef9bc51

11 files changed

Lines changed: 78 additions & 46 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Azure Resource Graph Query
2+
// Returns any AKS cluster nodepools that do not have Ephemeral Disks
3+
resources
4+
| where type == "microsoft.containerservice/managedclusters"
5+
| mv-expand agentPoolProfile = properties.agentPoolProfiles
6+
| extend
7+
osDiskType = tostring(agentPoolProfile.osDiskType),
8+
nodePoolName = tostring(agentPoolProfile.name),
9+
nodeResourceGroup = tostring(properties.nodeResourceGroup),
10+
subscriptionId = tostring(split(id, "/")[2])
11+
| where osDiskType != "Ephemeral" and isnotempty(nodeResourceGroup)
12+
| project
13+
nodePoolName,
14+
nodeResourceGroup,
15+
subscriptionId
16+
| join kind=inner (
17+
resources
18+
| where type == "microsoft.compute/virtualmachinescalesets"
19+
| extend
20+
vmssName = name,
21+
vmssId = id,
22+
subscriptionId = tostring(split(id, "/")[2]),
23+
resourceGroup = tostring(split(id, "/")[4])
24+
) on subscriptionId
25+
| where tolower(resourceGroup) == tolower(nodeResourceGroup)
26+
and tolower(vmssName) contains tolower(nodePoolName)
27+
| project
28+
recommendationId = "a7bfcc18-b0d8-4d37-81f3-8131ed8bead5",
29+
name = vmssName,
30+
id = vmssId,
31+
tags,
32+
param1 = "osDiskType: Non-Ephemeral"

azure-resources/Compute/virtualMachineScaleSets/recommendations.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,19 @@
151151
- name: Deprecated Azure Marketplace images
152152
url: "https://learn.microsoft.com/azure/virtual-machines/deprecated-images"
153153

154+
- description: Use Ephemeral OS Disks for AKS VMSS Node Pools
155+
aprlGuid: a7bfcc18-b0d8-4d37-81f3-8131ed8bead5
156+
recommendationTypeId: null
157+
recommendationControl: Scalability
158+
recommendationImpact: Medium
159+
recommendationResourceType: Microsoft.Compute/virtualMachineScaleSets
160+
recommendationMetadataState: Active
161+
longDescription: |
162+
Ephemeral OS disks on AKS offer lower read/write latency due to local attachment, eliminating the need for replication seen with managed disks. This enhances performance and speeds up cluster operations such as scaling or upgrading due to quicker re-imaging and boot times.
163+
potentialBenefits: Lower latency, faster re-imaging and booting
164+
pgVerified: true
165+
automationAvailable: true
166+
tags: []
167+
learnMoreLink:
168+
- name: Ephemeral OS disk
169+
url: "https://learn.microsoft.com/azure/aks/concepts-storage#ephemeral-os-disk"

azure-resources/ContainerService/managedClusters/kql/005ccbbd-aeab-46ef-80bd-9bd4479412ec.kql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ resources
66
| extend taints = tostring(parse_json(agentPoolProfile.nodeTaints))
77
| extend nodePool = tostring(parse_json(agentPoolProfile.name))
88
| where taints !has "CriticalAddonsOnly=true:NoSchedule" and agentPoolProfile.minCount < 2
9-
| project recommendationId="005ccbbd-aeab-46ef-80bd-9bd4479412ec", name=nodePool, id=strcat(id,"/agentPools/",nodePool), tags,param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)
9+
| project recommendationId="005ccbbd-aeab-46ef-80bd-9bd4479412ec", name, id=id, tags,param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)

azure-resources/ContainerService/managedClusters/kql/a7bfcc18-b0d8-4d37-81f3-8131ed8bead5.kql

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Azure Resource Graph Query
2-
// Returns each AKS cluster with nodepools that have Linux nodepools not using Azure Linux
2+
// Returns each AKS cluster that has Linux node pools not using Azure Linux
33
resources
4-
| where type == "microsoft.containerservice/managedclusters"
5-
| mv-expand agentPoolProfile = properties.agentPoolProfiles
6-
| where agentPoolProfile.osType == 'Linux' and agentPoolProfile.osSKU != 'AzureLinux'
7-
| project recommendationid="f46b0d1d-56ef-4795-b98a-f6ee00cb341a", name=agentPoolProfile.name, id=strcat(id,"/agentPools/",agentPoolProfile.name),tags, param1=strcat("nodePoolName: ", agentPoolProfile.name)
4+
| where type == "microsoft.containerservice/managedclusters"
5+
| mv-expand agentPoolProfile = properties.agentPoolProfiles
6+
| where agentPoolProfile.osType == 'Linux' and agentPoolProfile.osSKU != 'AzureLinux'
7+
| extend clusterId = id,clusterName = name,nodePoolName = tostring(agentPoolProfile.name)
8+
| summarize nonAzureLinuxNodePools = make_list(strcat("nodePoolName: ", nodePoolName)),anyClusterName = any(clusterName),anyTags = any(tags) by clusterId
9+
| project recommendationId = "f46b0d1d-56ef-4795-b98a-f6ee00cb341a",name = anyClusterName,id = clusterId,tags = anyTags,param1 = tostring(nonAzureLinuxNodePools)

azure-resources/ContainerService/managedClusters/recommendations.yaml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
recommendationTypeId: 9f3263db-b9c0-43bb-8523-6800f9f50793
44
recommendationControl: HighAvailability
55
recommendationImpact: High
6-
recommendationResourceType: Microsoft.ContainerService/managedClusters/agentPools
6+
recommendationResourceType: Microsoft.ContainerService/managedClusters
77
recommendationMetadataState: Active
88
longDescription: |
99
Azure Availability Zones ensure high availability by offering independent locations within regions, equipped with their own power, cooling, and networking to ensure applications and data are protected from datacenter-level failures.
@@ -202,23 +202,6 @@
202202
- name: Monitor AKS
203203
url: "https://learn.microsoft.com/azure/aks/monitor-aks"
204204

205-
- description: Use Ephemeral OS disks on AKS clusters
206-
aprlGuid: a7bfcc18-b0d8-4d37-81f3-8131ed8bead5
207-
recommendationTypeId: null
208-
recommendationControl: Scalability
209-
recommendationImpact: Medium
210-
recommendationResourceType: Microsoft.ContainerService/managedClusters/agentPools
211-
recommendationMetadataState: Active
212-
longDescription: |
213-
Ephemeral OS disks on AKS offer lower read/write latency due to local attachment, eliminating the need for replication seen with managed disks. This enhances performance and speeds up cluster operations such as scaling or upgrading due to quicker re-imaging and boot times.
214-
potentialBenefits: Lower latency, faster re-imaging and booting
215-
pgVerified: true
216-
automationAvailable: true
217-
tags: []
218-
learnMoreLink:
219-
- name: Ephemeral OS disk
220-
url: "https://learn.microsoft.com/azure/aks/concepts-storage#ephemeral-os-disk"
221-
222205
- description: Enable and remediate Azure Policies configured for AKS
223206
aprlGuid: 26ebaf1f-c70d-4ebd-8641-4b60a0ce0094
224207
recommendationTypeId: null
@@ -326,7 +309,7 @@
326309
recommendationTypeId: null
327310
recommendationControl: HighAvailability
328311
recommendationImpact: High
329-
recommendationResourceType: Microsoft.ContainerService/managedClusters/agentPools
312+
recommendationResourceType: Microsoft.ContainerService/managedClusters
330313
recommendationMetadataState: Active
331314
longDescription: |
332315
Configuring the user node pool with at least two nodes is essential for applications needing high availability, ensuring they remain operational and accessible without interruption.
@@ -394,7 +377,7 @@
394377
recommendationTypeId: null
395378
recommendationControl: HighAvailability
396379
recommendationImpact: High
397-
recommendationResourceType: Microsoft.ContainerService/managedClusters/agentPools
380+
recommendationResourceType: Microsoft.ContainerService/managedClusters
398381
recommendationMetadataState: Disabled
399382
longDescription: |
400383
Azure Linux on AKS boosts resiliency with a native image using validated, source-built components. It's lightweight, reducing the attack surface and maintenance. A Microsoft-hardened kernel, optimized for Azure, enhances stability and security for container workloads.

azure-resources/Network/loadBalancers/kql/621dbc78-3745-4d32-8eac-9e65b27b7512.kql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ resources
2727
| join kind=innerunique (
2828
resources
2929
| where type == "microsoft.network/publicipaddresses"
30-
| where location in~ ("australiaeast", "brazilsouth", "canadacentral", "centralindia", "centralus", "eastasia", "eastus", "eastus2", "francecentral", "germanywestcentral", "israelcentral", "italynorth", "japaneast", "japanwest", "koreacentral", "mexicocentral", "newzealandnorth", "northeurope", "norwayeast", "polandcentral", "qatarcentral", "southafricanorth", "southcentralus", "southeastasia", "spaincentral", "swedencentral", "switzerlandnorth", "uaenorth", "uksouth", "westeurope", "westus2", "westus3", "usgovvirginia", "chinanorth3")
30+
| where location in~ ("centralindia", "centralus", "eastus", "japaneast", "japanwest","newzealandnorth", "southcentralus", "southeastasia", "switzerlandnorth","uaenorth", "westeurope", "westus3", "usgovvirginia", "chinanorth3")
3131
| where isnull(zones) or array_length(zones) < 2
3232
| extend
3333
LBid = toupper(substring(properties.ipConfiguration.id, 0, indexof(properties.ipConfiguration.id, '/frontendIPConfigurations'))),
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Azure Resource Graph Query
2-
// Find all LoadBalancers which only have 1 backend pool defined or only 1 VM in the backend pool,
3-
// and project the name of the impacted backend pool.
2+
// Find all LoadBalancers with only 1 VM in any backend pool
43
resources
54
| where type =~ 'Microsoft.Network/loadBalancers'
65
| mv-expand bpool = properties.backendAddressPools
76
| extend BackendAddresses = array_length(bpool.properties.loadBalancerBackendAddresses)
87
| where BackendAddresses <= 1
9-
| project recommendationId = "6d82d042-6d61-ad49-86f0-6a5455398081",name=bpool.name,id=strcat(id,"/backendAddressPools/",bpool.name),tags
8+
| extend lbId = id, lbName = name, poolName = tostring(bpool.name)
9+
| summarize anyPool = any(poolName), anyTags = any(tags) by lbId, lbName
10+
| project recommendationId = "6d82d042-6d61-ad49-86f0-6a5455398081", name = lbName, id = lbId, tags = anyTags, param1 = strcat("backendPoolName: ", anyPool)

azure-resources/Network/loadBalancers/recommendations.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
recommendationTypeId: null
2121
recommendationControl: HighAvailability
2222
recommendationImpact: High
23-
recommendationResourceType: Microsoft.Network/loadBalancers/backendAddressPools
23+
recommendationResourceType: Microsoft.Network/loadBalancers
2424
recommendationMetadataState: Active
2525
longDescription: |
2626
Deploying Azure Load Balancers with at least two instances in the backend prevents a single point of failure and supports scalability. Pairing with Virtual Machine Scale Sets is advised for optimal scale building.

azure-resources/Network/publicIPAddresses/kql/c63b81fb-7afc-894c-a840-91bb8a8dcfaf.kql

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// Azure Resource Graph query
22
// List public IP addresses that are not Zone-Redundant
3-
Resources
3+
resources
44
| where type =~ "Microsoft.Network/publicIPAddresses" and sku.tier =~ "Regional"
5-
| where location in~ ("australiaeast", "brazilsouth", "canadacentral", "centralindia", "centralus", "eastasia", "eastus", "eastus2", "francecentral", "germanywestcentral", "israelcentral", "italynorth", "japaneast", "japanwest", "koreacentral", "mexicocentral", "newzealandnorth", "northeurope", "norwayeast", "polandcentral", "qatarcentral", "southafricanorth", "southcentralus", "southeastasia", "spaincentral", "swedencentral", "switzerlandnorth", "uaenorth", "uksouth", "westeurope", "westus2", "westus3", "usgovvirginia", "chinanorth3")
6-
| where isempty(zones) or array_length(zones) <= 1
5+
| where
6+
(location in~ ("australiaeast", "brazilsouth", "canadacentral", "centralindia", "centralus", "eastasia", "eastus", "eastus2", "francecentral", "germanywestcentral", "israelcentral", "italynorth", "japaneast", "japanwest", "koreacentral", "mexicocentral", "newzealandnorth", "northeurope", "norwayeast", "polandcentral", "qatarcentral", "southafricanorth", "southcentralus", "southeastasia", "spaincentral", "swedencentral", "switzerlandnorth", "uaenorth", "uksouth", "westeurope", "westus2", "westus3", "usgovvirginia", "chinanorth3")
7+
and array_length(zones) <= 1)
8+
or
9+
(location in~ ("centralindia", "centralus", "eastus", "japaneast", "japanwest", "newzealandnorth","southcentralus", "southeastasia", "switzerlandnorth", "uaenorth", "westeurope", "westus3","usgovvirginia", "chinanorth3")
10+
and (isempty(zones) or array_length(zones) <= 1))
711
| extend az = case(isempty(zones), "Non-zonal", array_length(zones) <= 1, strcat("Zonal (", strcat_array(zones, ","), ")"), zones)
812
| project recommendationId = "c63b81fb-7afc-894c-a840-91bb8a8dcfaf", name, id, tags, param1 = strcat("sku: ", sku.name), param2 = strcat("availabilityZone: ", az)
9-

0 commit comments

Comments
 (0)