All Products
Search
Document Center

Container Service for Kubernetes:Deploy the virtual node controller and use it to create Elastic Container Instance-based pods

Last Updated:Sep 01, 2023

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

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.

Virtual nodes can drastically reduce computing costs and improve scaling efficiency. Virtual nodes are suitable in the following scenarios:

  • 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.

ACK provides multiple serverless container services based on virtual nodes and elastic container instances. These services include ACK Serverless and ACK on Elastic Container Instance. You can use these services to deploy elastic and maintenance-free workloads. virtual node

Step 1: Deploy ack-virtual-node in ACK clusters

Note
  • The virtual node controller ack-virtual-node is managed by ACK Serverless clusters. Therefore, you can create Elastic Container Instance-based pods in ACK Serverless 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.

ACK managed clusters

Perform the following steps to deploy ack-virtual-node in an ACK managed cluster:

  1. Log on to the ACK console.

  2. In the left-side navigation pane of the ACK console, click Clusters.

  3. 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.

  4. In the left-side navigation pane of the details page, choose Operations > Add-ons.

  5. 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.

ACK dedicated Clusters

Perform the following steps to deploy ack-virtual-node in an ACK dedicated cluster.

  1. Log on to the ACK console.

  2. In the left-side navigation pane of the ACK console, choose Marketplace > App Catalog.

  3. On the Marketplace page, click the App Catalog tab. Find and click ack-virtual-node.

  4. On the ack-virtual-node page, click Deploy.

  5. 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.

  6. 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.

    Note

    Make 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.

  7. 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

Note

All pods in ACK Serverless clusters are deployed on elastic container instances. You do not need to add labels to the pods. Therefore, the following operations do not apply to ACK Serverless clusters. This topic describes how to create Elastic Container Instance-based pods in an ACK managed cluster.

You can use one of the following methods to create an Elastic Container Instance-based pod in an ACK managed cluster:

  • 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:

    1. Run the following command to add a label to the pod:

      kubectl run nginx --image nginx -l alibabacloud.com/eci=true
    2. 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>
  • 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:

    1. Run the following command to create a namespace.

      kubectl create ns vk
    2. Run the following command to add a label to the namespace to which the pod belongs:

      kubectl label namespace vk alibabacloud.com/eci=true
    3. Run the following command to schedule the pod to a virtual node:

      kubectl -n vk run nginx --image nginx
    4. 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>

Related operations

Note

The operations in this section do not apply to ACK Serverless clusters.

Modify the configurations of virtual nodes in an ACK cluster

For more information, see Configure Elastic Container Instance Profile.

Delete virtual nodes in ACK clusters

  1. 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.

  2. 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.