更新时间:2025-08-12 GMT+08:00
使用镜像快照
使用镜像快照创建Pod,支持以下两种方式:
- 自动匹配
自动匹配将从所有用户创建的可用的镜像快照中选择最优的镜像。按以下顺序进行匹配:
- 镜像匹配度:优先选择匹配度高的镜像快照,匹配度指的是Pod和镜像快照两者在镜像上的匹配情况。
- 创建时间:优先选择创建时间更新的镜像快照。

如果同时使用明确指定和自动匹配两种镜像快照方式创建Pod时,如果两者冲突,会返回400报错。
自动匹配
创建CCI实例时,可以通过注解中添加以下键值来开启自动匹配镜像快照。
名称 |
示例值 |
描述 |
---|---|---|
cci.io/image-snapshot-auto-match |
"true" |
设置是否开启自动匹配镜像快照。 |
cci.io/image-snapshot-usage-strategy |
"size" |
设置镜像快照自动匹配策略,默认为“size”。
|
以创建Deployment为例:
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
明确指定
创建CCI实例时,可以通过注解中添加以下键值来明确指定镜像快照和拦截策略。
名称 |
示例值 |
描述 |
---|---|---|
cci.io/image-snapshot-specified-name |
"my-imagesnapshot" |
指定的镜像快照名称。 |
cci.io/image-snapshot-reject-if-not-available |
"true" |
如果指定的镜像快照不存在或状态不可用,默认会从镜像仓库下载镜像。如果需要拦截实例创建,则需配置此注解为 "true"。 |
以创建Deployment为例:
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
父主题: 镜像快照