image Module

May 8, 2026 · View on GitHub

Pull images to local directory, push images to remote registry, or copy images between file system and image registry.

Parameters

ParameterDescriptionTypeRequiredDefault
manifestsList of images to operate onstring arrayYes-
platformArchitecture list (e.g., ["linux/amd64", "linux/arm64"])string arrayNo-
policyPolicy for platform filtering: strict (all platforms must exist, otherwise error), warn (log warning if missing, but continue)stringNostrict
patternRegex pattern to match imagesstringNo-
authsRegistry authenticationObject arrayNo-
auths.repoRegistry addressstringNo-
auths.usernameUsernamestringNo-
auths.passwordPasswordstringNo-
auths.insecureWhether to skip TLS verificationboolNo-
auths.plain_httpWhether to use HTTPboolNo-
srcSource image reference (remote registry or local directory, e.g., docker.io/library/alpine:3.19 or local:///var/lib/kubekey/images)stringNo-
destDestination (local directory or remote registry, e.g., local:///tmp/images/ or hub.kubekey/library/alpine:3.19)stringNo-
skip_tls_verifyDefault whether to skip TLS verificationboolNo-

src/dest format:

  • Remote registry: registry/repository:tag (e.g., docker.io/library/alpine:3.19)
  • Local directory: local:///absolute/path (e.g., local:///var/lib/kubekey/images)

Operation types (determined by src and dest):

  • pull: src = remote registry, dest = local directory
  • push: src = local directory, dest = remote registry
  • copy: src = local directory, dest = local directory

Available variables for dest:

  • {{ .module.image.src.reference.registry }}: registry
  • {{ .module.image.src.reference.repository }}: repository
  • {{ .module.image.src.reference.reference }}: reference (e.g., tag)

Local directory structure example:

images_dir/
├── registry1/
│   ├── image1/manifests/reference
│   └── image2/manifests/reference
└── registry2/
    └── image1/manifests/reference

Examples

1. Pull images from remote registry

- name: pull images
  image:
    manifests:
      - "docker.io/kubesphere/ks-apiserver:v4.1.3"
      - "docker.io/kubesphere/ks-controller-manager:v4.1.3"
    platform: [linux/amd64, linux/arm64]
    policy: strict
    src: "docker.io"
    dest: "local:///tmp/images/"

2. Push images to remote registry

- name: push images
  image:
    manifests:
      - "library/alpine:3.19"
    src: "local:///tmp/images/"
    dest: "hub.kubekey/{{ .module.image.src.reference.repository }}:{{ .module.image.src.reference.reference }}"

For example:

  • library/alpine:3.19hub.kubekey/library/alpine:3.19

3. Copy images between local directories

- name: copy images
  image:
    manifests:
      - "docker.io/calico/apiserver:v3.28.2"
    src: "local:///tmp/images/"
    dest: "local:///tmp/others/images/"

4. Copy images with regex pattern

- name: copy images with pattern
  image:
    pattern: ".*calico.*"
    src: "local:///tmp/images/"
    dest: "local:///tmp/others/images/"