Skip to content

Commit

Permalink
Convert OS Image cache to use new install-config interface
Browse files Browse the repository at this point in the history
Since openshift/installer#2757
merged we can mirror the installer referenced images directly
to simulate typical disconnected install scenarios.

This removes some complexity as we no longer need to run the
downloader container on the host, only expose the unprocessed images
via http.

Note this will work with latest 4.4. builds but not 4.3 until
openshift/installer#2835 lands
  • Loading branch information
Steven Hardy committed Dec 18, 2019
1 parent 04bcba7 commit ac99596
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
30 changes: 18 additions & 12 deletions 04_setup_ironic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if [ -f assets/templates/99_local-registry.yaml ] ; then
fi
rm -f $DOCKERFILE

for name in ironic ironic-api ironic-conductor ironic-inspector dnsmasq httpd mariadb ipa-downloader machine-os-downloader vbmc sushy-tools; do
for name in ironic ironic-api ironic-conductor ironic-inspector dnsmasq httpd mariadb ipa-downloader vbmc sushy-tools; do
sudo podman ps | grep -w "$name$" && sudo podman kill $name
sudo podman ps --all | grep -w "$name$" && sudo podman rm $name -f
done
Expand All @@ -69,30 +69,35 @@ fi
# Create pod
sudo podman pod create -n ironic-pod

# Pull the rhcos-downloder image to use from the release, this gets change
# to use IRONIC_MACHINE_OS_DOWNLOADER_LOCAL_IMAGE if present
IRONIC_MACHINE_OS_DOWNLOADER_IMAGE=$(oc adm release info --registry-config $REGISTRY_AUTH_FILE $OPENSHIFT_RELEASE_IMAGE --image-for=ironic-machine-os-downloader)

IRONIC_IMAGE=${IRONIC_LOCAL_IMAGE:-$IRONIC_IMAGE}
IRONIC_IPA_DOWNLOADER_IMAGE=${IRONIC_IPA_DOWNLOADER_LOCAL_IMAGE:-$IRONIC_IPA_DOWNLOADER_IMAGE}
IRONIC_MACHINE_OS_DOWNLOADER_IMAGE=${IRONIC_MACHINE_OS_DOWNLOADER_LOCAL_IMAGE:-$IRONIC_MACHINE_OS_DOWNLOADER_IMAGE}

for IMAGE in ${IRONIC_IMAGE} ${IRONIC_IPA_DOWNLOADER_IMAGE} ${IRONIC_MACHINE_OS_DOWNLOADER_IMAGE} ${VBMC_IMAGE} ${SUSHY_TOOLS_IMAGE} ; do
for IMAGE in ${IRONIC_IMAGE} ${IRONIC_IPA_DOWNLOADER_IMAGE} ${VBMC_IMAGE} ${SUSHY_TOOLS_IMAGE} ; do
sudo -E podman pull $([[ $IMAGE =~ $LOCAL_REGISTRY_ADDRESS.* ]] && echo "--tls-verify=false" ) $IMAGE
done

rm -rf $REGISTRY_AUTH_FILE

CACHED_MACHINE_OS_IMAGE="${IRONIC_DATA_DIR}/html/images/${MACHINE_OS_IMAGE_NAME}"
if [ ! -f "${CACHED_MACHINE_OS_IMAGE}" ]; then
curl -g --insecure -L -o "${CACHED_MACHINE_OS_IMAGE}" "${MACHINE_OS_IMAGE_URL}"
echo "${MACHINE_OS_IMAGE_SHA256} ${CACHED_MACHINE_OS_IMAGE}" | tee ${CACHED_MACHINE_OS_IMAGE}.sha256sum
sha256sum --strict --check ${CACHED_MACHINE_OS_IMAGE}.sha256sum
fi
CACHED_MACHINE_OS_BOOTSTRAP_IMAGE="${IRONIC_DATA_DIR}/html/images/${MACHINE_OS_BOOTSTRAP_IMAGE_NAME}"
if [ ! -f "${CACHED_MACHINE_OS_BOOTSTRAP_IMAGE}" ]; then
curl -g --insecure -L -o "${CACHED_MACHINE_OS_BOOTSTRAP_IMAGE}" "${MACHINE_OS_BOOTSTRAP_IMAGE_URL}"
echo "${MACHINE_OS_BOOTSTRAP_IMAGE_SHA256} ${CACHED_MACHINE_OS_BOOTSTRAP_IMAGE}" | tee ${CACHED_MACHINE_OS_BOOTSTRAP_IMAGE}.sha256sum
sha256sum --strict --check ${CACHED_MACHINE_OS_BOOTSTRAP_IMAGE}.sha256sum
fi

