Updated on 2026-09-09 GMT+08:00

Using an Image Snapshot

When you are creating a pod, CCI needs to pull the container images. The image download speed affects the pod startup. Image snapshots accelerate image pull, improve pod startup speed, and reduce bandwidth consumption. You can create a pod using an automatically-matched or specified image snapshot.

Notes and Constraints

If you create a pod using both the specified image snapshot and the automatically-matched image snapshot and the two image snapshots conflict, 400 will be returned.

Method 1: Automatic Matching

The optimal image snapshots are selected from all available image snapshots based on the following:

  1. Image matching degree: The images in the image snapshots are matched with those used by the pod, and the most matched image snapshots are preferred.
  2. Time when image snapshots were created: The latest image snapshot is preferred.

When creating a pod, you can add the annotations below to enable automatic image snapshot matching.

Annotation

Example Value

Description

cci.io/image-snapshot-auto-match

true

Whether to enable automatic image snapshot matching.

cci.io/image-snapshot-usage-strategy

size

Automatic matching policy for image snapshots. The default value is size.

  • size: The system compares each container image in the pod specification against the images cached in each image snapshot, sums the sizes of all matching images, and selects the snapshot with the largest total matched size.
  • quantity: The system compares each container image in the pod specification against the images cached in each image snapshot, counts the number of matching images, and selects the snapshot with the highest match count.

cci.io/image-snapshot-exact-match

true

Fully-matched image snapshot. Whether all container images in the pod are fully matched with those in the image snapshot. The default value is false.

In the following example, a Deployment will be created.
apiVersion: cci/v2
kind: Deployment
metadata:
  name: deploy-example
  namespace: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
      annotations:
        cci.io/image-snapshot-auto-match: "true"
        cci.io/image-snapshot-exact-match: "true"
    spec:
      containers:
        - image: redis
          name: container-0
          resources:
            limits:
              cpu: 500m
              memory: 1024Mi
            requests:
              cpu: 500m
              memory: 1024Mi
      imagePullSecrets:
        - name: imagepull-secret

Method 2: Specifying the Image Snapshot

You can also specify the image snapshot to be used.

When creating a pod, you can add the annotations below to specify the image snapshot and interception policy.

Annotation

Example Value

Description

cci.io/image-snapshot-specified-name

"my-imagesnapshot"

Name of the specified image snapshot.

cci.io/image-snapshot-reject-if-not-available

"true"

If the specified image snapshot does not exist or is unavailable, the image is pulled from the image repository by default. To intercept pod creation, set the value to true.

In the following example, a Deployment will be created.

apiVersion: cci/v2
kind: Deployment
metadata:
  name: deploy-example
  namespace: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
      annotations:
        cci.io/image-snapshot-specified-name: "my-imagesnapshot"
        cci.io/image-snapshot-reject-if-not-available: "true"
    spec:
      containers:
        - image: redis
          name: container-0
          resources:
            limits:
              cpu: 500m
              memory: 1024Mi
            requests:
              cpu: 500m
              memory: 1024Mi
      imagePullSecrets:
        - name: imagepull-secret