Container Image Acceleration
In traditional container systems, starting a container requires downloading and extracting all necessary image data. While this is manageable for small images, large images significantly extend container startup times. To address this, we’ve introduced an Image Acceleration Service based on lazy loading, which dramatically improves container startup performance. In our tests, a 25GB image accelerated by this service reduces container startup time to just 20 seconds.
Before using this feature, understand the underlying technologies:
- Image data and file system indexes are pre-cached in UFS.
- Only the file system index is loaded from UFS during container startup (no actual data is loaded).The container can immediately access the root file system (rootfs) using the index.
- When the container requests specific files, the file system loads the corresponding data from UFS based on the index offsets.
- The file system includes a cache layer that stores frequently accessed data in memory, optimizing subsequent file system operations.
Enable Image Acceleration
Prerequisites
- A UK8S cluster with a version ≥ 1.26.
- A UFS that must be in the same VPC as the UK8S cluster and have the mounting points configured.
- The username and password for the UHub repository (with push permission) to accelerate images.
NOTICE:
⚠️ During the image acceleration process, DO NOT modify or delete the UFS, or alter any files within it. Otherwise, it may cause IO errors in containers or make nodes NotReady!
⚠️ After enabling image acceleration, historical nodes will not automatically enable acceleration. Only newly added nodes after enabling image acceleration for the cluster will support it.
Enable Acceleration
Enter the [Application Center] of UK8S, find [Container Image Acceleration], and click [Enable Now] to activate the image acceleration function.
When enabling, you need to fill in the UFS information for storing image data, as well as the UHub username and password for pushing accelerated images.
After enabling, we will install some image acceleration components in your cluster. After waiting for a while, you can see the components enter the ready state:
Status Display
Only nodes using specific containerd plugins support image acceleration. In the [Nodes] list page of the console, you can see a special icon next to the names of nodes that support image acceleration:
In Kubernetes, these nodes will also be labeled with the following label to facilitate configuring affinity later, ensuring that Pods using accelerated images are scheduled to acceleration-supported nodes:
node.uk8s.Genesis Cloud.cn/image_accel: true
Create Accelerated Image
Images need to be accelerated before use. The specific steps for acceleration are:
- Download the original image, convert its format, and cache it in the UFS.
- Create an accelerated image and push it to UHub.
Two key concepts here:
- Original image: The image to be accelerated.
- Accelerated image: The image after acceleration.
In practical use, replace the Pod’s image with the accelerated image to achieve the image acceleration effect.
In the [Container Image Acceleration] interface, you can create an acceleration task to convert the original image into an accelerated image, which requires filling in two image addresses.
⚠️ The UHub user filled in when enabling image acceleration must have permission to push the accelerated image.
After creating the acceleration task, you can check its execution status. When the status is [Ready], the accelerated image is ready for use.
Use Image Acceleration
Replace the original image with the accelerated image to enable acceleration. Here is an example:
⚠️ Nodes affinity must be added to the Pod that needs acceleration to ensure the Pod is scheduled to nodes supporting acceleration.
apiVersion: v1
kind: Pod
metadata:
name: test-pod
namespace: default
labels:
app: test-pod
spec:
containers:
- name: test-pod
image: uhub.service.ucloud.cn/wenqian/nginx:latest-acc
imagePullPolicy: Always
restartPolicy: Always
affinity:
nodeAffinity:
# This affinity is mandatory; otherwise, the Pod scheduled to non-accelerated nodes will fail to start
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node.uk8s.ucloud.cn/uimgacc
operator: In
values:
- "true"