This topic describes how to connect Elastic Container Instance (ECI) to a Container Service for Kubernetes cluster by installing a virtual node. An ECI serves as a pod in the Kubernetes cluster. If your Kubernetes cluster needs a scale-out, you can create ECIs on demand on the virtual node without the need to plan the computing capacity for the node. The ECIs can communicate with the existing pods in the Kubernetes cluster.

Overview

For more information about how virtual nodes work, see How Virtual Kubelet works. Virtual nodes are charged based on pods in the pay-as-you-go mode. For more information, see Billing.

Install a virtual node

Container Service for Kubernetes cluster

You can deploy Virtual Kubelet in a Container Service for Kubernetes cluster by installing the ack-virtual-node add-on.

Deploy Virtual Kubelet

  1. Log on to the Container Service console.
  2. In the left-side navigation pane, choose Marketplace > App Catalog. On the App Catalog page that appears, search for ack-virtual-node and click the card of the add-on that is found.
  3. On the App Catalog - ack-virtual-node page that appears, click the Parameters tab and set the parameters for deploying Virtual Kubelet.
    Parameter Description How to obtain the value
    ECI_ACCESS_KEY The AccessKey ID of your Alibaba Cloud account. For more information, see How can I obtain an AccessKey pair?
    ECI_SECRET_KEY The AccessKey secret of your Alibaba Cloud account. For more information, see How can I obtain an AccessKey pair?
    ALIYUN_CLUSTERID The ID of the Kubernetes cluster where Virtual Kubelet is to be deployed. Click the target cluster name on the Clusters page. On the Basic Information page that appears, copy the value of Cluster ID in the Basic Information section.
    ECI_REGION The ID of the region where the Kubernetes cluster resides. Click the target cluster name on the Clusters page. On the Basic Information page that appears, copy the value of Region in the Basic Information section.
    ECI_VPC The Virtual Private Cloud (VPC) where the Kubernetes cluster resides. Click the target cluster name on the Clusters page. On the Basic Information page that appears, copy the value of VPC in the Cluster Resources section.
    ECI_VSWITCH The default VSwitch to be used by Virtual Kubelet to create ECIs. Click a node ID on the Nodes page. On the Instance Details page that appears, copy the value of VSwitch in the Configuration Information section.
    ECI_SECURITY_GROUP The default security group to be used by Virtual Kubelet to create ECIs. Click a node ID on the Nodes page. Click Security Groups in the left-side navigation pane. Copy the value of Security Group ID for the corresponding security group on the Security Groups tab.
  4. In the Deploy pane on the right, select the target cluster and click Create. The Namespace and Release Name parameters are automatically set to kube-system and ack-virtual-node, respectively, which cannot be changed.

Verify the installation

Check the node list

After the virtual node is installed, choose Cluster > Nodes in the left-side navigation pane. Verify that the virtual-kubelet node appears on the Nodes page.

You can run the kubectl command to view the information about nodes.

$ kubectl get node
NAME                                STATUS   ROLES    AGE   VERSION
cn-beijing.192.168.0.238   Ready    <none>   66d    v1.14.6-aliyun.1
cn-beijing.192.168.0.239   Ready    <none>   66d    v1.14.6-aliyun.1
cn-beijing.192.168.0.240   Ready    <none>   66d    v1.14.6-aliyun.
virtual-kubelet                   Ready    agent       19d    v1.11.2	

Schedule pods to the virtual node

After the virtual node is installed, you can schedule pods to the virtual node. Virtual Kubelet automatically creates the corresponding ECIs.

  1. In the Container Service console, choose Applications > Deployments in the left-side navigation pane. On the Deployments page that appears, select the target cluster and namespace, and click Create from Template in the upper-right corner.
  2. Select a sample template or Custom from the Sample Template drop-down list, and click Create. For example, you can create a deployment by using the following YAML file:
    apiVersion: apps/v1beta2 # For versions earlier than 1.8.0, use apps/v1beta1.
    kind: Deployment
    metadata:
      name: nginx-deployment-basic
      labels:
        app: nginx
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            imagePullPolicy: Always
          nodeName: virtual-node-eci-0 # The name of the virtual node.
  3. On the Deployments page, verify that the deployment appears in the deployment list, as shown in the following figure.
  4. In the left-side navigation pane, choose Applications > Pods. If the page shown in the following figure appears, the pods are scheduled to the virtual node.

Schedule pods to a virtual node

If a virtual node exists in your Kubernetes cluster, you can schedule pods to the virtual node. Virtual Kubelet automatically creates the corresponding ECIs. You can schedule a pod to the virtual node in one of the following ways:

  • Add a label to the namespace to which the pod belongs.
  • Add a label to the pod.

For more information about how to use virtual nodes, see Virtual nodes.