You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/aks/spot-node-pool.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,20 +5,19 @@ ms.topic: article
5
5
ms.date: 03/29/2023
6
6
author: schaffererin
7
7
ms.author: schaffererin
8
-
9
8
ms.subservice: aks-nodes
10
9
#Customer intent: As a cluster operator or developer, I want to learn how to add an Azure Spot node pool to an AKS Cluster.
11
10
---
12
11
13
12
# Add an Azure Spot node pool to an Azure Kubernetes Service (AKS) cluster
14
13
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.
16
15
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.
18
17
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.
20
19
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.
22
21
23
22
## Before you begin
24
23
@@ -32,18 +31,18 @@ In this article, you add a secondary Spot node pool to an existing Azure Kuberne
32
31
The following limitations apply when you create and manage AKS clusters with a Spot node pool:
33
32
34
33
* 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.
36
35
* A Spot node pool must use Virtual Machine Scale Sets.
37
36
* You can't change `ScaleSetPriority` or `SpotMaxPrice` after creation.
38
37
* 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.
40
39
* You must add a [corresponding toleration][spot-toleration] and affinity to schedule workloads on a Spot node pool.
41
40
42
41
## Add a Spot node pool to an AKS cluster
43
42
44
43
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].
45
44
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.
47
46
48
47
```azurecli-interactive
49
48
az aks nodepool add \
@@ -68,19 +67,19 @@ The previous command also enables the [cluster autoscaler][cluster-autoscaler],
68
67
> [!IMPORTANT]
69
68
> 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.
70
69
71
-
### Verify the Spot node pool
70
+
## Verify the Spot node pool
72
71
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`.
74
73
75
-
```azurecli
74
+
```azurecli-interactive
76
75
az aks nodepool show --resource-group myResourceGroup --cluster-name myAKSCluster --name spotnodepool
77
76
```
78
77
79
-
### Schedule a pod to run on the Spot node
78
+
## Schedule a pod to run on the Spot node
80
79
81
80
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.
82
81
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:
84
83
85
84
```yaml
86
85
spec:
@@ -100,10 +99,22 @@ spec:
100
99
operator: In
101
100
values:
102
101
- "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
104
110
```
105
111
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).
0 commit comments