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. 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
- Supports only CCE clusters using the VPC network model and CCE Turbo clusters (using virtual-kubelet 1.2.5 or later). The cluster version must be 1.19 or earlier.
- 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.
- 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.)
- In a pod, the number of CPUs is greater than 0 for at least one container.
- After auto adjustment, the number of CPU cores in a pod cannot exceed 32, and the memory size cannot exceed 256 GiB.
Automatic Resource Adjustment
If pods to be scaled to CCI do not meet the CCI specifications, virtual-kubelet automatically adjusts pod resources .
The rules are as follows:
- Increase the number of CPU cores of each container (except BestEffort containers) in the pod to an integer multiple of 0.25 and set the memory size to a value greater than or equal to 0.2 GiB.
- Increase the memory size of the pod to an integer multiple of 1 GiB.
- If the ratio of pod memory/CPU is smaller than 2, increase the pod memory to a value that is greater than or equal to twice the number of CPUs and at the same time, an integer multiple of 1 GiB. If the ratio of pod memory/CPU is greater than 8, increase the number of pod CPUs to be greater than or equal to 1/8 of the memory size and at the same time, an integer multiple of 0.25.
- If the number of CPU cores exceeds 32 or the memory size exceeds 256 GiB, the adjustment fails and the pod creation request is rejected.
- The CPU and memory increments caused by the adjustment are added to the first non-BestEffort container.
Installing Add-ons
- Log in to the CCE console and access the cluster details page. Choose Add-ons in the navigation pane, locate virtual-kubelet on the right, and click Install.
- Select the add-on specifications and select Enable pod communications between CCE and CCI through Kubernetes Services.
- Click Install.
Creating a Workload Using a YAML File
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-vk
labels:
virtual-kubelet.io/burst-to-cci: 'auto'
spec:
replicas: 20
selector:
matchLabels:
app: test-vk
template:
metadata:
labels:
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 of the workload in the YAML file:
virtual-kubelet.io/burst-to-cci: "auto"
The following values are supported:
- auto: Automatic scaling to CCI is enabled when the resource usage of CCE nodes is high.
- enforce: Pods are forcibly scheduled to CCI.
- off: Pods are not scheduled to CCI.
Uninstalling virtual-kubelet
Clearing Resources on CCI
- Scale in or delete the workload so that no pod will be scheduled to CCI.
- 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
- 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.
- In the dialog box displayed, click Yes to uninstall the add-on.
Last Article: Using HPA and CA for Auto Scaling of Workloads and Nodes
Next Article: Permissions Management
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.