Multiple Node Pools on Azure Kubernetes Service
Tags: linux, azure, kubernetes, beginners
Published: 2020-04-06 18:30:10

One of the most impressive parts of moving applications into the cloud is the ability to apply different types of computing power to your application based on use-case.  By taking advantage of all the different compute types within Azure, users access to various CPUs and GPUs that can be implemented. No upfront costs or concerns about racking the gear.  No fighting for better support with your vendor or having to buy the latest and greatest to keep up.  Azure provides you with a number of options to help implement these various compute options.

Different use cases will often require you to make decisions about what compute options you've selected.  How will they improve portions of your application for the business?  In this post we'll look at how you can use multiple types of compute options within a Kubernetes cluster in order to use different resources for different parts of their application.

### **Getting Started**

This is a post on understanding [Azure Kubernetes Service](https://docs.microsoft.com/azure/aks/?WT.mc_id=k8spool-devto-jagord) (AKS) node pools. This is a blog post that makes assumptions that you're done the Azure tutorials around fundamentals.  It will also assume you know how to create and use the Azure Kubernetes Service to launch a cluster.  

If you'd like to start with these, check out these Microsoft Learn Modules and blog posts:

[Microsoft Docs Learn Azure Fundamentals](https://docs.microsoft.com/learn/paths/azure-fundamentals/?WT.mc_id=k8spool-devto-jagord)

[Microsoft Docs Learn Introduction to Azure Kubernetes Service
](https://docs.microsoft.com/learn/modules/intro-to-azure-kubernetes-service/?WT.mc_id=k8spool-devto-jagord)

[Kubernetes Terminology for Beginners](https://dev.to/azure/kubernetes-terminology-for-beginners-2pdb)

[Azure Kubernetes Service - A Beginner's Guide.](https://dev.to/azure/azure-kubernetes-service-a-beginner-s-guide-mkc)

----

### **What's a node in Kubernetes?**

From the [official Kubernetes Docs](https://kubernetes.io/docs/concepts/architecture/nodes/)

>The Kubernetes node has the services necessary to run application containers and be managed from the master systems. A node is a worker machine in Kubernetes, previously known as a minion. A node may be a VM or physical machine, depending on the cluster. Each node contains the services necessary to run pods and is managed by the master components. The services on a node include the container runtime, kubelet and kube-proxy. See The Kubernetes Node section in the architecture design doc for more details._

It could be your local computer using [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/), a server in a datacenter or a virtual machine in the cloud.

---

### **What's a node pool?**

You can use different types of CPUs and storage with management for your AKS managed nodes.  A subset of VM's like hardware and configuration. Scale them based on your utilization.

From [Create and manage multiple node pools for a cluster in AKS](https://docs.microsoft.com/azure/aks/use-multiple-node-pools?WT.mc_id=k8spool-devto-jagord) on Microsoft docs website:

>In Azure Kubernetes Service (AKS), nodes of the same configuration are grouped together into node pools. These node pools contain the underlying VMs that run your applications. The initial number of nodes and their size (SKU) is defined when you create an AKS cluster, which creates a default node pool. To support applications that have different compute or storage demands, you can create additional node pools. For example, use these additional node pools to provide GPUs for compute-intensive applications, or access to high-performance SSD storage.

----

### **What's a GPU Optimized VM?:**

From [Microsoft docs](https://docs.microsoft.com/azure/virtual-machines/sizes-gpu?WT.mc_id=k8spool-devto-jagord): 

>GPU optimized VM sizes are specialized virtual machines available with single or multiple NVIDIA GPUs. These sizes are designed for compute-intensive, graphics-intensive, and visualization workloads.

----

### **Solving a problem**

![TWT](https://dev-to-uploads.s3.amazonaws.com/i/vngaunqmccfh0y5cwxwn.png)

### **Even Fake companies need help**

[Tailwind Traders](https://tailwindtraiders.com) is the world's biggest fake company with a reference app used for this and many other examples. You can review [this video from Azure Friday about the reference apps](https://www.youtube.com/watch?v=EP-PME-1tq0). You can also review the [application repository here](https://github.com/Microsoft/TailwindTraders-Website), it's open to the world to build with all the tools in this blog post.

![Application diagram](https://dev-to-uploads.s3.amazonaws.com/i/bhbas9wuh4corlzg1vcq.png)

The Tailwind Traders Website at its core is an e-commerce site with a number of extremely critical services that the company requires reliability and uptime in order to successfully execute new orders.  In order for Tailwind Traders to understand their customers better, much of the experience the user has is stored in a NoSQL database in [Azure Cosmos DB](https://docs.microsoft.com/azure/cosmos-db/introduction?WT.mc_id=k8spool-devto-jagord).  Cosmos provides Tailwind Traders with a low latency and high throughput database that works with the MongoDB API. Daily, reports on this information are run and delivered into a web presentable front end.   

The reports app uses a number of algorithms that the data science team at Tailwind Traders developed along with the application engineer; these are extremely compute-intensive and seem to be taxing the capabilities of the more general-purpose CPU offerings in Azure. The Tailwind Traders engineering team recently looked at processing times of their daily reports for customer information and recognized that even though they were wise enough to architect their application into microservices, they felt that the return time of some reports (nearly 8-9 hours) had a potential of being reduced by utilizing GPUs available in Microsoft Azure.

Tailwind Traders will want to use standard CPUs for a portion of the web front end of my app. The company's CIO would like to have reports on their collected data processed quicker on GPUs in order for the business to best place the most popular and impressive products to potential customers based on data captured. The more information Tailwind Traders is able to gain on their customer's experience, the more they can improve it.

### **Proposed Solution:**

![Create b2s cpu](https://dev-to-uploads.s3.amazonaws.com/i/j6kdih38yfwphk5n7krt.gif)

TWT's team will build an AKS cluster with multiple node pools. The two pools will contain different types of computing power to handle the microserviced application workloads. 

To begin, the team will create a new cluster for AKS, in this case, `nodepool01` that will handle the web app front end using a [Bs2 series VM](https://docs.microsoft.com/azure/virtual-machines/sizes-b-series-burstable?WT.mc_id=k8spool-devto-jagord) for the node pool. 

You can also create node pools and specify your specific CPU type with `az cli` tool rather than do so by the portal:

```
# Create a resource group in East US
az group create --name myResourceGroup --location eastus

# Create a basic single-node AKS cluster
az aks create \
    --resource-group myResourceGroup \
    --name cluster01 \
    --vm-set-type VirtualMachineScaleSets \
    --node-count 2 \
    --generate-ssh-keys \
    --kubernetes-version 1.15.7 \
    --load-balancer-sku standard

# Add a node pool to the cluster

az aks nodepool add \
    --resource-group myResourceGroup \
    --cluster-name cluster01 \
    --name nodepool02 \
    --node-count 3 \
    --kubernetes-version 1.15.7
```
 
This cluster will use B-series burstable VMs which are ideal for workloads that do not need the full performance of the CPU continuously, like web servers, small databases and development and test environments - exactly the solution for a web front end service and its required components such as a [load balancer](https://docs.microsoft.com/azure/aks/static-ip?WT.mc_id=k8spool-devto-jagord).

The TWT team chose to create a secondary node pool `nodepool02` that will handle my GPU intensive workloads, such as processing data for reports that are used to improve customer experience.  The secondary node pool is created using a [NC6s_v2 class virtual machine](https://docs.microsoft.com/azure/virtual-machines/sizes-gpu?WT.mc_id=k8spool-devto-jagord).

![gpu node pool](https://dev-to-uploads.s3.amazonaws.com/i/fc4wascj4k8rvaz1zf33.gif)

The TWT tech team next can create a node pool using the az aks node pool add command again. This time, specify the name `nodepool02`, and use the `--node-vm-size` parameter to specify the Standard_NC6 size:

```
az aks nodepool add \
    --resource-group myResourceGroup \
    --cluster-name myAKSCluster \
    --name nodepool02 \
    --node-count 1 \
    --node-vm-size Standard_NC6 \
    --no-wait
```

The TWT team can begin assigning specific pods to nodes by [scheduling pods using taints and tolerations](https://docs.microsoft.com/azure/aks/use-multiple-node-pools?WT.mc_id=k8spool-devto-jagord#schedule-pods-using-taints-and-tolerations).

By providing a dedicates pool of GPU backed nodes, TWT will now be able to run their reports using the power of single or multiple NVIDIA GPUs.  

### **More Info**

There's more documentation available to you to find out the best way to implement node pools with AKS.  Check out the different links and videos provided before so you can begin using this powerful option for those who want to diversify compute options within their AKS cluster.

### **Resources**

[Microsoft Docs: az aks nodepool](https://docs.microsoft.com/cli/azure/ext/aks-preview/aks/nodepool?view=azure-cli-latest&WT.mc_id=k8spool-devto-jagord)
[Create and manage multiple node pools for a cluster in Azure Kubernetes Service (AKS)](https://docs.microsoft.com/azure/aks/use-multiple-node-pools?WT.mc_id=k8spool-devto-jagord)
[GitHub Actions for deploying to Kubernetes service](https://docs.microsoft.com/azure/aks/kubernetes-action?WT.mc_id=k8spool-devto-jagord)
[Azure Kubernetes Service (AKS)
](https://docs.microsoft.com/azure/aks/?WT.mc_id=k8spool-devto-jagord)


Multiple node pools in Azure Kubernetes Service (AKS) | [Azure Friday](https://azure.microsoft.com/resources/videos/azure-friday/?WT.mc_id=k8spool-devto-jagord)
{% youtube XHrlCJDDjS4 %}

Getting production ready in Kubernetes
{% youtube pg_P8T0OWpo %}

### **The Author**

![jay](https://dev-to-uploads.s3.amazonaws.com/i/hpdq4erfs392ivnzavpi.jpg)

If you're running into issues and need assistance with AKS or any other Azure service, reach out to me:

Twitter: [@jaydestro](https://twitter.com/jaydestro)
Twitch: [jaydestro](https://twitch.tv/jaydestro)
Github: [jaydestro](https://github.com/jaydestro)

I am always happy to hear from developers and engineers who are trying to implement new services to improve their experience for their customers.