Updated on 2025-08-12 GMT+08:00

Using an Image Snapshot

You can use an image snapshot to create a pod in either of the following ways:

  • Automatic matching

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

    1. Image matching degree: The images in the image snapshots are matched with those for the pod, and the mostly matched image snapshot is preferred.
    2. Time when image snapshots were created: Image snapshots that were created later are preferred.
  • Specific image snapshot

    Specify the image snapshot to be used.

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

Automatic Matching

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

Key

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: selects the image snapshot with the largest sum of image sizes.
  • quantity: selects the image snapshot that matches the largest number of images.

In the following example, a Deployment will be created.

apiVersion: cci/v2
kind: Deployment
metadata:
  name: deployment-test
  namespace: ns-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
      annotations:
        cci.io/image-snapshot-auto-match: "true"
    spec:
      containers:
        - image: redis
          name: container-0
          resources:
            limits:
              cpu: 500m
              memory: 1024Mi
            requests:
              cpu: 500m
              memory: 1024Mi
      imagePullSecrets:
        - name: imagepull-secret

Specifying an Image Snapshot

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

Key

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: deployment-test
  namespace: ns-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