push-images.sh.j2 953 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. version_file={{ offline_data_path }}/versions.json
  3. if ! [ -f "$version_file" ]; then
  4. echo "[ERROR] version file $version_file is empty! "
  5. exit 1
  6. fi
  7. imgs=( $(cat $version_file |jq '.dockers |to_entries[] |.key +":"+ .value' | xargs) )
  8. echo imgs ${imgs[@]}
  9. registry=$(cat $version_file | jq .registry |xargs)
  10. if [ -z "$registry" ]; then
  11. echo "[ERROR] registry is empty!"
  12. exit 1
  13. fi
  14. echo registry $registry
  15. # restart k3s
  16. systemctl restart k3s
  17. push_and_tag(){
  18. local img_name_version=$1
  19. # k3s ctr images tag registry.cn-beijing.aliyuncs.com/$registry/$img_name_version \
  20. # $insecure_registry/$registry/$img_name_version
  21. k3s ctr images push $insecure_registry/$registry/$img_name_version --plain-http
  22. }
  23. export -f push_and_tag
  24. for i in {{ docker_insecure_registries | join(" ") }}
  25. do
  26. for img in "${imgs[@]}"
  27. do
  28. insecure_registry=$i registry=$registry push_and_tag $img
  29. done
  30. done