Microservices Deployment Strategies: Custom Scheduling
Assigning Your Workloads to Specific Nodes: Why?
Imagine you have 2 types of applications in your Kubernetes cluster:
- A web application: a frontend, an API, and a database.
- A machine learning application: a set of jobs that process large datasets, train models, and perform inference.
You created a cluster with two types of node pools:
- A standard node pool with 5 nodes, each having 4 vCPUs and 8 GB of RAM.
- A high-performance node pool with 3 nodes, each having 16 NVIDIA Tesla T4 GPUs, 32 vCPUs, and 128 GB of RAM.
If you have this setup in a cluster running on Google Cloud, you'd pay (approximately) the following monthly costs:
- Up to $1,500/month for the standard node pool.
- Up to $20,600/month for the high-performance node pool.
This pricing is a pay-as-you-go model based on the resources allocated to your nodes. The more you use, the more you pay.
In this scenario, it makes absolutely no sense to run the web application on the high-performance node pool and pay for what you don't need. Instead, you should force the web application to run only on the standard node pool. Kubernetes provides different mechanisms to achieve this goal. Some of them include taints and tolerations, nodeSelector, and node affinity.
Here are more common scenarios where these mechanisms can be useful:
Special hardware: Some applications require specific hardware capabilities, such as GPUs, TPUs, or SSD storage. In these cases, workloads must run on nodes equipped with the necessary hardware.
Licensing: Certain software licenses limit how many nodes can run a specific application. If a license restricts you to a single node, you must assign that workload to a specific node.
Compliance: Regulatory or organizational policies may require workloads to run on nodes located in specific regions or environments. For example, data residency laws might require workloads to stay within a certain country.
Data locality: If an application relies on accessing data stored locally on a node, running the workload on that same node can optimize data access and reduce latency.
Cloud-Native Microservices With Kubernetes - 2nd Edition
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in KubernetesEnroll now to unlock all content and receive all future updates for free.
