Kubernetes versions 1.18 to 1.24 retain the elastic scheduling capability in Elastic Container Instance (ECI). Since May 2023, Container Service for Kubernetes (ACK) has discontinued maintenance of this feature for clusters running Kubernetes v1.24 or later. Use one of the following alternatives instead:
-
Configure resource allocation based on ECS instances and elastic container instances: Enforce ECI-only, ECS-only, or ECS-preferred scheduling using Kubernetes-native taints, tolerations, and node affinity.
-
Configure priority-based resource scheduling: Use ResourcePolicy for advanced strategies, including priority-based scheduling across subscription ECS, pay-as-you-go ECS, and ECI; reverse-order scale-down; and non-intrusive pod migration.
For a comparison of virtual node scheduling solutions, see Schedule a pod to a virtual node.
Elastic Container Instance-based scheduling lets you control which compute backend runs your pods by adding a single annotation to pod metadata. Depending on the annotation value, pods run exclusively on Elastic Compute Service (ECS) nodes, exclusively on elastic container instances, or on elastic container instances only when ECS capacity in the cluster is exhausted.
Prerequisites
Before you begin, ensure that you have:
-
An ACK managed Pro cluster
-
A supported scheduler version for your Kubernetes version: For details on scheduler versions, see kube-scheduler.
Kubernetes version Minimum scheduler version 1.18 v1.18-ack-3.0 1.20 v1.20.4-ack-4.0 1.22 v1.22.3-ack-1.0 1.24 v1.24.3-ack-2.0 -
The
ack-virtual-nodecomponent deployed in the cluster. For setup instructions, see Schedule pods to elastic container instances through virtual nodes.
Configure the scheduling mode
Add the alibabacloud.com/burst-resource annotation to the pod's metadata section. For a Deployment, place the annotation under spec.template.metadata.
The following table summarizes how each annotation value affects scheduling behavior:
| Annotation value | Scheduling behavior | Requires virtual node | Fails if |
|---|---|---|---|
| *(not set)* | Uses only existing ECS nodes in the cluster (default) | No | — |
eci |
Uses ECS nodes first; falls back to ECI when ECS capacity is insufficient | — | — |
eci_only |
Uses only ECI; ECS nodes are never used | Yes | No virtual node exists in the cluster |
| Any other value | — | — | Always fails; invalid value |
alibabacloud.com/burst-resource: eci conflicts with alibabacloud.com/fluid-sidecar-target: eci. For usage examples of alibabacloud.com/fluid-sidecar-target, see Accelerate data access in serverless cloud computing and related topics.
Apply the annotation
-
Create a file named
nginx-deployment.yamlwith the following content: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 # Fall back to ECI when ECS capacity is insufficient labels: app: nginx spec: containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 resources: limits: cpu: 2 requests: cpu: 2 -
Apply the manifest:
kubectl apply -f nginx-deployment.yaml
Failure scenarios
Pod scheduling fails in the following situations:
-
The annotation value is not
ecioreci_only. The PodStatus message isrequesttypemustbeeci,eci_onlyorecs(Kubernetes v1.22.15 and v1.24.6). -
The annotation value is
eci_onlybut no virtual node exists in the cluster. The PodStatus message isdoesn'tfitecitype:eci_only(Kubernetes v1.22.15 and v1.24.6).