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

管理镜像快照

查看镜像快照

创建镜像快照后,您可以查询镜像快照信息。

  • 查询用户创建的所有镜像快照,执行如下命令。
    kubectl get imagesnapshot -oyaml
  • 查询单个镜像快照,执行如下命令。
    kubectl get imagesnapshot my-imagesnapshot -oyaml
    返回结果如下:
    apiVersion: imagecache.cci.io/v1
    kind: ImageSnapshot
    metadata:
      name: "my-imagesnapshot"
    spec:
      images:
      - image: serverA.com/xx/redis
      - image: nginx:latest
      - image: redis
      ...
    status:
      snapshotID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
      snapshotName: cci-imagesnapshot-my-imagesnapshot
      phase: Available
      reason: xx
      message: xx
      images:
      - image: serverA.com/image-a:v1
      - image: serverB.com/image-b:v2
      - image: serverC.com/image-c:v3

    从返回结果中可以查看镜像快照名称、状态等信息,其中状态相关主要字段如下:

    表1 参数说明

    名称

    类型

    示例值

    描述

    phase

    string

    Available

    镜像快照当前所处状态:

    • Available:可用
    • Unavailable:不可用
    • Creating:创建中
    • Deleting:删除中

    snapshotID

    string

    /

    当前镜像快照对应的evs云盘快照ID。

    snapshotName

    string

    cci-imagesnapshot-my-imagesnapshot

    当前镜像快照对应的evs云盘快照名称,命名格式为cci-imagesnapshot-{imagesnap_name}

    reason

    string

    CreateEVSSnapshotFailed

    镜像快照处于当前状态的原因。

    message

    string

    /

    镜像快照处于当前状态的原因的具体描述。

    images

    array of PulledImage

    /

    镜像快照中缓存的镜像的信息。

    image

    string

    nginx:latest

    镜像快照中的镜像。

删除镜像快照

镜像快照对应一份EVS云盘快照,保留镜像快照需要支付相应的EVS云盘快照费用。对于不再使用的镜像快照,如果在创建时未设置保留时长,需手动删除。

使用如下命令删除镜像快照:

kubectl delete imagesnapshot my-imagesnapshot --wait=false

镜像快照相关API为类kubernetes风格API,并不支持完整的kubernetes API特性,比如“不支持watch”,“不支持fieldSelector、labelSelector”等等。

所以使用kubectl删除镜像快照时,建议额外指定--wait=false。否则,kubectl在删除镜像快照后会发起watch请求以等待镜像快照删除成功。但因镜像快照API不支持watch,此时kubectl工具可能会报错。

分享:

    相关文档

    相关产品