创建镜像快照
操作场景
本章介绍了如何创建镜像快照。要了解镜像快照的工作原理,请参阅镜像快照概述。
操作步骤
运行容器需要先拉取指定的容器镜像,但因网络和容器镜像大小等因素,镜像拉取耗时往往成了Pod启动的主要耗时。通过镜像快照功能,可以事先将要使用的镜像制作成快照,基于该快照创建Pod,从而避免镜像下载,提升Pod的启动速度。
以下示例创建一个名为my-imagesnapshot的镜像快照。
apiVersion: cci/v2 kind: ImageSnapshot metadata: name: 'my-imagesnapshot' spec: buildingConfig: namespace: test-namespace eipID: xxxxxxxx imageSnapshotSize: 30 ttlDaysAfterCreated: 7 images: - image: 'nginx:stable-alpine-perl' registries: - imagePullSecret: imagepull-secret server: xxxxx.myhuaweicloud.com plainHTTP: true
字段 |
类型 |
必填 |
示例值 |
描述 |
---|---|---|---|---|
.metadata.name |
string |
是 |
my-imagesnapshot |
镜像快照名称。 |
.spec.images.image |
string |
是 |
nginx:latest |
用于制作镜像快照的镜像。 |
.spec.registries.server |
string |
是 |
serverA.com |
不带 http:// 或 https:// 前缀的镜像仓库地址。 |
.spec.registries.imagePullSecret |
string |
否 |
imagepull-secret |
访问镜像仓库使用的凭证Secret。 |
.spec.registries.plainHTTP |
boolean |
否 |
true |
如果是使用HTTP协议的自建镜像仓库地址,需要设置为true,否则会因协议不同而导致镜像拉取失败。默认值为false。 |
.spec.registries.insecureSkipVerify |
boolean |
否 |
true |
如果是使用自签发证书的自建镜像仓库地址,需要设置为true来跳过证书认证,否则会因证书认证失败而导致镜像拉取失败。默认值为false。 |
.spec.buildingConfig.namespace |
string |
是 |
my-namespace-a |
用户命名空间。镜像快照制过程需要在用户命名空间创建CCI实例。 |
.spec.buildingConfig.eipID |
string |
否 |
3cxxxxe0-xxxx-xxxx-xxxx-8xxxxf3xxxx4 |
用于访问拉取公网镜像的EIP |
.spec.buildingConfig.autoCreateEIP |
boolean |
否 |
true |
在制作镜像快照时,是否自动为创建镜像快照实例创建弹性公网IP,当指定了eipId的情况下,autoCreateEIP配置将被忽略。当autoCreateEIP为true时,需通过autoCreateEIPAttribute指定弹性公网IP的配置。 |
.spec.buildingConfig.autoCreateEIPAttribute.bandwidthChargeMode |
string |
否 |
bandwidth |
按流量计费还是按带宽计费。 取值范围:bandwidth,traffic,不填或者为空时默认是bandwidth。其中IPv6国外默认是bandwidth,国内默认是traffic。 |
.spec.buildingConfig.autoCreateEIPAttribute.bandwidthSize |
int |
否 |
1000 |
带宽大小。 取值范围:默认1Mbit/s~2000Mbit/s |
.spec.buildingConfig.autoCreateEIPAttribute.type |
string |
否 |
5_bgp |
EIP的类型。 取值范围:5_bgp(全动态BGP),5_sbgp(静态BGP),5_youxuanbgp(优选BGP)。 |
.spec.buildingConfig.autoCreateEIPAttribute.ipVersion |
int |
否 |
4 |
弹性公网IP的版本。 取值范围:4或者6。
|
.spec.buildingConfig.TimeoutMinutes |
int |
否 |
1440 |
镜像快照制作完成的超时时间,单位分钟。 取值范围:[30, 10080] 的整数,表示30分钟~1周。默认值为1440,表示1天。 |
.spec.ttlDaysAfterCreated |
integer |
否 |
10 |
镜像快照保留时间,单位为天,过期将会被清理。默认值为0,即永不过期。 每当快照被负载/容器组资源使用时,其过期时间将被重置为当前时间加上快照保留时间。
说明:
快照过期后,仍会占用配额,需定期审核过期镜像快照后删除。 |
.spec.imageSnapshotSize |
integer |
否 |
20 |
镜像快照大小,单位为GiB,默认值为20。 |