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

创建镜像快照

运行容器需要先拉取指定的容器镜像,但因网络和容器镜像大小等因素,镜像拉取耗时往往成了Pod启动的主要耗时。通过镜像快照功能,可以事先将要使用的镜像制作成快照,基于该快照创建Pod,从而避免镜像下载,提升Pod的启动速度。

创建镜像快照

假如镜像快照定义的文件名称为my-imagesnapshot.yaml,则执行kubectl apply -f my-imagesnapshot.yaml即可创建镜像快照,-f 表示从文件创建

# kubectl apply -f my-imagesnapshot.yaml

以下示例创建一个名为my-imagesnapshot的镜像快照。

apiVersion: imagecache.cci.io/v1
kind: ImageSnapshot
metadata:
  name: "my-imagesnapshot"
spec:
  images:
  - image: serverA.com/xx/redis
  - image: nginx:latest
  - image: redis
  registries:
  - server: serverA.com
    username: userA
    password: pwdA
  - server: serverB.com
    username: userB
    password: pwdB
    plainHTTP: true
  - server: serverC.com
    username: userC
    password: pwdC
    insecureSkipVerify: true
  buildingConfig:
    namespace: my-namespace-a
  evsInfo:
    volumeType: ssd
    volumeSizeGiB: 30
    filesystemType: ext4
  ttlDaysAfterCreated: 20
表1 参数说明

名称

类型

必填

示例值

描述

name

string

my-imagesnapshot

镜像快照名称。

image

string

nginx:latest

用于制作镜像快照的镜像。

server

string

serverA.com

不带 http:// 或 https:// 前缀的镜像仓库地址。

username

string

userA

镜像仓库用户名。

password

string

pwdA

镜像仓库密码。

plainHTTP

boolean

true

如果是使用HTTP协议的自建镜像仓库地址,需要设置为true,否则会因协议不同而导致镜像拉取失败。默认值为false。

insecureSkipVerify

boolean

true

如果是使用自签发证书的自建镜像仓库地址,需要设置为true来跳过证书认证,否则会因证书认证失败而导致镜像拉取失败。默认值为false。

namespace

string

my-namespace-a

用户命名空间。镜像快照制过程需要在用户命名空间创建CCI实例。

evsInfo

EVSInfo

/

镜像快照的EVS云盘配置。

volumeType

string

ssd

镜像快照的磁盘类型。默认为ssd。

volumeSizeGiB

integer

20

镜像快照大小,单位Gi。默认为20。

filesystemType

string

ext4

镜像快照的磁盘文件系统类型。当前只支持ext4。

ttlDaysAfterCreated

integer

10

镜像快照保留时间,过期将会被清理。默认值为0,即永不过期。

分享:

    相关文档

    相关产品