拉取镜像并改名脚本
#!/bin/bash images=( kube-apiserver:v1.24.3 kube-controller-manager:v1.24.3 kube-scheduler:v1.24.3 kube-proxy:v1.24.3 pause:3.7 etcd:3.5.3-0 coredns:v1.8.6 ) for imageName in ${images[@]} ; do docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName k8s.gcr.io/$imageName docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName done
第二种场景,由于coredns路径有变化,需要单独定义路径
#!/bin/bash #Author:anliu #Blog: #Time:2024-03-25 19:57:18 #Name:image-tag.sh #Version:V1.0 #Description:This is a test script image_path=registry.cn-hangzhou.aliyuncs.com/google_containers image_path_tag=k8s.gcr.io image_tag=$(kubeadm config images list --kubernetes-version v1.22.0 |awk -F"/" '{print $NF}') tag=$(kubeadm config images list --kubernetes-version v1.22.0|awk -F"/" '{print $NF}' | awk -F":" '{print $1}') func_pull_image(){ if [ "$2" == "coredns" ];then docker pull $image_path/${1} docker tag $image_path/${1} $image_path_tag/coredns/${1} else docker pull $image_path/${1} docker tag $image_path/${1} $image_path_tag/${1} fi } i=0 image_tag_num=(kube-apiserver kube-controller-manager kube-scheduler kube-proxy pause etcd coredns) for image_name in $image_tag;do #tag_name=$(echo $tag|awk '{print $'$i'}') tag_name=${image_tag_num[$i]} func_pull_image $image_name $tag_name let i+=1 done
标签:image,imageName,拉取,tag,path,镜像,kubeadm,kube,docker From: https://www.cnblogs.com/struggle-1216/p/16483631.html