# cached images to the bootstrap VM
sudo podman run -d --net host --privileged --name httpd --pod ironic-pod \
-v $IRONIC_DATA_DIR:/shared --entrypoint /bin/runhttpd ${IRONIC_IMAGE}

sudo podman run -d --net host --privileged --name ipa-downloader --pod ironic-pod \
-v $IRONIC_DATA_DIR:/shared ${IRONIC_IPA_DOWNLOADER_IMAGE} /usr/local/bin/get-resource.sh

sudo podman run -d --net host --privileged --name machine-os-downloader --pod ironic-pod \
-v $IRONIC_DATA_DIR:/shared ${IRONIC_MACHINE_OS_DOWNLOADER_IMAGE} /usr/local/bin/get-resource.sh $MACHINE_OS_IMAGE_URL

if [ "$NODES_PLATFORM" = "libvirt" ]; then
sudo podman run -d --net host --privileged --name vbmc --pod ironic-pod \
-v "$WORKING_DIR/virtualbmc/vbmc":/root/.vbmc -v "/root/.ssh":/root/ssh \
Expand All @@ -106,10 +111,11 @@ fi

# Wait for the downloader containers to finish, if they are updating an existing cache
# the checks below will pass because old data exists
sudo podman wait -i 1000 ipa-downloader machine-os-downloader
sudo podman wait -i 1000 ipa-downloader

# Wait for images to be downloaded/ready
while ! curl --fail http://localhost/images/rhcos-ootpa-latest.qcow2.md5sum ; do sleep 1 ; done
while ! curl --fail http://localhost/images/${MACHINE_OS_IMAGE_NAME}.sha256sum ; do sleep 1 ; done
while ! curl --fail http://localhost/images/${MACHINE_OS_BOOTSTRAP_IMAGE_NAME}.sha256sum ; do sleep 1 ; done
while ! curl --fail --head http://localhost/images/ironic-python-agent.initramfs ; do sleep 1; done
while ! curl --fail --head http://localhost/images/ironic-python-agent.tar.headers ; do sleep 1; done
while ! curl --fail --head http://localhost/images/ironic-python-agent.kernel ; do sleep 1; done
14 changes: 8 additions & 6 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export VM_EXTRADISKS=${VM_EXTRADISKS:-"false"}
# Ironic vars (Image can be use <NAME>_LOCAL_IMAGE to override)
export IRONIC_IMAGE="quay.io/metal3-io/ironic:master"
export IRONIC_IPA_DOWNLOADER_IMAGE="quay.io/metal3-io/ironic-ipa-downloader:master"
export IRONIC_DATA_DIR="$WORKING_DIR/ironic"
export IRONIC_DATA_DIR="${WORKING_DIR}/ironic"
export IRONIC_IMAGES_DIR="${IRONIC_DATA_DIR}/html/images"

# VBMC and Redfish images
export VBMC_IMAGE=${VBMC_IMAGE:-"quay.io/metal3-io/vbmc"}
Expand Down Expand Up @@ -197,11 +198,12 @@ if [ ! -d "$WORKING_DIR" ]; then
chmod 755 "$WORKING_DIR"
fi

if [ ! -d "$IRONIC_DATA_DIR" ]; then
echo "Creating Ironic Data Dir"
sudo mkdir "$IRONIC_DATA_DIR"
sudo chown "${USER}:${USER}" "$IRONIC_DATA_DIR"
chmod 755 "$IRONIC_DATA_DIR"
if [ ! -d "$IRONIC_IMAGES_DIR" ]; then
echo "Creating Ironic Images Dir"
sudo mkdir -p "$IRONIC_IMAGES_DIR"
sudo chown -R "${USER}:${USER}" "$IRONIC_DATA_DIR"
sudo find $IRONIC_DATA_DIR -type d -print0 | xargs -0 chmod 755
sudo chmod -R +r $IRONIC_DATA_DIR
fi

# Defaults the variable to enable testing a custom machine-api-operator image
Expand Down
3 changes: 3 additions & 0 deletions ocp_install_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export CLUSTER_DOMAIN="${CLUSTER_NAME}.${BASE_DOMAIN}"
export SSH_PUB_KEY="${SSH_PUB_KEY:-$(cat $HOME/.ssh/id_rsa.pub)}"
export NETWORK_TYPE=${NETWORK_TYPE:-"OpenShiftSDN"}
export EXTERNAL_SUBNET=${EXTERNAL_SUBNET:-"192.168.111.0/24"}
export MIRROR_IP=${MIRROR_IP:-"192.168.111.1"}
export DNS_VIP=${DNS_VIP:-"192.168.111.2"}

