sync-image.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # Version configuration (can be overridden by environment variables)
  3. TARGET_REGISTRY=${TARGET_REGISTRY:-"registry.cn-beijing.aliyuncs.com/yunion"}
  4. CALICO_VERSION=${CALICO_VERSION:-"v3.27.5"}
  5. # skopeo login --username $USERNAME $TARGET_REGISTRY
  6. SKOPEO_COPY_CMD='skopeo copy --override-os linux --multi-arch all'
  7. # Function: Copy image from source to target registry
  8. copy_image() {
  9. local source_image=$1
  10. local target_name=$2
  11. local target_image="${TARGET_REGISTRY}/${target_name}"
  12. echo "Copying ${source_image} to ${target_image}..."
  13. $SKOPEO_COPY_CMD docker://${source_image} docker://${target_image}
  14. }
  15. # Function: Add calico images to the copy list
  16. add_calico_images() {
  17. local version=$1
  18. IMAGES["calico-cni:${version}"]="docker.io/calico/cni:${version}"
  19. IMAGES["calico-node:${version}"]="docker.io/calico/node:${version}"
  20. IMAGES["calico-kube-controllers:${version}"]="docker.io/calico/kube-controllers:${version}"
  21. }
  22. # Define images to be copied
  23. declare -A IMAGES=()
  24. # Add calico images
  25. add_calico_images "${CALICO_VERSION}"
  26. # Add other images
  27. IMAGES["traefik:2.10.5"]="docker.io/rancher/mirrored-library-traefik:2.10.5"
  28. IMAGES["coredns:1.10.1"]="docker.io/rancher/mirrored-coredns-coredns:1.10.1"
  29. # Copy all images
  30. for target_name in "${!IMAGES[@]}"; do
  31. copy_image "${IMAGES[$target_name]}" "${target_name}"
  32. done