Deployment sets are used to manage the distribution of Elastic Compute Service (ECS) instances. ECS instances in a deployment set are distributed across multiple physical servers for high redundancy. This improves the availability of your applications. A node pool that is associated with a deployment set contains ECS nodes that are distributed across multiple physical servers. You can configure pod affinity to deploy your application pods to different ECS nodes. This way, disaster recovery is implemented and the availability of your applications is improved. This topic describes how to associate a deployment set with a node pool in the Container Service for Kubernetes (ACK) console and provides two use cases.

Prerequisites

  • A deployment set is created. For more information, see Create a deployment set.
  • The ECS quota of the deployment set is sufficient and sufficient ECS instances of the specified instance type are available. By default, each deployment set can contain up to 20 ECS instances in each zone. For more information, see View and increase resource quotas.

Background information

To ensure the high availability of your application in a zone, you must deploy your application across multiple hosts. However, when a physical server is down, all application pods are affected. To resolve this issue, you can use deployment sets that are provided by ECS. The ECS instances that are contained in a deployment set are distributed across multiple physical servers and are isolated from each other. This helps prevent service disruptions that are caused by single points of failure. For more information, see Overview.

Limits

  • You can associate only one deployment set with each node pool and you cannot change the deployment sets that are associated with node pools.
  • You cannot manually add ECS instances to or remove ECS instances from deployment sets. If you want to change the number of ECS instances in a deployment set, you can scale the node pool with which the deployment set is associated. For more information, see Modify the expected number of nodes in a node pool.
  • After you associate a deployment set with a node pool, the node pool does not support preemptible instances or dedicated hosts.
  • When you add ECS instances to a deployment set, you can create up to 20 ECS instances in each zone. This limit varies based on the usage of your ECS instances. You can use the following formula to calculate the maximum number of ECS instances that you can create in a region: 20 × Number of zones in the region. The number of zones in a region varies based on the vSwitches that you select for the node pool. You cannot manually increase the quota of ECS instances in the quota center. To request a quota increase, submit an application in Quota Center.
  • Deployment sets support ECS instances of the following instance families:
    • g8m, c7, g7, g7ne, r7, c6, g6, r6, c5, g5, r5, c6e, g6e, r6e, c7se, g7se, r7se, r6se, c7t, g7t, r7t, c7a, g7a, r7a, c6a, g6a, r6a, g5ne, re6, re6p, re4, and ic5
    • hfc7, hfg7, hfr7, hfc6, hfg6, hfr6, hfc5, and hfg5
    • d2s, d2c, d1, d1ne, d1-c14d3, and d1-c8d3
    • i3, i3g, i2, i2g, i2ne, i2gne, and i1
    • se1ne, sn1, sn1ne, sn2, sn2ne, and se1
    • ebmg5, sccgn6, scch5, sccg5, scch5s, and sccg5s
    • s6, t6, xn4, mn4, n2, n1, and n4
    • gn6i
    You can call the DescribeDeploymentSetSupportedInstanceTypeFamily API operation to query instance families that are supported by deployment sets.
  • If the quota of ECS instances is exhausted, requests to add ECS instances to deployment sets or restart pay-as-you-go ECS instances in economical mode are denied. To increase the quota of ECS instances, submit an application in Quota Center.

For more information about the limits and quotas of deployment sets, see Limits.

Associate a deployment set with a node pool in the ACK console

  1. Log on to the ACK console.
  2. In the left-side navigation pane of the ACK console, click Clusters.
  3. On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.
  4. In the left-side navigation pane of the details page, choose Nodes > Node Pools.
  5. In the upper-right corner of the Node Pools page, click Create Node Pool or Create Managed Node Pool.
  6. In the Create Node Pool or Create Managed Node Pool (Beta) dialog box, configure the parameters, specify a deployment set, and click Confirm Order.
    For more information about the parameters, see Create a node pool.deployment-set

Use cases

  • Use case 1: Your applications are deployed in the same node pool and pod anti-affinity is configured for pods that belong to the same application. Each node can host only one pod.

    This use case shows how to schedule three replicated pods in a Deployment to three different nodes.

    1. Create a node pool that contains three nodes and specify the ID of the deployment set that you want to associate with the node pool. Fore more information, see Associate a deployment set with a node pool in the ACK console.
      After you create the node pool, click the name of the node pool on the Node Pools page. The Nodes tab shows the nodes that are contained in the node pool. nodes
      Log on to the ECS console. In the left-side navigation pane, choose Deployment & Elasticity > Deployment Sets. The Deployment Sets page shows that the three nodes belong to the specified deployment set. deployment-set2
    2. Create a YAML file based on the following content.

      Deploy three pods and configure anti-affinity to schedule the pods to three different nodes.

      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:  #Configure the scheduling policy. 
                - labelSelector:
                    matchExpressions:
                    - key: app
                      operator: In
                      values:
                      - nginx
                  topologyKey: kubernetes.io/hostname
            nodeSelector:
                alibabacloud.com/nodepool-id: <nodepool-id>  #Specify the ID of the node pool. 
            containers:
            - name: nginx
              image: nginx
              resources:
                limits:
                  cpu: 1
                requests:
                  cpu: 1
      Execution results

      On the Deployments page, click the Deployment that you want to manage. The Pods tab shows that the pods are scheduled to three different nodes.

  • Use case 2: Your applications are deployed in the same node pool. Pods that belong to the same application can be scheduled to different nodes across multiple zones.
    1. Create a node pool that contains four nodes, specify the ID of the deployment set that you want to associate with the node pool, and select a vSwitch that is deployed across multiple zones. Fore more information, see Associate a deployment set with a node pool in the ACK console.

      After you create the node pool, four nodes and four zones are displayed on the Nodes page. ECS instances are deployed in four different zones and are added to the same deployment set based on the balanced distribution policy of auto scaling.

      Log on to the ECS console. In the left-side navigation pane, choose Deployment & Elasticity > Deployment Sets. The Deployment Sets page shows that the four nodes in the node pool belong to the specified deployment set.

    2. Create a YAML file based on the following content.

      You can use pod topology spread constraints to schedule pods that belong to the same application to different nodes across multiple zones. 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 the ID of the node pool. 
            containers:
            - name: nginx
              image: nginx
              resources:
                limits:
                  cpu: 1
                requests:
                  cpu: 1
      Execution results

      On the Deployments page, click the Deployment that you want to manage. The Pods tab shows that pods that belong to the same application are scheduled to different nodes across multiple zones.

Related topics

Use Terraform to associate a deployment set with a node pool