Skip to content

Commit defe9c1

Browse files
Merge pull request #272232 from schaffererin/userstory245572
Added preferredDuringSchedulingIgnoredDuringExecution node affinity rule into pod yml example
2 parents 673c767 + 96de214 commit defe9c1

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

articles/aks/spot-node-pool.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ ms.topic: article
55
ms.date: 03/29/2023
66
author: schaffererin
77
ms.author: schaffererin
8-
98
ms.subservice: aks-nodes
109
#Customer intent: As a cluster operator or developer, I want to learn how to add an Azure Spot node pool to an AKS Cluster.
1110
---
1211

1312
# Add an Azure Spot node pool to an Azure Kubernetes Service (AKS) cluster
1413

15-
A Spot node pool is a node pool backed by an [Azure Spot Virtual machine scale set][vmss-spot]. With Spot VMs in your AKS cluster, you can take advantage of unutilized Azure capacity with significant cost savings. The amount of available unutilized capacity varies based on many factors, such as node size, region, and time of day.
14+
In this article, you add a secondary Spot node pool to an existing Azure Kubernetes Service (AKS) cluster.
1615

17-
When you deploy a Spot node pool, Azure allocates the Spot nodes if there's capacity available and deploys a Spot scale set that backs the Spot node pool in a single default domain. There's no SLA for the Spot nodes. There are no high availability guarantees. If Azure needs capacity back, the Azure infrastructure will evict the Spot nodes.
16+
A Spot node pool is a node pool backed by an [Azure Spot Virtual Machine scale set][vmss-spot]. With Spot VMs in your AKS cluster, you can take advantage of unutilized Azure capacity with significant cost savings. The amount of available unutilized capacity varies based on many factors, such as node size, region, and time of day.
1817

19-
Spot nodes are great for workloads that can handle interruptions, early terminations, or evictions. For example, workloads such as batch processing jobs, development and testing environments, and large compute workloads may be good candidates to schedule on a Spot node pool.
18+
When you deploy a Spot node pool, Azure allocates the Spot nodes if there's capacity available and deploys a Spot scale set that backs the Spot node pool in a single default domain. There's no SLA for the Spot nodes. There are no high availability guarantees. If Azure needs capacity back, the Azure infrastructure evicts the Spot nodes.
2019

21-
In this article, you add a secondary Spot node pool to an existing Azure Kubernetes Service (AKS) cluster.
20+
Spot nodes are great for workloads that can handle interruptions, early terminations, or evictions. For example, workloads such as batch processing jobs, development and testing environments, and large compute workloads might be good candidates to schedule on a Spot node pool.
2221

2322
## Before you begin
2423

@@ -32,18 +31,18 @@ In this article, you add a secondary Spot node pool to an existing Azure Kuberne
3231
The following limitations apply when you create and manage AKS clusters with a Spot node pool:
3332

3433
* A Spot node pool can't be a default node pool, it can only be used as a secondary pool.
35-
* The control plane and node pools can't be upgraded at the same time. You must upgrade them separately or remove the Spot node pool to upgrade the control plane and remaining node pools at the same time.
34+
* You can't upgrade the control plane and node pools at the same time. You must upgrade them separately or remove the Spot node pool to upgrade the control plane and remaining node pools at the same time.
3635
* A Spot node pool must use Virtual Machine Scale Sets.
3736
* You can't change `ScaleSetPriority` or `SpotMaxPrice` after creation.
3837
* When setting `SpotMaxPrice`, the value must be *-1* or a *positive value with up to five decimal places*.
39-
* A Spot node pool will have the `kubernetes.azure.com/scalesetpriority:spot` label, the taint `kubernetes.azure.com/scalesetpriority=spot:NoSchedule`, and the system pods will have anti-affinity.
38+
* A Spot node pool has the `kubernetes.azure.com/scalesetpriority:spot` label, the `kubernetes.azure.com/scalesetpriority=spot:NoSchedule` taint, and the system pods have anti-affinity.
4039
* You must add a [corresponding toleration][spot-toleration] and affinity to schedule workloads on a Spot node pool.
4140

