Elastic Container Instance-based scheduling is a scheduling policy that Alibaba Cloud provides for elastic resource scheduling. You can add annotations to specify the resources that you want to use when you deploy applications. You can specify that only Elastic Compute Service (ECS) instances or elastic container instances are used, or enable the system to request elastic container instances when ECS resources are insufficient. Elastic Container Instance-based scheduling can meet your resource requirements in different workload scenarios. This topic describes how to use Elastic Container Instance-based scheduling.

Prerequisites

  • An Container Service for Kubernetes (ACK) Pro cluster is created and the Kubernetes version is 1.18 or later. For more information, see Create an ACK Pro cluster.
  • Specific versions of the scheduler are required based on the Kubernetes version of the cluster. The following table describes the scheduler versions that are required for each Kubernetes version. For more information about the features of different versions of the scheduler, see kube-scheduler.
    Kubernetes versionScheduler version
    1.18v1.18-ack-3.0 and later
    1.20v1.20.4-ack-4.0 and later
    1.22v1.22.3-ack-1.0 and later
    1.24v1.24.3-ack-2.0 and later
  • The ack-virtual-node component is installed in the cluster. For more information, see Use Elastic Container Instance in ACK clusters.
  • You cannot specify the alibabacloud.com/burst-resource: eci and alibabacloud.com/fluid-sidecar-target: eci annotations at the same time. For more information about how to use the alibabacloud.com/fluid-sidecar-target: eci annotation, see Overview of data access in serverless cloud computing.

Procedure

Note You can specify the type of elastic resources that you want to use in the annotations parameter in the template.metadata section of the Deployment configuration. The alibabacloud.com/burst-resource annotation can be set to one of the following values:
  • If the value is left empty, only existing ECS resources in the cluster are used. This is the default value.
  • eci: Elastic container instances are used when the ECS resources in the cluster are insufficient.
  • eci_only: Only elastic container instances are used. The ECS resources in the cluster are not used.
  1. Create a file named nginx-deployment.yaml and copy the following content to the file:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      replicas: 4
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          name: nginx
          annotations:
            alibabacloud.com/burst-resource: eci # Specify the type of resources that you want to use for elastic scheduling. 
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            resources:
              limits:
                cpu: 2
              requests:
                cpu: 2
  2. Run the following command to create pods that run on elastic container instances:
    kubectl apply -f nginx-deployment.yaml