Virtual nodes enable seamless integration between Kubernetes and Elastic Container Instance. Virtual nodes empower Kubernetes clusters with high elasticity. This way, Kubernetes clusters are no longer limited by the computing capacity of cluster nodes. You can create Elastic Container Instance-based pods as needed to avoid the planning of cluster capacity. This topic describes virtual nodes and elastic container instances. It also describes how to deploy the virtual node controller (ack-virtual-node) and use it to create Elastic Container Instance-based pods.
Prerequisites
- A Container Service for Kubernetes (ACK) managed or ACK dedicated cluster is created and the Kubernetes version of the cluster is 1.16 or later. For more information about how to create an ACK managed or ACK dedicated cluster, see Create an ACK managed cluster or Create an ACK dedicated cluster. Note If you want to use an ACK Pro cluster, refer to Use Elastic Container Instance-based scheduling.
- Elastic Container Instance is activated. You can log on to the Elastic Container Instance console to activate the service.
- The region where the cluster is deployed is supported by Elastic Container Instance. To view the supported regions and zones, log on to the Elastic Container Instance console.
Virtual nodes and elastic container instances
Elastic Container Instance is a serverless compute service that is provided by Alibaba Cloud for containerization. You can use elastic container instances to set up an O&M-free and isolated runtime environment for your containers. Elastic container instances allow you to focus on containerized applications without the need to purchase or manage Elastic Compute Service (ECS) instances. This way, you do not need to perform infrastructure maintenance. You can create elastic container instances to meet your business requirements. You are charged for resource usage on a per second basis.
- Online business that requires elastic scaling to handle traffic fluctuations, such as online education and e-commerce. Virtual nodes optimize the maintenance of resource pools. This helps you reduce computing costs.
- Virtual nodes can reduce costs in computing scenarios where Spark or Presto is used to process data.
- Continuous integration and continuous delivery (CI/CD) pipeline: Jenkins and GitLab Runner.
- Jobs: Jobs in AI computing scenarios and CronJobs.

Step 1: Deploy ack-virtual-node in ACK clusters
- The virtual node controller ack-virtual-node is managed by ASK clusters. Therefore, you can create Elastic Container Instance-based pods in ASK clusters without the need to deploy ack-virtual-node. In ACK managed clusters or ACK dedicated clusters, you must deploy ack-virtual-node before you can create Elastic Container Instance-based pods.
- In ACK managed clusters, you can deploy ack-virtual-node on the Add-ons page of the console. By default, ack-virtual-node is managed by the clusters after it is deployed.
- In ACK dedicated clusters, you can deploy ack-virtual-node on the Marketplace page of the console. By default, ack-virtual-node is managed by the clusters after it is deployed.
Perform the following steps to deploy ack-virtual-node in an ACK managed cluster:
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- 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.
- In the left-side navigation pane of the details page, choose .
- On the Add-ons page, select ack-virtual-node and click Install. The default vSwitch and security group of the cluster are used for elastic container instances that are deployed by ack-virtual-node. If you want to modify these settings, see Related operations.
Perform the following steps to deploy ack-virtual-node in an ACK dedicated cluster.
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, choose .
- On the Marketplace page, click the App Catalog tab. Find and click ack-virtual-node.
- On the ack-virtual-node page, click Deploy.
- In the Deploy wizard, select a cluster and namespace, and then click Next. Namespace is automatically set to kube-system. Release Name is automatically set to ack-virtual-node.
- On the Parameters wizard page, set the parameters, configure the virtual node, and then click OK.
Parameter Description How to obtain the value ALIYUN_CLUSTERID The ID of the cluster. Go to the details page of the cluster. Click the Basic Information tab. In the Basic Information section, you can view the cluster ID. ALIYUN_RESOURCEGROUP_ID The ID of the resource group. If you do not specify this parameter, the default resource group is used. To specify a resource group, log on to the Resource Management console to obtain the ID of the resource group that you want to use. ECI_REGION The ID of the region. Go to the details page of the cluster. Click the Basic Information tab. In the Basic Information section, you can view the region where the cluster is deployed. Note For example, cn-hangzhou indicates the China (Hangzhou) region.ECI_VSWITCH The vSwitches. On the Nodes page, click the ID of a node. On the instance details page, you can obtain the value of vSwitch in the Configuration Information section. NoteMake sure that the zone of the vSwitch is supported by Elastic Container Instance.
You can specify vSwitches that are deployed in different zones. For example, you can specify multiple vSwitches in the format of
ECI_VSWITCH: "vsw-xxxxxxx1, vsw-xxxxxxx2, vsw-xxxxxxx3"
.ECI_SECURITY_GROUP The ID of the security group. On the Nodes page, click the ID of a node. On the instance details page, click the Security Groups tab. In the Security Groups section, you can obtain the security group ID. ECI_ACCESS_KEY The AccessKey ID of your account. For more information, see Obtain an AccessKey pair. You must attach the AliyunECIFullAccess policy to your account in the Resource Access Management (RAM) console. For more information, see Grant permissions to RAM users.
ECI_SECRET_KEY The AccessKey secret of your account. For more information, see Obtain an AccessKey pair. You must attach the AliyunECIFullAccess policy to your account in the Resource Access Management (RAM) console. For more information, see Grant permissions to RAM users.
- Check the deployment progress of virtual-node-controller. For more information, see Use kubectl on Cloud Shell to manage ACK clusters.Run the following command to view the status of virtual-node-controller.
kubectl -n kube-system get deploy ack-virtual-node-controller
Expected output:
NAME READY AGE virtual-node-controller 1/1 1m
Step 2: Create Elastic Container Instance-based pods
- Add a label to the pod.
Add the
alibabacloud.com/eci=true
label to the pod that you want to create. Then, an Elastic Container Instance-based pod is created and scheduled to a virtual node. Examples:- Run the following command to add a label to the pod:
kubectl run nginx --image nginx -l alibabacloud.com/eci=true
- Run the following command to query the pod:
kubectl get pod -o wide|grep virtual-kubelet
Expected output:
nginx-7fc9f746b6-r4xgx 0/1 ContainerCreating 0 20s 192.168.XX.XX virtual-kubelet <none> <none>
- Run the following command to add a label to the pod:
- Add a label to the namespace to which the pod belongs.
Add the
alibabacloud.com/eci=true
label to the namespace to which the pod belongs. Then, an Elastic Container Instance-based pod is created and scheduled to a virtual node. Example:- Run the following command to create a namespace.
kubectl create ns vk
- Run the following command to add a label to the namespace to which the pod belongs:
kubectl label namespace vk alibabacloud.com/eci=true
- Run the following command to schedule the pod to a virtual node:
kubectl -n vk run nginx --image nginx
- Run the following command to query the pod:
kubectl -n vk get pod -o wide|grep virtual-kubelet
Expected output:
nginx-6f489b847d-vgj4d 1/1 Running 0 1m 192.168.XX.XX virtual-kubelet <none> <none>
- Run the following command to create a namespace.
Related operations
For more information, see Configure Elastic Container Instance Profile.
Delete virtual nodes in ACK clusters- Uninstall ack-virtual-node.
After you delete all Elastic Container Instance-based pods in an ACK managed cluster, uninstall ack-virtual-node on the Add-ons page.
After you delete all Elastic Container Instance-based pods in an ACK dedicated cluster, delete ack-virtual-node on the Helm page.
- Run the
kubectl delete node <node name>
to delete the virtual nodes that you do not need.Note If you do not delete the Elastic Container Instance-based pods in the cluster before you uninstall ack-virtual-node, the elastic container instances are retained in the cluster.