更新时间:2024-06-18 GMT+08:00
分享

使用镜像快照

使用镜像快照创建Pod,支持以下两种方式:

  • 自动匹配

自动匹配将从所有用户创建的可用的镜像快照中选择最优的镜像。按以下顺序进行匹配:

a. 镜像匹配度:优先选择匹配度高的镜像快照,匹配度指的是Pod和镜像快照两者在镜像上的匹配情况。

b. 创建时间:优先选择创建时间更新的镜像快照。

  • 明确指定

明确指定使用的镜像快照。该镜像缓存必须为创建完成可用(Available)状态。

如果同时使用明确指定和自动匹配两种镜像快照方式创建Pod时,如果两者冲突,会返回400报错。

自动匹配

创建CCI实例时,可以通过注解中添加以下键值来开启自动匹配镜像快照。

名称

示例值

描述

cci.io/image-snapshot-auto-match

"true"

设置是否开启自动匹配镜像快照。

以创建Deployment为例:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-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"

指定的镜像快照名称。

以创建Deployment为例:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
      annotations:
        cci.io/image-snapshot-auto-match: "false"
        cci.io/image-snapshot-specified-name: "my-imagesnapshot"
    spec:
      containers:
        - image: redis
          name: container-0
          resources:
            limits:
              cpu: 500m
              memory: 1024Mi
            requests:
              cpu: 500m
              memory: 1024Mi
      imagePullSecrets:
        - name: imagepull-secret
分享:

    相关文档

    相关产品