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/best-practices-app-cluster-reliability.md
+20-46Lines changed: 20 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,9 @@ title: Deployment and cluster reliability best practices for Azure Kubernetes Se
3
3
titleSuffix: Azure Kubernetes Service
4
4
description: Learn the best practices for deployment and cluster reliability for Azure Kubernetes Service (AKS) workloads.
5
5
ms.topic: conceptual
6
-
ms.date: 03/11/2024
6
+
ms.date: 04/22/2024
7
7
author: schaffererin
8
8
ms.author: schaffererin
9
-
10
9
---
11
10
12
11
# Deployment and cluster reliability best practices for Azure Kubernetes Service (AKS)
@@ -17,7 +16,7 @@ The best practices in this article are organized into the following categories:
17
16
18
17
| Category | Best practices |
19
18
| -------- | -------------- |
20
-
|[Deployment level best practices](#deployment-level-best-practices)| • [Pod Disruption Budgets (PDBs)](#pod-disruption-budgets-pdbs) <br/> • [Pod CPU and memory limits](#pod-cpu-and-memory-limits) <br/> • [Pre-stop hooks](#pre-stop-hooks) <br/> • [maxUnavailable](#maxunavailable) <br/> • [Pod anti-affinity](#pod-anti-affinity) <br/> • [Readiness, liveness, and startup probes](#readiness-liveness-and-startup-probes) <br/> • [Multi-replica applications](#multi-replica-applications)|
19
+
|[Deployment level best practices](#deployment-level-best-practices)| • [Pod Disruption Budgets (PDBs)](#pod-disruption-budgets-pdbs) <br/> • [Pod CPU and memory limits](#pod-cpu-and-memory-limits) <br/> • [Pre-stop hooks](#pre-stop-hooks) <br/> • [maxUnavailable](#maxunavailable) <br/> • [Pod topology spread constraints](#pod-topology-spread-constraints) <br/> • [Readiness, liveness, and startup probes](#readiness-liveness-and-startup-probes) <br/> • [Multi-replica applications](#multi-replica-applications)|
21
20
|[Cluster and node pool level best practices](#cluster-and-node-pool-level-best-practices)| • [Availability zones](#availability-zones) <br/> • [Cluster autoscaling](#cluster-autoscaling) <br/> • [Standard Load Balancer](#standard-load-balancer) <br/> • [System node pools](#system-node-pools) <br/> • [Accelerated Networking](#accelerated-networking) <br/> • [Image versions](#image-versions) <br/> • [Azure CNI for dynamic IP allocation](#azure-cni-for-dynamic-ip-allocation) <br/> • [v5 SKU VMs](#v5-sku-vms) <br/> • [Do *not* use B series VMs](#do-not-use-b-series-vms) <br/> • [Premium Disks](#premium-disks) <br/> • [Container Insights](#container-insights) <br/> • [Azure Policy](#azure-policy)|
22
21
23
22
## Deployment level best practices
@@ -178,60 +177,35 @@ spec:
178
177
179
178
For more information, see [Max Unavailable](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#max-unavailable).
180
179
181
-
### Pod anti-affinity
180
+
### Pod topology spread constraints
182
181
183
182
> **Best practice guidance**
184
183
>
185
-
> Use pod anti-affinity to ensure that pods are spread across nodes for node-down scenarios.
184
+
> Use pod topology spread constraints to ensure that pods are spread across different nodes or zones to improve availability and reliability.
186
185
187
-
You can use the `nodeSelector` field in your pod specification to specify the node labels you want the target node to have. Kubernetes only schedules the pod onto nodes that have the specified labels. Anti-affinity expands the types of constraints you can define and gives you more control over the selection logic. Anti-affinity allows you to constrain pods against labels on other pods.
186
+
You can use pod topology spread constraints to control how pods are spread across your cluster based on the topology of the nodes and spread pods across different nodes or zones to improve availability and reliability.
188
187
189
-
The following example pod definition file shows how to use pod anti-affinity to ensure that pods are spread across nodes:
188
+
The following example pod definition file shows how to use the `topologySpreadConstraints` field to spread pods across different nodes:
190
189
191
190
```yaml
192
-
apiVersion: apps/v1
193
-
kind: Deployment
191
+
apiVersion: v1
192
+
kind: Pod
194
193
metadata:
195
-
name: multi-zone-deployment
196
-
labels:
197
-
app: myapp
194
+
name: example-pod
198
195
spec:
199
-
replicas: 3
200
-
selector:
201
-
matchLabels:
202
-
app: myapp
203
-
template:
204
-
metadata:
205
-
labels:
206
-
app: myapp
207
-
spec:
208
-
containers:
209
-
- name: myapp-container
210
-
image: nginx
211
-
ports:
212
-
- containerPort: 80
213
-
affinity:
214
-
podAntiAffinity:
215
-
requiredDuringSchedulingIgnoredDuringExecution:
216
-
- labelSelector:
217
-
matchExpressions:
218
-
- key: app
219
-
operator: In
220
-
values:
221
-
- myapp
222
-
topologyKey: topology.kubernetes.io/zone
196
+
# Configure a topology spread constraint
197
+
topologySpreadConstraints:
198
+
- maxSkew: <integer>
199
+
minDomains: <integer> # optional
200
+
topologyKey: <string>
201
+
whenUnsatisfiable: <string>
202
+
labelSelector: <object>
203
+
matchLabelKeys: <list> # optional
204
+
nodeAffinityPolicy: [Honor|Ignore] # optional
205
+
nodeTaintsPolicy: [Honor|Ignore] # optional
223
206
```
224
207
225
-
For more information, see [Affinity and anti-affinity in Kubernetes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity).
226
-
227
-
> [!TIP]
228
-
> Use pod anti-affinity across availability zones to ensure that pods are spread across availability zones for zone-down scenarios.
229
-
>
230
-
> You can think of availability zones as backups for your application. If one zone goes down, your application can continue to run in another zone. You use affinity and anti-affinity rules to schedule specific pods on specific nodes. For example, let's say you have a memory/CPU-intensive pod, you might want to schedule it on a larger VM SKU to give the pod the capacity it needs to run.
231
-
>
232
-
> When you deploy your application across multiple availability zones, you can use pod anti-affinity to ensure that pods are spread across availability zones. This practice helps ensure that your application remains available in the event of a zone-down scenario.
233
-
>
234
-
> For more information, see [Best practices for multiple zones](https://kubernetes.io/docs/setup/best-practices/multiple-zones/) and [Overview of availability zones for AKS clusters](./availability-zones.md#overview-of-availability-zones-for-aks-clusters).
208
+
For more information, see [Pod Topology Spread Constraints](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/).
0 commit comments