function extract_command() {
Expand Down Expand Up @@ -96,6 +97,8 @@ controlPlane:
baremetal: {}
platform:
baremetal:
bootstrapOSImage: http://${MIRROR_IP}/images/${MACHINE_OS_BOOTSTRAP_IMAGE_NAME}?sha256=${MACHINE_OS_BOOTSTRAP_IMAGE_SHA256}
clusterOSImage: http://${MIRROR_IP}/images/${MACHINE_OS_IMAGE_NAME}?sha256=${MACHINE_OS_BOOTSTRAP_IMAGE_SHA256}
dnsVIP: ${DNS_VIP}
hosts:
$(master_node_map_to_install_config $NUM_MASTERS)
Expand Down
11 changes: 10 additions & 1 deletion rhcos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ OPENSHIFT_INSTALLER_MACHINE_OS=${OPENSHIFT_INSTALLER_MACHINE_OS:-https://raw.git

# Get the rhcos.json for that commit, and find the baseURI and openstack image path
MACHINE_OS_IMAGE_JSON=$(curl "${OPENSHIFT_INSTALLER_MACHINE_OS}")

export MACHINE_OS_INSTALLER_IMAGE_URL=$(echo "${MACHINE_OS_IMAGE_JSON}" | jq -r '.baseURI + .images.openstack.path')
export MACHINE_OS_INSTALLER_IMAGE_SHA256=$(echo "${MACHINE_OS_IMAGE_JSON}" | jq -r '.images.openstack.sha256')
export MACHINE_OS_IMAGE_URL=${MACHINE_OS_IMAGE_URL:-${MACHINE_OS_INSTALLER_IMAGE_URL}}
export MACHINE_OS_IMAGE_FILENAME_LATEST="rhcos-ootpa-latest.qcow2"
export MACHINE_OS_IMAGE_NAME=$(basename ${MACHINE_OS_IMAGE_URL})
export MACHINE_OS_IMAGE_SHA256=${MACHINE_OS_IMAGE_SHA256:-${MACHINE_OS_INSTALLER_IMAGE_SHA256}}

export MACHINE_OS_INSTALLER_BOOTSTRAP_IMAGE_URL=$(echo "${MACHINE_OS_IMAGE_JSON}" | jq -r '.baseURI + .images.qemu.path')
export MACHINE_OS_INSTALLER_BOOTSTRAP_IMAGE_SHA256=$(echo "${MACHINE_OS_IMAGE_JSON}" | jq -r '.images.qemu.sha256')
export MACHINE_OS_BOOTSTRAP_IMAGE_URL=${MACHINE_OS_BOOTSTRAP_IMAGE_URL:-${MACHINE_OS_INSTALLER_BOOTSTRAP_IMAGE_URL}}
export MACHINE_OS_BOOTSTRAP_IMAGE_NAME=$(basename ${MACHINE_OS_BOOTSTRAP_IMAGE_URL})
export MACHINE_OS_BOOTSTRAP_IMAGE_SHA256=${MACHINE_OS_BOOTSTRAP_IMAGE_SHA256:-${MACHINE_OS_INSTALLER_BOOTSTRAP_IMAGE_SHA256}}
3 changes: 1 addition & 2 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ function bmo_config_map {

mkdir -p ocp/deploy
cp $SCRIPTDIR/metal3-config.yaml ocp/deploy
sed -i "s#__MACHINE_OS_IMAGE_URL__#${MACHINE_OS_IMAGE_URL}#" ocp/deploy/metal3-config.yaml
sed -i "s#__MACHINE_OS_IMAGE_URL__#http://${MIRROR_IP}/images/${MACHINE_OS_IMAGE_NAME}?sha256=${MACHINE_OS_BOOTSTRAP_IMAGE_SHA256}#" ocp/deploy/metal3-config.yaml
sed -i "s#provisioning_interface: \"ens3\"#provisioning_interface: \"${CLUSTER_PRO_IF}\"#" ocp/deploy/metal3-config.yaml
sed -i "s#cache_url: \"http://192.168.111.1/images\"#cache_url: \"http://${BAREMETAL_IP}/images\"#" ocp/deploy/metal3-config.yaml

cp ocp/deploy/metal3-config.yaml assets/generated/99_metal3-config.yaml
}

0 comments on commit ac99596

Please sign in to comment.