Skip to content

Instantly share code, notes, and snippets.

@jparrill
Last active April 30, 2021 09:23
Show Gist options
  • Save jparrill/f3e9cf1e14a1617ab08b27da4a5a30bf to your computer and use it in GitHub Desktop.
Save jparrill/f3e9cf1e14a1617ab08b27da4a5a30bf to your computer and use it in GitHub Desktop.
Container Image Sync between a public and internal registry
quay.io/ocpmetal/s3server:latest
quay.io/ocpmetal/assisted-service:latest
quay.io/ocpmetal/assisted-installer:latest
quay.io/ocpmetal/assisted-installer-agent:latest
quay.io/ocpmetal/ocp-metal-ui:latest
quay.io/ocpmetal/bm-inventory:latest
quay.io/ocpmetal/assisted-installer-controller:latest
quay.io/ocpmetal/assisted-iso-create:latest
quay.io/ocpmetal/ocp-metal-ui-tests:latest
quay.io/ocpmetal/postgresql-12-centos7:latest
quay.io/ocpmetal/s3-object-expirer:latest
quay.io/ocpmetal/assisted-installer-controller-ocp:latest
quay.io/ocpmetal/swagger-codegen-cli:2.4.15
quay.io/ocpmetal/agent:latest
quay.io/ocpmetal/assisted-ignition-generator:stable.24.09.2020-22.20
quay.io/ocpmetal/connectivity_check:latest
quay.io/ocpmetal/inventory:latest
quay.io/sameersbn/squid:latest
quay.io/coreos/coreos-installer:release
quay.io/ohadlevy/kexec:latest
quay.io/bitnami/wildfly:latest
quay.io/ocpmetal/assisted-installer-controller-ocp:latest
quay.io/mavazque/s3cmd:latest
quay.io/ocpmetal/assisted-service-operator-bundle:latest
quay.io/ocpmetal/assisted-service-index:latest
quay.io/openshift/origin-cli:latest
registry.access.redhat.com/ubi8/ubi-minimal:latest
k8s.gcr.io/pause:3.5
quay.io/ocpmetal/assisted-installer-controller:latest
#!/bin/bash
AI_IMAGE_LIST_FILE=./ai_image_list
ICSP_FILE=./ICSP.yaml
PULL_SECRET=../pull_secret.json
INTERNAL_REG=bm-cluster-1-hyper.e2e.bos.redhat.com:5000
TOTAL_IMAGES=$(cat ${AI_IMAGE_LIST_FILE}| wc -l)
COUNTER=1
function create_ICSP_header() {
cat <<EOF > ${ICSP_FILE}
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
name: redhat-icsp-gen
spec:
repositoryDigestMirrors:
EOF
}
function add_ICSP_entry() {
# Add new entry on ICSP file
IMG_SRC=${1}
IMG_DST=${2}
cat <<EOF >> ${ICSP_FILE}
- mirrors:
- ${IMG_DST%:*}
source: ${IMG_SRC%:*}
EOF
}
function sync_images() {
# Sync Container Images with source file
for image in $(cat ${AI_IMAGE_LIST_FILE}); do
echo "IMAGE: ${image##*/} (${COUNTER}/${TOTAL_IMAGES})"
#HASH=$(sudo skopeo inspect docker://${image} | jq ".Digest" | tr -d '"')
EXTERNAL_REG=${image%%/*}
SRC=${image##/*}
DEST=$(echo $SRC | sed s/${EXTERNAL_REG}/${INTERNAL_REG}/g)
sudo skopeo copy --all --authfile ${PULL_SECRET} --dest-tls-verify=false docker://${SRC} docker://${DEST}
add_ICSP_entry ${SRC} ${DEST}
COUNTER=$((COUNTER+1))
echo
done
}
create_ICSP_header
sync_images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment