Przykładowe zapytania usługi Azure Resource Graph dotyczące platformy Kubernetes z obsługą usługi Azure Arc

Ta strona jest kolekcją przykładowych zapytań usługi Azure Resource Graph dla platformy Kubernetes z obsługą usługi Azure Arc. Aby uzyskać pełną listę przykładów usługi Azure Resource Graph, zobacz Resource Graph samples by category (Przykłady usługi Resource Graph według kategorii ) i Resource Graph samples by table (Przykłady usługi Resource Graph według tabeli).

Przykładowe zapytania

Wyświetlanie listy wszystkich klastrów Kubernetes z włączoną usługą Azure Arc za pomocą rozszerzenia usługi Azure Monitor

Zwraca identyfikator połączonego klastra dla każdego klastra Kubernetes z włączoną usługą Azure Arc, który ma zainstalowane rozszerzenie usługi Azure Monitor.

KubernetesConfigurationResources
| where type == 'microsoft.kubernetesconfiguration/extensions'
| where properties.ExtensionType  == 'microsoft.azuremonitor.containers'
| parse id with connectedClusterId '/providers/Microsoft.KubernetesConfiguration/Extensions' *
| project connectedClusterId
az graph query -q "KubernetesConfigurationResources | where type == 'microsoft.kubernetesconfiguration/extensions' | where properties.ExtensionType == 'microsoft.azuremonitor.containers' | parse id with connectedClusterId '/providers/Microsoft.KubernetesConfiguration/Extensions' * | project connectedClusterId"

Wyświetlanie listy wszystkich klastrów Kubernetes z włączoną usługą Azure Arc bez rozszerzenia usługi Azure Monitor

Zwraca identyfikator połączonego klastra dla każdego klastra Kubernetes z włączoną usługą Azure Arc, który nie ma rozszerzenia usługi Azure Monitor.

Resources
| where type =~ 'Microsoft.Kubernetes/connectedClusters' | extend connectedClusterId = tolower(id) | project connectedClusterId
| join kind = leftouter
	(KubernetesConfigurationResources
	| where type == 'microsoft.kubernetesconfiguration/extensions'
	| where properties.ExtensionType  == 'microsoft.azuremonitor.containers'
	| parse tolower(id) with connectedClusterId '/providers/microsoft.kubernetesconfiguration/extensions' *
	| project connectedClusterId
)  on connectedClusterId
| where connectedClusterId1 == ''
| project connectedClusterId
az graph query -q "Resources | where type =~ 'Microsoft.Kubernetes/connectedClusters' | extend connectedClusterId = tolower(id) | project connectedClusterId | join kind = leftouter (KubernetesConfigurationResources | where type == 'microsoft.kubernetesconfiguration/extensions' | where properties.ExtensionType == 'microsoft.azuremonitor.containers' | parse tolower(id) with connectedClusterId '/providers/microsoft.kubernetesconfiguration/extensions' * | project connectedClusterId ) on connectedClusterId | where connectedClusterId1 == '' | project connectedClusterId"

Wyświetlanie listy wszystkich zasobów platformy Kubernetes z włączoną usługą Azure Arc

Zwraca listę każdego klastra Kubernetes z obsługą usługi Azure Arc i odpowiednie metadane dla każdego klastra.

Resources
| project id, subscriptionId, location, type, properties.agentVersion, properties.kubernetesVersion, properties.distribution, properties.infrastructure, properties.totalNodeCount, properties.totalCoreCount
| where type =~ 'Microsoft.Kubernetes/connectedClusters'
az graph query -q "Resources | project id, subscriptionId, location, type, properties.agentVersion, properties.kubernetesVersion, properties.distribution, properties.infrastructure, properties.totalNodeCount, properties.totalCoreCount | where type =~ 'Microsoft.Kubernetes/connectedClusters'"

Wyświetl listę wszystkich Połączenie edClusters i ManagedClusters, które zawierają konfigurację flux

Zwraca wartości connectedCluster i managedCluster Ids dla klastrów zawierających co najmniej jedną wartość fluxConfiguration.

resources
| where type =~ 'Microsoft.Kubernetes/connectedClusters' or type =~ 'Microsoft.ContainerService/managedClusters' | extend clusterId = tolower(id) | project clusterId
| join
( kubernetesconfigurationresources
| where type == 'microsoft.kubernetesconfiguration/fluxconfigurations'
| parse tolower(id) with clusterId '/providers/microsoft.kubernetesconfiguration/fluxconfigurations' *
| project clusterId
) on clusterId
| project clusterId
az graph query -q "resources | where type =~ 'Microsoft.Kubernetes/connectedClusters' or type =~ 'Microsoft.ContainerService/managedClusters' | extend clusterId = tolower(id) | project clusterId | join ( kubernetesconfigurationresources | where type == 'microsoft.kubernetesconfiguration/fluxconfigurations' | parse tolower(id) with clusterId '/providers/microsoft.kubernetesconfiguration/fluxconfigurations' * | project clusterId ) on clusterId | project clusterId"

Wyświetlanie listy wszystkich konfiguracji strumienia, które są w stanie niezgodnym

Zwraca identyfikatory fluxConfiguration konfiguracji, które nie mogą synchronizować zasobów w klastrze.

kubernetesconfigurationresources
| where type == 'microsoft.kubernetesconfiguration/fluxconfigurations'
| where properties.complianceState == 'Non-Compliant'
| project id
az graph query -q "kubernetesconfigurationresources | where type == 'microsoft.kubernetesconfiguration/fluxconfigurations' | where properties.complianceState == 'Non-Compliant' | project id"

Następne kroki