kubekey/docs/zh/modules/image.md
zuoxuesong-worker 238eb2b8f6
Feat/pull image with multi arch (#2883)
* feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

* feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

* feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

* feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: support user pull one or more arch from image registry and combine them to one image

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

---------

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>
2025-12-23 06:20:32 +00:00

4.3 KiB

image 模块

image模块允许用户下载镜像到本地目录或上传镜像到远程目录。

参数

参数 说明 类型 必填 默认值
pull 把镜像从远程仓库中拉取到本地目录 map -
pull.images_dir 镜像存放的本地目录 字符串 -
pull.manifests 需要拉取的镜像列表 字符串数组 -
pull.auths 远程仓库的认证信息 Object数组 -
pull.auths.repo 用于认证远程仓库的地址 字符串 -
pull.auths.username 用于认证远程仓库的用户名 字符串 -
pull.auths.password 用于认证远程仓库的密码 字符串 -
pull.auths.insecure 是否跳过当前远程仓库的tls认证 bool -
pull.auths.plain_http 是否使用http访问远程仓库 bool -
pull.platform 镜像的架构信息 字符串数组 -
pull.skip_tls_verify 默认的是否跳过远程仓库的tls认证 bool -
push 从本地目录中推送镜像到远程仓库 map -
push.images_dir 镜像存放的本地目录 字符串 -
push.auths 远程仓库的认证信息 Object数组 -
push.auths.repo 用于认证远程仓库的地址 字符串 -
push.auths.username 用于认证远程仓库的用户名 字符串 -
push.auths.password 用于认证远程仓库的密码 字符串 -
push.auths.insecure 是否跳过当前远程仓库的tls认证 bool -
push.auths.plain_http 是否使用http访问远程仓库 bool -
push.skip_tls_verify 默认的是否跳过远程仓库的tls认证 bool -
push.src_pattern 正则表达式,过滤本地目录中存放的镜像 map -
push.dest 模版语法,从本地目录镜像推送到的远程仓库镜像 map -
copy 模版语法,将镜像在文件系统和镜像仓库内相互复制 map -
copy.platform 镜像的架构信息 字符串数组 -
copy.from 模版语法,源镜像信息 map -
copy.from.path 镜像源文件路径 字符串 -
copy.from.manifests 源镜像列表 字符串数组 -
copy.to 模版语法,从本地目录镜像推送到的远程仓库镜像 map -
copy.to.path 镜像目标文件路径 字符串 -
copy.to.pattern 正则表达式,过滤复制至目标的镜像 字符串 -

每个本地目录存放的镜像对应一个dest镜像。

|-- images_dir/
|   |-- registry1/
|   |   |-- image1/
|   |   |   |-- manifests/
|   |   |   |   |-- reference
|   |   |-- image2/
|   |   |   |-- manifests/
|   |   |   |   |-- reference
|   |-- registry2/
|   |   |-- image1/
|   |   |   |-- manifests/
|   |   |   |   |-- reference

对于每个src镜像对应有一个dest。dest中有如下默认的模板变量 {{ .module.image.src.reference.registry }}: 本地目录中单个镜像的registry {{ .module.image.src.reference.repository }}: 本地目录中单个镜像的repository {{ .module.image.src.reference.reference }}: 本地目录中单个镜像的reference

使用示例

  1. 拉取镜像
- name: pull images
  image:
    pull:
      images_dir: /tmp/images/
      platform:
        - amd64
        - arm64
      manifests:
       - "docker.io/kubesphere/ks-apiserver:v4.1.3"
       - "docker.io/kubesphere/ks-controller-manager:v4.1.3"
       - "docker.io/kubesphere/ks-console:3.19"
  1. 推送镜像到远程仓库
- name: push images
  push:
    images_dir: /tmp/images/
    dest: hub.kubekey/{{ .module.image.src.reference.repository }}:{{ .module.image.src.reference.reference }}

即: docker.io/kubesphere/ks-apiserver:v4.1.3 => hub.kubekey/kubesphere/ks-apiserver:v4.1.3 docker.io/kubesphere/ks-controller-manager:v4.1.3 => hub.kubekey/kubesphere/ks-controller-manager:v4.1.3 docker.io/kubesphere/ks-console:3.19 => hub.kubekey/kubesphere/ks-console:v4.1.3

  1. 将镜像从文件系统复制至其他文件系统
- name: file to file
  image:
    copy:
      from:
        path: "/tmp/images/"
        manifests:
          - docker.io/calico/apiserver:v3.28.2
      to:
        path: "/tmp/others/images/"