Skip to content
This repository was archived by the owner on Mar 23, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions 03_create_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
set -xe

source logging.sh
source common.sh

export OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE="${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE:-registry.svc.ci.openshift.org/ocp/release:4.2}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When openshift/oc#57 merges, we'll no longer set OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE so you could do e.g.

export OPENSHIFT_RELEASE_IMAGE=...

extract_installer $OPENSHIFT_RELEASE_IMAGE ...

# FIXME: remove OPENSHIFT_INSTALL_RELASE_IMAGE_OVERRIDE when openshift/oc#57 merges
OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE=$OPENSHIFT_RELEASE_IMAGE ${OPENSHIFT_INSTALLER} ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just copied the current version of what's done in dev-scripts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern indeed looks nicer 👍


function extract_installer() {
local release_image
local outdir

release_image="$1"
outdir="$2"

extract_dir=$(mktemp -d "installer--XXXXXXXXXX")
pullsecret_file=$(mktemp "pullsecret--XXXXXXXXXX")

echo "${PULL_SECRET}" > "${pullsecret_file}"
# FIXME: Find the pullspec for baremetal-installer image and extract the image, until
# https://github.com/openshift/oc/pull/57 is merged
baremetal_image=$(oc adm release info --registry-config "${pullsecret_file}" $OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE -o json | jq -r '.references.spec.tags[] | select(.name == "baremetal-installer") | .from.name')
oc image extract --registry-config "${pullsecret_file}" $baremetal_image --path usr/bin/openshift-install:${extract_dir}

chmod 755 "${extract_dir}/openshift-install"
mv "${extract_dir}/openshift-install" "${outdir}"
export OPENSHIFT_INSTALLER="${outdir}/openshift-install"

rm -rf "${extract_dir}"
rm -rf "${pullsecret_file}"
}

# TODO - Provide scripting to help generate install-config.yaml.
# - https://github.com/openshift-kni/install-scripts/issues/19
if [ ! -f install-config.yaml ] ; then
echo "Please create install-config.yaml"
exit 1
fi

# Do some PULL_SECRET sanity checking
if [[ "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" == *"registry.svc.ci.openshift.org"* ]]; then
if [[ "${PULL_SECRET}" != *"registry.svc.ci.openshift.org"* ]]; then
echo "Please get a valid pull secret for registry.svc.ci.openshift.org."
exit 1
fi
fi
if [[ "${PULL_SECRET}" != *"cloud.openshift.com"* ]]; then
echo "Please get a valid pull secret for cloud.openshift.com."
exit 1
fi

mkdir -p ocp
extract_installer "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" ocp/
cp install-config.yaml ocp/
${OPENSHIFT_INSTALLER} --dir ocp create manifests
# TODO - Add custom install time manifests here:
# - https://github.com/openshift-kni/install-scripts/issues/30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment in #30 - I'm unclear whether using create manifests is a temporary workaround or something we have to live with while we're using OpenShift 4.2

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's something we have to live with during 4.2, because a couple of things (most notably the ConfigMap required to start the BMO/Ironic containers via the MAO, and the BaremetalHost CRD) need to be added which aren't currently integrated into the installer.

We expect that integration work to be completed in the 4.3 timeframe, but for now I think we've got no option than to inject these pieces via manifests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Russell suggested re-looking at the BMO config map issue - #30 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can drop it from this script for now while we sort it out. The install won't work successfully without it though. The machine-api-operator will fail to come up, because the metal3 deployment it manages will be busted without its config.

${OPENSHIFT_INSTALLER} --dir ocp create cluster