Best practices for deployment sets in node pools
A deployment set is a policy that controls the distribution of ECS instances. It spreads ECS instances across different physical servers to improve application high availability and underlying disaster recovery capabilities. By assigning a deployment set to a node pool, you ensure that ECS instances launched by the node pool are not placed on the same physical server. Combined with affinity configurations, your application becomes aware of the underlying node topology and distributes evenly across nodes, ensuring high availability and disaster recovery resilience.
Prerequisites
You have created a deployment set. For more information, see Create a deployment set.
Background information
Within the same zone, you typically deploy services across multiple hosts to ensure high availability. However, if one physical server fails, all replicas of your application on that server are affected. To address this, ECS provides deployment sets. All ECS instances in a deployment set are strictly distributed across different physical servers within a specified region, meeting the isolation requirements of application architectures and significantly reducing the risk of service unavailability. For more information about deployment sets, see Deployment set.
Limits
Feature usage notes in clusters
-
Deployment sets support only ACK managed clusters and ACK dedicated clusters.
-
You can assign a deployment set only when creating a new node pool. You cannot enable it for an existing node pool. Each node pool supports binding to only one deployment set.
-
You cannot manually add or remove nodes from a deployment set. Adjust the number of nodes in the deployment set by scaling the node pool. For more information, see Create and manage node pools.
-
After enabling deployment sets, you cannot create spot instances.
Deployment set quotas and specification limits
-
Deployment set quota limits:
-
Node pool deployment sets use the high availability strategy by default. Under this strategy, you can create up to 20 ECS instances per zone within a deployment set. The total number of ECS instances you can create in an Alibaba Cloud region is
20 × number of zones. Ensure sufficient ECS instance quotas and adequate inventory for your required instance types in the deployment set. For more information, see Deployment set.The maximum number of instances a deployment set can hold cannot be increased. However, to raise the maximum number of deployment sets allowed for your account, apply on the Quota Platform. For more information about deployment set limits and quotas, see Limits on deployment sets.
-
Creating ECS instances in a deployment set or restarting pay-as-you-go ECS instances (in economical mode) may fail due to insufficient inventory in the region. Wait a while and retry creating or restarting the instance.
-
Assign a deployment set to a node pool in the console
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
On the Node Pools page, click Create Node Pool. In the Create Node Pool dialog box, configure parameters, select a deployment set, and then click Confirm.
For details about node pool configuration items, see Create and manage node pools. After selecting a deployment set, the maximum number of nodes in the node pool becomes limited. Choose carefully. By default, a deployment set supports up to 20 × number of zones nodes. Ensure sufficient quotas in the deployment set to avoid node creation failures.
Use cases
Schedule pods of the same workload in a single node pool with pod anti-affinity so that only one pod runs per node
This example shows how to schedule three pod replicas from a Deployment onto three different nodes. Follow these steps.
-
Create a node pool with three nodes and assign a deployment set ID to it. For more information, see Assign a deployment set to a node pool in the console.
After creating the node pool, go to the Node Pools page, click the target node pool, and then view the three successfully created nodes on the Nodes tab. On the cluster’s Nodes tab, confirm that all three nodes are in the Ready state and distributed across different zones (Zone I and Zone J), matching the deployment set’s dispersion policy.
Log on to the ECS console. In the navigation pane on the left, select . On the Deployment Set page, verify that all three nodes in the node pool belong to the selected deployment set. On the Deployment Set product page, under Instance List, confirm that the three instances are distributed across Zone I and Zone J and are all in the Running state.
-
Use the following YAML to configure your application.
Configure pod anti-affinity to schedule the three application pods onto different nodes in the node pool.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: name: nginx labels: app: nginx spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: # Set scheduling policy. - labelSelector: matchExpressions: - key: app operator: In values: - nginx topologyKey: kubernetes.io/hostname nodeSelector: alibabacloud.com/nodepool-id: <nodepool-id> # Specify node pool ID. containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 resources: limits: cpu: 1 requests: cpu: 1Execution Result
On the Deployments page, click the target Deployment and go to the Pods tab. You will see the three pods scheduled onto different nodes in the node pool. All three nginx pods are successfully created and in the Running state, scheduled to different nodes (
cn-hangzhou.10.16.0.6,cn-hangzhou.10.240.56.81,cn-hangzhou.10.240.56.82), confirming that the pod anti-affinity policy is effective.
Distribute pods of the same workload evenly across zones and nodes within a single node pool
-
Create a node pool with four nodes, assign a deployment set ID to it, and select VSwitches in multiple zones. For more information, see Assign a deployment set to a node pool in the console.
After creation, go to the Node Pools page, click the target node pool, and view the four nodes on the Nodes tab. Four zones were selected. Based on ESS’s even distribution policy, the launched ECS instances are spread across four different zones and added to the deployment set. On the Nodes tab, the nodes appear in Zone K, H, I, and J, all in Ready state, with the ecs.g5ne.xlarge (4 vCPU 16 GiB, pay-as-you-go) specification.
Log on to the ECS console. In the navigation pane on the left, select . On the Deployment Set page, verify that all four nodes in the node pool belong to the selected deployment set.
-
Use the following YAML to configure your application.
Use pod topology spread constraints to evenly distribute pods of the same application across zones and nodes. For more information, see Pod topology spread constraints.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: app: nginx spec: replicas: 4 selector: matchLabels: app: nginx template: metadata: name: nginx labels: app: nginx spec: topologySpreadConstraints: - maxSkew: 1 topologyKey: kubernetes.io/hostname whenUnsatisfiable: DoNotSchedule labelSelector: matchLabels: app: nginx - maxSkew: 1 topologyKey: topology.kubernetes.io/zone whenUnsatisfiable: DoNotSchedule labelSelector: matchLabels: app: nginx nodeSelector: alibabacloud.com/nodepool-id: <nodepool-id> # Specify node pool ID. containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 resources: limits: cpu: 1 requests: cpu: 1Execution Result
On the Deployments page, click the target Deployment and go to the Pods tab. You will see that pods of the same application are evenly distributed across zones and nodes. After deployment, all four nginx pods on the Pods tab are in the Running state with zero restarts and are scheduled to different nodes, confirming that the pod topology spread constraints are effective.
References
-
You can also assign a deployment set to a node pool using Terraform.
-
For recommended configurations for highly available cluster architectures, see Recommended configurations for highly available cluster architectures.