4241
## Add a Spot node pool to an AKS cluster
4342

4443
When adding a Spot node pool to an existing cluster, it must be a cluster with multiple node pools enabled. When you create an AKS cluster with multiple node pools enabled, you create a node pool with a `priority` of `Regular` by default. To add a Spot node pool, you must specify `Spot` as the value for `priority`. For more details on creating an AKS cluster with multiple node pools, see [use multiple node pools][use-multiple-node-pools].
4544

46-
* Create a node pool with a `priority` of `Spot` using the [az aks nodepool add][az-aks-nodepool-add] command.
45+
* Create a node pool with a `priority` of `Spot` using the [`az aks nodepool add`][az-aks-nodepool-add] command.
4746

4847
```azurecli-interactive
4948
az aks nodepool add \
@@ -68,19 +67,19 @@ The previous command also enables the [cluster autoscaler][cluster-autoscaler],
6867
> [!IMPORTANT]
6968
> Only schedule workloads on Spot node pools that can handle interruptions, such as batch processing jobs and testing environments. We recommend you set up [taints and tolerations][taints-tolerations] on your Spot node pool to ensure that only workloads that can handle node evictions are scheduled on a Spot node pool. For example, the above command adds a taint of `kubernetes.azure.com/scalesetpriority=spot:NoSchedule`, so only pods with a corresponding toleration are scheduled on this node.
7069
71-
### Verify the Spot node pool
70+
## Verify the Spot node pool
7271
73-
* Verify your node pool has been added using the [`az aks nodepool show`][az-aks-nodepool-show] command and confirming the `scaleSetPriority` is `Spot`.
72+
* Verify your node pool was added using the [`az aks nodepool show`][az-aks-nodepool-show] command and confirming the `scaleSetPriority` is `Spot`.
7473
75-
```azurecli
74+
```azurecli-interactive
7675
az aks nodepool show --resource-group myResourceGroup --cluster-name myAKSCluster --name spotnodepool
7776
```
7877
79-
### Schedule a pod to run on the Spot node
78+
## Schedule a pod to run on the Spot node
8079
8180
To schedule a pod to run on a Spot node, you can add a toleration and node affinity that corresponds to the taint applied to your Spot node.
8281
83-
The following example shows a portion of a YAML file that defines a toleration corresponding to the `kubernetes.azure.com/scalesetpriority=spot:NoSchedule` taint and a node affinity corresponding to the `kubernetes.azure.com/scalesetpriority=spot` label used in the previous step.
82+
The following example shows a portion of a YAML file that defines a toleration corresponding to the `kubernetes.azure.com/scalesetpriority=spot:NoSchedule` taint and a node affinity corresponding to the `kubernetes.azure.com/scalesetpriority=spot` label used in the previous step with `requiredDuringSchedulingIgnoredDuringExecution` and `preferredDuringSchedulingIgnoredDuringExecution` node affinity rules:
8483
8584
```yaml
8685
spec:
@@ -100,10 +99,22 @@ spec:
10099
operator: In
101100
values:
102101
- "spot"
103-
...
102+
preferredDuringSchedulingIgnoredDuringExecution:
103+
- weight: 1
104+
preference:
105+
matchExpressions:
106+
- key: another-node-label-key
107+
operator: In
108+
values:
109+
- another-node-label-value
104110
```
105111

106-
When you deploy a pod with this toleration and node affinity, Kubernetes will successfully schedule the pod on the nodes with the taint and label applied.
112+
When you deploy a pod with this toleration and node affinity, Kubernetes successfully schedules the pod on the nodes with the taint and label applied. In this example, the following rules apply:
113+
114+
* The node *must* have a label with the key `kubernetes.azure.com/scalesetpriority`, and the value of that label *must* be `spot`.
115+
* The node *preferably* has a label with the key `another-node-label-key`, and the value of that label *must* be `another-node-label-value`.
116+
117+
For more information, see [Assigning pods to nodes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity).
107118

108119
## Upgrade a Spot node pool
109120

0 commit comments

Comments
 (0)