add tags for KUBE_ADDON_REGISTRY when we load images locally

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas 2022-03-15 15:43:11 -04:00
parent 2b1b849d6a
commit 9a0bb97a34
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59

View File

@ -457,8 +457,10 @@ function try-load-docker-image {
if [[ "${CONTAINER_RUNTIME_NAME:-}" == "containerd" || "${CONTAINERD_TEST:-}" == "containerd" ]]; then
load_image_command=${LOAD_IMAGE_COMMAND:-ctr -n=k8s.io images import}
tag_image_command=${TAG_IMAGE_COMMAND:-ctr -n=k8s.io images tag}
else
load_image_command="${LOAD_IMAGE_COMMAND:-}"
tag_image_command="${TAG_IMAGE_COMMAND:-}"
fi
# Deliberately word split load_image_command
@ -472,6 +474,15 @@ function try-load-docker-image {
sleep 5
fi
done
if [[ -n "${KUBE_ADDON_REGISTRY:-}" ]]; then
# remove the prefix and suffix from the path to get the container name
container=${img##*/}
container=${container%.tar}
# find the right one for which we will need an additional tag
container=$(ctr -n k8s.io images ls | grep "k8s.gcr.io/${container}" | awk '{print $1}' | cut -f 2 -d '/')
${tag_image_command} "k8s.gcr.io/${container}" "${KUBE_ADDON_REGISTRY}/${container}"
fi
# Re-enable errexit.
set -e
}