Skip to content

Commit 83f0f4e

Browse files
authored
Add support for mirroring OLM operators (#1332)
* Add support for mirroring OLM operators In disconnected deployments (like ipv6) we need to mirror any OLM operators that we want to install because the OLM images aren't otherwise available. This patch adds a MIRROR_OLM configuration variable that will create a pruned index containing only the relevant operators in the local registry. The mirroring process generates a couple of manifests needed to use the mirrored index, and these files are added to the deployment manifests directory so it will be usable immediately. * Install opm client when mirroring OLM images This is required in order to prune the image list so we don't pull down all of the OLM operator images. It's a fairly simple install, so let's automate it so there's no additional steps needed to use the feature. * Document MIRROR_OLM config value
1 parent d842f1b commit 83f0f4e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

04_setup_ironic.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,30 @@ if [ ! -z "${MIRROR_IMAGES}" ]; then
134134
IRONIC_RELEASE_IMAGE=$(image_for ironic | cut -d '@' -f2)
135135
LOCAL_REGISTRY_PREFIX="${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}/localimages/local-release-image"
136136
IRONIC_LOCAL_IMAGE=${IRONIC_LOCAL_IMAGE:-"${LOCAL_REGISTRY_PREFIX}@${IRONIC_RELEASE_IMAGE}"}
137+
138+
if [ -n "${MIRROR_OLM:-}" ]; then
139+
echo "Installing OPM client"
140+
VERSION="$(openshift_version ${OCP_DIR})"
141+
OLM_DIR=$(mktemp --tmpdir -d "mirror-olm--XXXXXXXXXX")
142+
_tmpfiles="$_tmpfiles $OLM_DIR"
143+
144+
pushd $OLM_DIR
145+
curl -O https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/${VERSION}.0/opm-linux.tar.gz
146+
tar xf opm-linux.tar.gz
147+
sudo mv -f opm /usr/local/bin
148+
popd
149+
150+
echo "Mirroring OLM operator(s): ${MIRROR_OLM}"
151+
REGISTRY_AUTH_FILE=${PULL_SECRET_FILE} opm index prune -f registry.redhat.io/redhat/redhat-operator-index:v${VERSION} -p ${MIRROR_OLM} -t ${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}/localimages/redhat-operator-index:v${VERSION}
152+
153+
podman push --authfile ${PULL_SECRET_FILE} ${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}/localimages/redhat-operator-index:v${VERSION}
154+
155+
oc adm catalog mirror ${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}/localimages/redhat-operator-index:v${VERSION} ${LOCAL_REGISTRY_DNS_NAME}:${LOCAL_REGISTRY_PORT}/olm -a $PULL_SECRET_FILE --to-manifests=${OLM_DIR}
156+
157+
mkdir -p ${OCP_DIR}/manifests
158+
cp -a ${OLM_DIR}/catalogSource.yaml ${OCP_DIR}/manifests
159+
cp -a ${OLM_DIR}/imageContentSourcePolicy.yaml ${OCP_DIR}/manifests
160+
fi
137161
fi
138162

139163
for name in ironic ironic-api ironic-conductor ironic-inspector dnsmasq httpd-${PROVISIONING_NETWORK_NAME} mariadb ipa-downloader; do

config_example.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ set -x
7676
# for an IPv4 install.
7777
#export MIRROR_IMAGES=true
7878

79+
# Comma-separated list of OLM operators to mirror into the local registry. This
80+
# has no effect if MIRROR_IMAGES is false.
81+
# This will not work for releases that have not yet shipped. The content for
82+
# the release must have been published in order for mirroring to work.
83+
#export MIRROR_OLM=kubernetes-nmstate-operator
84+
7985
# Ensure that the local registry will be available
8086
#export ENABLE_LOCAL_REGISTRY=true
8187

0 commit comments

Comments
 (0)