What is a Node resource group in Azure Kubernetes Service?
Tags: kubernetes, azure, productivity, showdev
Published: 2020-01-28 12:37:39

Here is a quick tip on `Node Resource Group` in [Azure Kubernetes Service (AKS)](https://docs.microsoft.com/azure/aks/?WT.mc_id=devto-blog-abhishgu)

When you [create an AKS cluster](https://docs.microsoft.com/azure/aks/kubernetes-walkthrough?WT.mc_id=devto-blog-abhishgu) as part of an [Azure resource group](https://docs.microsoft.com/azure/azure-resource-manager/management/overview?WT.mc_id=devto-blog-abhishgu#terminology), all it contains is the AKS cluster and not the other AKS components such as nodes (virtual machines) etc. These resources related to your AKS cluster are a part of a *different* resource group which is *automatically* created during deployment - this is known as the **Node Resource Group** 

> This often trips up folks who are new to AKS since they try to look for components in the original resource group where AKS was deployed

In addition to the nodes, virtual network and other resources which are part of the AKS cluster when its initially deployed, the node resource group can also host additional components. For example, if you [use a Persistent Volume claim with the default storage class](https://docs.microsoft.com/azure/aks/concepts-storage?WT.mc_id=devto-blog-abhishgu#persistent-volume-claims), AKS will provision an [Azure Disk](https://docs.microsoft.com/azure/virtual-machines/linux/managed-disks-overview?WT.mc_id=devto-blog-abhishgu), or, if you use a [`LoadBalancer` service](https://kubernetes.io/docs/concepts/services-networking/service/), AKS provisions an [Azure Load Balancer](https://docs.microsoft.com/azure/load-balancer/load-balancer-overview?WT.mc_id=devto-blog-abhishgu) behind the scenes.

The node resource group has a default naming convention, so it's not too hard to locate it. The format is - `MC_<AKS resource group>_<AKS cluster name>_<AKS region>` e.g. `MC_mygroup_myaks_southeastasia`. Say you wanted to list down the disks which back the Persistent Volumes in your AKS cluster, you can use the [`az disk list`](https://docs.microsoft.com/cli/azure/disk?view=azure-cli-latest&WT.mc_id=devto-blog-abhishgu#az-disk-list) command in the [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest&WT.mc_id=devto-blog-abhishgu) along with the name of the node resource group:

```
export AKS_CLUSTER_RESOURCE_GROUP=mygroup
export AKS_CLUSTER_NAME=myaks
export AKS_CLUSTER_REGION=southeastasia

az disk list --resource-group MC_${AKS_CLUSTER_RESOURCE_GROUP}_${AKS_CLUSTER_NAME}_${AKS_CLUSTER_REGION}
```

You can also choose to [provide a custom name of your choice](https://docs.microsoft.com/azure/aks/faq?WT.mc_id=devto-blog-abhishgu#can-i-provide-my-own-name-for-the-aks-node-resource-group) for the node resource group during the AKS cluster creation process. You can use the Azure CLI to query the name of this resource group using the [`az aks show`](https://docs.microsoft.com/cli/azure/aks?view=azure-cli-latest&WT.mc_id=devto-blog-abhishgu) command

```
AKS_NODE_RESOURCE_GROUP=$(az aks show --resource-group $AKS_CLUSTER_RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query nodeResourceGroup -o tsv)
```

Please note:

- Don't (manually) add unrelated components to the node resource group since its lifecycle is tightly coupled with the lifecycle of the AKS cluster itself i.e. the node resource is automatically deleted as soon as the AKS cluster is deleted
- [Please do not modify](https://docs.microsoft.com/azure/aks/faq?WT.mc_id=devto-blog-abhishgu#can-i-modify-tags-and-other-properties-of-the-aks-resources-in-the-node-resource-group) the properties of the resources in the node resource group

> Before wrapping up, have you checked out the [Applied Cloud Stories](https://aka.ms/applied-cloud-stories) initiative? It is an open call for technical content about relevant cloud scenarios and workloads, interesting challenges, and practical solutions that can run on Azure. You can participate by writing a new article, or recording a new video about the topic of your choice! 

> [You can send in your stories before March 15, 2020](https://forms.office.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR3gEboqOOXdAmlybbKuHqRhURVNQTzkwWjdHNTlIQTlVOEFIWjYxSzFMSy4u) 🙌 They will help inspire and educate engineers across the globe about how to approach advanced, innovative, and mission-critical cloud scenarios that are solving specific problems.


That's all for now. Stay tuned for more!

![](https://media.giphy.com/media/W0Vz7zDK7vgMBc2fpw/giphy.gif)