Using Image Snapshots to Accelerate Image Pull
Scenario
Image snapshots provide a more efficient way to start up containers. Using an image snapshot to create a pod accelerates image pull and reduces the time required for starting up the containers. For details about how to use image snapshots, see Using Image Snapshots.
Procedure
- Log in to the CCI console. In the navigation pane, choose Image Snapshots. On the displayed page, click Create from YAML. The following is an example YAML file:
apiVersion: cci/v2 kind: ImageSnapshot metadata: name: imagesnapshot-a spec: buildingConfig: namespace: default # Namespace imageSnapshotSize: 20 # Image snapshot size, in GiB ttlDaysAfterCreated: 100 # Image validity period images: - image: nginx:stable-alpine-perl # Image registries: [] - In the navigation pane, choose Workloads. On the Deployments tab, click Create from YAML to create a workload. Add cci.io/image-snapshot-auto-match: 'true' in annotations. The following is an example:
kind: Deployment apiVersion: cci/v2 metadata: name: nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx annotations: cci.io/image-snapshot-auto-match: 'true' # Automatic matching of image snapshots spec: containers: - name: nginx image: nginx:stable-alpine-perl resources: requests: cpu: 500m memory: 1Gi - Verify that the pod annotations contain the cci.io/image-snapshot-detail and cci.io/imagesnapshot-volume fields, the matched image snapshot is displayed, and the size of the mounted data disk is the same as that of the image snapshot.