Run pods on ECI in an ACK managed cluster to handle traffic spikes without managing ECS instances.
Usage notes
For kube-scheduler v6.11.0 or later, when more than 1,000 ACS or ECI pods are created concurrently by adding labels, upgrade to the latest version and enable the SchedulerBatchMoveEvents=true feature gate.
Use cases
ECI pods handle traffic spikes and reduce compute costs:
-
Online services with fluctuating traffic patterns
Respond to traffic spikes faster, reduce resource pool maintenance, and lower compute costs.
-
Short-lived or batch computing tasks
No dedicated node maintenance required. Pay only for compute resources used during execution, reducing costs for workloads such as Spark and AI jobs.
Prerequisites
The ACK cluster runs Kubernetes 1.16 or later in a region that supports ECI.
Check supported regions in Regions and zones supported by ECI, then log on to the Elastic Container Instance console to activate ECI.
Procedure
Step 1: Deploy the ack-virtual-node component
The following steps use an ACK managed cluster as an example. For an ACK dedicated cluster, deploy ack-virtual-node from the Marketplace page. See Deploy the ack-virtual-node component.
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 Components and Add-ons.
On the Add-ons page, click the Core Components tab, find ACK Virtual Node, and then click Install. Follow the on-screen instructions to complete the installation.
During the installation, the default vSwitch and security group of the cluster are used as the initial ECI configuration parameters. To modify the parameters, you can update them by configuring an eci-profile.
Step 2: Schedule a pod to ECI
These examples schedule a pod to ECI by labeling the pod or namespace. See Schedule a Pod to a virtual node for other methods.
Pod
Add the label alibabacloud.com/eci: "true" to a pod to schedule it to an x86-architecture virtual node as an ECI pod.
-
Create a Deployment from the following YAML file.
kubectl create -f eci-pod.yamlExample
eci-pod.yaml:NoteThe
k8s.aliyun.com/eci-use-specsannotation specifies the ECI pod compute specification. See Specify the compute specification of an ECI pod.apiVersion: apps/v1 kind: Deployment metadata: name: test labels: app: test spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: name: test labels: app: nginx alibabacloud.com/eci: "true" # Add this label to schedule the Pod to ECI. annotations: k8s.aliyun.com/eci-use-specs: "2-4Gi" # Specify 2 vCPUs and 4 GiB of memory for the ECI pod. spec: containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 ports: - containerPort: 80 -
Verify that the Pod is running on a virtual node.
kubectl get pod -o wide -l app=nginxExpected output. The
NODEcolumn indicates the virtual node.NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES test-86f7fbc94f-g5m22 1/1 Running 0 38s 10.16.XX.XX virtual-kubelet-cn-hangzhou-j <none> <none> test-86f7fbc94f-r4wcn 1/1 Running 0 38s 10.16.XX.XX virtual-kubelet-cn-hangzhou-j <none> <none> -
View the details of the ECI pod.
kubectl get pod <pod-name> -o yamlCheck the
k8s.aliyun.com/eci-instance-idannotation for the ECI instance ID and thek8s.aliyun.com/eci-instance-specannotation for the compute specification used for billing.
Namespace
To run a category of pods on ECI, create a namespace and add the label alibabacloud.com/eci: "true". All pods in this namespace are scheduled to an x86-architecture virtual node as ECI pods.
-
Create a Namespace named
vkand add the required label to it.kubectl create ns vk kubectl label namespace vk alibabacloud.com/eci=true -
Create a Deployment in the
vknamespace.kubectl create -f eci-namespace.yamlExample
eci-namespace.yaml:NoteThe
k8s.aliyun.com/eci-use-specsannotation specifies the ECI pod compute specification. See Specify the compute specification of an ECI pod.apiVersion: apps/v1 kind: Deployment metadata: name: test namespace: vk # Specify the labeled Namespace to schedule Pods to ECI. labels: app: test spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: name: test labels: app: nginx annotations: k8s.aliyun.com/eci-use-specs: "2-4Gi" # Specify 2 vCPUs and 4 GiB of memory for the ECI pod. spec: containers: - name: nginx image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 ports: - containerPort: 80 -
Verify that the Pod is running on a virtual node.
kubectl get pod -o wide -l app=nginx -n vkExpected output. The
NODEcolumn indicates the virtual node.NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES test-8f54bcfb5-86pvc 1/1 Running 0 14s 10.16.XX.XX virtual-kubelet-cn-hangzhou-j <none> <none> test-8f54bcfb5-skvkg 1/1 Running 0 14s 10.16.XX.XX virtual-kubelet-cn-hangzhou-j <none> <none> -
View the details of the ECI pod.
kubectl get pod <pod-name> -o yaml -n vkCheck the
k8s.aliyun.com/eci-instance-idannotation for the ECI instance ID and thek8s.aliyun.com/eci-instance-specannotation for the compute specification used for billing.