Skip to content

Commit 4f693db

Browse files
committed
Support putting external images into the local registry of the kubevirtci cluster (#3801)
User can define an environment variable EXTRA_IMAGES that contains a list of external image urls separated by spaces. At the end of 'make cluster-up' target the EXTRA_IMAGES are processed by a script ./cluster-up/extra-images.sh so that for each image url, it pulls the image and then push the image into the local registry. Then when 'make cluster-sync' is invoked, it searches all external image urls in the generated yamls in _out/manifests/ and replaces them with corresponding urls in the local registry (registry:5000) Signed-off-by: Howard Gao <[email protected]>
1 parent e40a2e5 commit 4f693db

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

cluster-sync/sync.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ fi
6464
DOCKER_PREFIX=$MANIFEST_REGISTRY PULL_POLICY=$PULL_POLICY make manifests
6565
DOCKER_PREFIX=$DOCKER_PREFIX make push
6666

67+
# Update manifests to replace extra images with internal registry ones
68+
if [ -n "${EXTRA_IMAGES}" ]; then
69+
for img in ${EXTRA_IMAGES}; do
70+
base_image_path="${img#*/}"
71+
local_img_url="registry:5000/${base_image_path}"
72+
for resfile in ./_out/manifests/*.yaml; do
73+
sed -i "s|${img}|${local_img_url}|g" $resfile
74+
done
75+
done
76+
fi
77+
6778
function kill_running_operator {
6879
out=$(_kubectl get pods -n $CDI_NAMESPACE)
6980
out=($out)

cluster-up/extra-images.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
cri_bin=$1
4+
if [ -z $cri_bin ]; then
5+
cri_bin=docker
6+
fi
7+
8+
if [ -n "${EXTRA_IMAGES}" ]; then
9+
registry_port=$(./cluster-up/cli.sh ports registry | xargs)
10+
for img in ${EXTRA_IMAGES}; do
11+
base_image_path="${img#*/}"
12+
local_img_url="localhost:${registry_port}/${base_image_path}"
13+
$cri_bin pull $img
14+
$cri_bin tag $img $local_img_url
15+
$cri_bin push $local_img_url
16+
done
17+
fi

cluster-up/up.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ up
3636
if [ ${KUBEVIRT_SINGLE_STACK} == true ]; then
3737
validate_single_stack_ipv6
3838
fi
39+
40+
${KUBEVIRTCI_PATH}extra-images.sh $_cri_bin

0 commit comments

Comments
 (0)