Help Center> Cloud Container Engine> Best Practices> Auto Scaling> Elastic Scaling of CCE Pods to CCI

Elastic Scaling of CCE Pods to CCI

The virtual-kubelet add-on is an implementation of the open-source Virtual Kubelet project. When momentary traffic spikes occur in CCE clusters, virtual-kubelet uses HUAWEI CLOUD CCI to create pods for Deployments, StatefulSets, and jobs, eliminating the overhead of resizing CCE clusters.

The virtual-kubelet add-on provides the following functions:

  • Creates pods automatically in seconds. When CCE cluster resources are insufficient, you do not need to add nodes to the cluster. virtual-kubelet automatically creates pods in CCI for you to run workloads in CCE.
  • Seamlessly works with HUAWEI CLOUD SWR for you to use public and private images.
  • Supports event synchronization, monitoring, logging, remote command execution, and status query for CCI pods.
  • Allows you to view the capacity information about virtual elastic nodes.
  • Supports connectivity between CCE and CCI pods through Services.

Constraints and Limitations

  • Only CCE clusters that use the VPC network model are supported.
  • CCE pods that are scheduled to CCI must be using ConfigMap, Secret, emptyDir, SFS, and SFS Turbo volumes. Subpath is not supported for emptyDir.
  • DaemonSets and pods that use the HostNetwork mode cannot be scheduled to CCI.
  • Pods deployed across CCE and CCI can only communicate through ClusterIP Services.
  • The subnet where the cluster is located cannot overlap with 10.247.0.0/16. Otherwise, the subnet conflicts with the Service CIDR block in the CCI namespace.
  • Before using virtual-kubelet, go to the CCI console to apply for the permission to use CCI.
  • After the virtual-kubelet add-on is installed, a namespace named "cce-burst-cluster ID" is created in CCI and managed by the add-on. Do not use this namespace when manually creating pods in CCI.
  • Pods scheduled to CCI must meet the requirements listed in pod specifications of CCI.
    1. When an add-on earlier than v1.2.5 is used, the value of Requests of each container must be equal to that of Limits. (For an add-on of v1.2.5 or later, the two values can be different. When pods are scaled to CCI, the two values are automatically adjusted to the same. If Limits is configured, the value of Limits is used. If Limits is not configured, the value of Requests is used.)
    2. In a pod, the number of CPUs is greater than 0 for at least one container.
    3. After auto adjustment, the number of CPU cores in a pod cannot exceed 32, and the memory size cannot exceed 256 GiB.

Installing virtual-kubelet on a CCE Cluster

Create a cluster

  • Cluster type: CCE cluster
  • Cluster version: v1.11 or later
  • Region: CN East-Shanghai1 or CN North-Beijing4
  • Network model: VPC network

Install the add-on

  1. Log in to the CCE console. In the navigation pane, choose Add-ons. On the Add-on Marketplace tab page, click Install Add-on under virtual-kubelet.
  2. On the Install Add-on page, select the cluster and the add-on version, and click Next: Configuration.
  3. In the Configuration step, select Cross-Service Access to enable pods in the CCE cluster to communicate with pods in CCI by using a Kubernetes Service.

  4. Click Install.

    After the add-on is installed, click Back to Add-on List. On the Add-on Instance tab page, select the corresponding cluster to view the running instance. This indicates that the add-on has been installed on each node in the cluster.

Creating a Workload on the CCE Console

  1. On the CCE console, choose Workloads in the navigation pane.
  2. In the Specify Basic Info step of creating a Deployment or Job, select Elastic Scheduling to CCI.

    Figure 1 Creating a workload

  3. Click Next: Add Container.
  4. After adding containers, click Next: Set Application Access.
  5. Click Next: Configure Advanced Settings and click Create.
  6. After the workload is created, return to the workload list page and check whether the created workload is in the Running state.
  7. Click the workload name. On the Pods tab page, check the nodes where the pods are located. A message will be displayed here if the pod is running on CCI clusters.

    Figure 2 Check whether the workload is scaled to CCI

  8. Switch to the CCI console. In the navigation pane, choose Workloads > Pods to view the pods that scheduled to CCI. The naming format is Namespace-Pod name. The name is the pod name in CCE.

    Figure 3 Pods scaled to CCI

  9. Increase the number of pods in CCE. You can see that the added pods are scheduled to CCI.

    Figure 4 Adding pods
    Figure 5 Scaling pods in CCE to CCI
    Figure 6 Scheduling multiple pods from CCE to CCI

Creating a Workload Using a YAML File

Example:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-vk
  labels: {}
spec:
  replicas: 20
  selector:
    matchLabels:
      app: test-vk
  template:
    metadata:
      labels:
        virtual-kubelet.io/burst-to-cci: 'auto'
        app: test-vk
    spec:
      containers:
      - name: container-0
        image: centos:latest
        resources:
          limits:
            cpu: 500m
            memory: 1024Mi
          requests:
             cpu: 500m
             memory: 1024Mi
        command:
          - /bin/bash
          - '-c'
          - sleep 10000
      dnsPolicy: Default

The information in red is the label to be added.

Add the following field to labels in the YAML file:

virtual-kubelet.io/burst-to-cci: "auto"

The following values are supported:

  • auto: Pods are automatically scheduled to CCI when CCE resources are used up.
  • enforce: Pods are forcibly scheduled to CCI.
  • off: Pods are not scheduled to CCI.

Uninstalling virtual-kubelet

Clearing Resources on CCI

  1. Scale in or delete the workload so that no pod will be scheduled to CCI.
  2. Log in to the CCI console and delete the namespace corresponding to the cluster ID. (After the namespace is deleted, all resources in the namespace will be automatically deleted to avoid charging on residual resources.)

Uninstalling the Add-on

  1. Log in to the CCE console. In the navigation pane, choose Add-ons. On the Add-on Instance tab page, click Uninstall under virtual-kubelet.
  2. In the dialog box displayed, click Yes to uninstall the add-on.