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.
The Elastic Container Instance-based scheduling feature is still supported and will be deprecated in later Kubernetes versions. You can use Kubernetes-native semantics to configure Elastic Container Instance-based auto scaling in later Kubernetes versions. For more information, see Configure Elastic Container Instance-based auto scaling.
The Elastic Container Instance-based scheduling feature is updated to the priority-based resource scheduling feature. Priority-based resource scheduling supports all use scenarios of Elastic Container Instance-based scheduling and provides higher flexibility.
We recommend that you use priority-based resource scheduling. Compared with Elastic Container Instance-based auto scaling, priority-based resource scheduling can delete pods from nodes in the reverse sequence without intrusion into application pods. For more information, see Configure priority-based resource scheduling.
Prerequisites
A Container Service for Kubernetes (ACK) Pro cluster that runs Kubernetes 1.18 or later is created. 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 version
Scheduler version
1.18
v1.18-ack-3.0 and later
1.20
v1.20.4-ack-4.0 and later
1.22
v1.22.3-ack-1.0 and later
1.24
v1.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 use the
alibabacloud.com/burst-resource: eci
annotation and thealibabacloud.com/fluid-sidecar-target: eci
annotation at the same time. For more information about how to use thealibabacloud.com/fluid-sidecar-target: eci
annotation, see Overview of data access in serverless cloud computing.
Procedure
Add an annotation to the template.metadata
field of a Deployment to specify the types of resources that you want to use. Valid values of alibabacloud.com/burst-resource
:
If the value is left empty, only existing ECS resources in the cluster are used. This is the default setting.
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.
If the value is not eci or eci_only, or the value is eci_only but no virtual node exists in the cluster, pods fail to be scheduled. In Kubernetes 1.22.15 and 1.24.6, one of the following error messages is returned based on the cause of the failure to schedule pods:
The value is not eci or eci_only:
requesttypemustbeeci,eci_onlyorecs
.The value is eci_only but no virtual node exists:
doesn'tfitecitype:eci_only
.
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 types 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
Run the following command to create pods that use Elastic Container Instance-based scheduling:
kubectl apply -f nginx-deployment.yaml