virtual-kubelet
This add-on is developed based on the Virtual Kubelet, an open source Kubernetes kubelet implementation that masquerades as a kubelet to connect Kubernetes to other APIs. virtual-kubelet is mainly used to extend Kubernetes APIs to serverless container services such as HUAWEI CLOUD CCI.
To be specific, virtual-kubelet calls Cloud Container Instance (CCI) to create and manage pods for your Deployments, StatefulSets, and jobs deployed in CCE during short-term service spikes. In this way, you can reduce consumption caused by cluster scaling. For details, see Scheduling CCE Pods to CCI.
Open source community: https://github.com/virtual-kubelet/virtual-kubelet
The virtual-kubelet add-on provides the following functions:
- Creates pods automatically in seconds. virtual-kubelet automatically creates pods on CCI, eliminating the overhead of resizing the CCE cluster.
- Seamlessly works with HUAWEI CLOUD SWR for you to use public and private images.
- Supports event synchronization, monitoring, logging, remote command execution on pods, and status viewing for CCI pods.
- Allows users to view the capacity information about virtual elastic nodes.
- Supports connectivity between CCE and CCI pods through Services.
Notes and Constraints
- 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 the Add-on
- 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.
- On the Install Add-on page, select the cluster and the add-on version, and click Next: Configuration.
- In the Configuration step, select Cross-Service Access to enable pods in the CCE cluster to communicate with pods on CCI by using a Kubernetes Service.
Figure 1 Selecting Cross-Service Access
- Click Install.
After the add-on is installed, click Go Back to Previous Page. 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.
Using the Add-on
After installing the virtual-kubelet add-on, perform the following steps to create a workload that can be elastically scaled to CCI:
- On the CCE console, choose Workloads in the navigation pane.
- In the Specify Basic Info step of creating a Deployment or Job, select Elastic Scheduling to CCI.
Figure 2 Selecting Elastic Scheduling to CCI
- Click Next: Add Container to continue the creation process.
Impact of virtual-kubelet on Available Resource Monitoring
After the virtual-kubelet add-on is installed, it is equivalent to a super-large node for monitoring. In this case, CCI resources are calculated together in the allocatable resources on the CCE cluster monitoring page. As shown in the following figure, after the virtual-kubelet add-on is installed, the CPU/memory allocation rate decreases sharply.
You can view the allocation rate of a specific node on the Nodes page or the AOM console.
Upgrading the Add-on
- Log in to the CCE console. In the navigation pane, choose Add-ons. On the Add-on Instance tab page, click Upgrade under virtual-kubelet.
- If the Upgrade button is not available, the current add-on is already up-to-date and no upgrade is required.
- During the upgrade, the virtual-kubelet add-on of the original version on cluster nodes will be discarded, and the add-on of the target version will be installed.
- On the Basic Information page, select the add-on version and click Next.
- Set the parameters by referring to the parameter description in Installing the Add-on and click Upgrade.
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. (Uninstalling the add-on will clear all resources on CCI to ensure that no extra fees are incurred by residual resources.)
If you delete a cluster without uninstalling the virtual-kubelet add-on, resources on CCI will not be automatically cleared and may incur extra fees. Either of the following operations helps avoid that:
- Uninstall the virtual-kubelet add-on before deleting the cluster.
- After deleting the cluster, log in to the CCI console and delete the namespace named cce-burst-${CLUSTER_ID}.
Last Article: web-terminal
Next Article: gpu-beta
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.