All Products
Search
Document Center

Elastic Container Instance:Reschedule pods that fail to be scheduled to elastic container instances

Last Updated:Feb 26, 2024

By default, pods created in Container Service for Kubernetes (ACK) clusters are scheduled to Elastic Compute Service (ECS) real nodes. If the computing resources of the ECS nodes are insufficient, the pods fail to be scheduled. To resolve the issue, you can deploy the virtual-kubelet-autoscaler plug-in in your ACK clusters. The plug-in automatically reschedules the pods that fail to be scheduled due to insufficient resources to virtual nodes. The pods run as elastic container instances, which improve the elasticity of your business.

Background information

virtual-kubelet-autoscaler is a Kubernetes Autoscaler plug-in provided by Alibaba Cloud. If pods fail to be scheduled to matched ECS real nodes, virtual-kubelet-autoscaler reschedules the failed pods to elastic container instances.

autoscaler

Prerequisites

An ACK cluster is created and an virtual node is deployed in the cluster. For more information, see Create an ACK managed cluster and Deploy the virtual node controller and use it to create Elastic Container Instance-based pods.

Deploy the virtual-kubelet-autoscaler plug-in

  1. Log on to the ACK console.

  2. In the left-side navigation pane, choose Marketplace > Marketplace.

  3. Find the ack-virtual-kubelet-autoscaler application and click the card of the application.

  4. In the upper-right corner of the details page, click Deploy.

  5. In the Deploy wizard, configure the basic information and parameters.

    1. In the Basic Information step, select a cluster and namespace, and specify a name for the release. Then, click Next.

    2. In the Parameters step, configure parameters based on your requirements and then click OK.

After the plug-in is deployed, in the left-side navigation pane of the management page of the cluster, choose Applications > Helm to view the release status of the application. If the status is Deployed, the application is deployed.

Test virtual-kubelet-autoscaler

Check usage of real node resources

Only if the computing resources on ECS real nodes are insufficient, virtual-kubelet-autoscaler automatically reschedules pods that failed to be scheduled to virtual nodes. Before you test virtual-kubelet-autoscaler, check whether the ECS real nodes on the Nodes page of the ACK cluster are insufficient.

  1. On the Clusters page of the ACK console, click the name of the cluster to go to the management page of the cluster.

  2. In the left-side navigation pane, choose Nodes > Nodes.

  3. View usage of node resources.

    In this topic, the following sample environment is used. You can use a different environment based on your cluster conditions.

    • Real node: one ECS node ecs.c7.xlarge whose specifications are 4 vCPUs and 8 GiB of memory. A Deployment is created on the ECS node. The CPU utilization is close to 100%.

    • Virtual node: one virtual node named virtual-kubelet-cn-beijing-g. No workload is deployed on the virtual node.

    节点调度.png

Create a Deployment on the virtual node to check the scheduling status of the pod

  1. Prepare a YAML file.

    vim deployment-autoscaler.yaml

    The following code provides the content of a sample deployment-autoscaler.yaml file. The Deployment contains four replicas and requests for computing resources of 2 vCPUs and 4 GiB memory for the containers of each replica.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-autoscaler
      labels:
        app: nginx
    spec:
      replicas: 4
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2
            ports:
            - containerPort: 80
            resources:
              requests:
                cpu: 2
                memory: 4Gi
  2. Create the Deployment.

    kubectl create -f deployment-autoscaler.yaml
  3. Check the status of the pods

    1. Check the status of the pods.

      kubectl get pods -o wide

      In the following sample command output, the pods that correspond to the Deployment run on the virtual node.

      autoscaler2

    2. View the event information about the pods to check the scheduling status of the pods.

      kubectl describe pod <pod-name>

      The following figure provides a sample command output. In the Events section, information indicates that virtual-kubelet-autoscaler scheduled the pods to the virtual node because computing resources on real nodes are insufficient.

      autoscaler3