I need the list AKS cluster names, node pool and node names using powershell

Girish Prajwal 706 Reputation points
2023-05-09T13:37:04.7633333+00:00

Hi Team, I need the list AKS cluster names, node pool and node names using powershell.

Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,448 questions
{count} votes

Accepted answer
  1. Prrudram-MSFT 28,201 Reputation points Moderator
    2023-05-10T08:34:20.5566667+00:00

    Hi @Girish Prajwal

    You can get the list of AKS cluster names and node pool names using the PowerShell script below.

    # Get the list of AKS clusters
    $aksClusters = Get-AzAksCluster
    
    # Loop through each AKS cluster and get the node pool and node names
    foreach ($aksCluster in $aksClusters) {
        $aksClusterName = $aksCluster.Name
        $aksResourceGroup = $aksCluster.ResourceGroupName
        write-output "AKS Clusters: $aksClusterName"
        $aksNodepool = Get-AzAksNodepool -ResourceGroupName $aksResourceGroup -ClusterName $aksClusterName
        
       foreach ( $item in $aksNodepool)
       {
        Write-Output "AKS NodePools: $item. Name"
       }
    }
    

    For the node names list you need to use the Kubectl commands:

    kubectl get nodes -l "type=virtual-node,node-role.kubernetes.io/agentpool=<node-pool-name>"
    
    

    The AKS node names are not included in the node pool properties because node names are assigned by the Kubernetes and are not related to the node pool. When you create an AKS cluster, Kubernetes creates a set of nodes to run your workloads. These nodes are created in a node pool, which is a logical grouping of nodes with similar configurations. However, the node names are assigned by Kubernetes and are not related to the node pool.

    You can use the kubectl get nodes command to get the list of nodes in your AKS cluster, and the kubectl describe node <node-name> command to get detailed information about a specific node, including its name. However, the node names are not included in the node pool properties because they are not related to the node pool.

    If this does answer your question, please accept it as the answer as a token of appreciation.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.