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
45 changes: 31 additions & 14 deletions OpenShift/03_create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,49 @@ set -xe
source ../common/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}"
export OPENSHIFT_RELEASE_IMAGE="${OPENSHIFT_RELEASE_IMAGE:-registry.svc.ci.openshift.org/ocp/release:4.2}"
LOGLEVEL="${LOGLEVEL:-info}"

function extract_installer() {
function extract_command() {
local release_image
local cmd
local outdir
local extract_dir

release_image="$1"
outdir="$2"
cmd="$1"
release_image="$2"
outdir="$3"

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"
oc adm release extract --registry-config "${pullsecret_file}" --command=$cmd --to "${extract_dir}" ${release_image}

mv "${extract_dir}/${cmd}" "${outdir}"
rm -rf "${extract_dir}"
rm -rf "${pullsecret_file}"
}

# Let's always grab the `oc` from the release we're using.
function extract_oc() {
extract_dir=$(mktemp -d "installer--XXXXXXXXXX")
extract_command oc "$1" "${extract_dir}"
sudo mv "${extract_dir}/oc" /usr/local/bin
rm -rf "${extract_dir}"
}

function extract_installer() {
local release_image
local outdir

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

extract_command openshift-baremetal-install "$1" "$2"
export OPENSHIFT_INSTALLER="${outdir}/openshift-baremetal-install"
}

# TODO - Provide scripting to help generate install-config.yaml.
# - https://github.com/openshift-kni/install-scripts/issues/19
if [ ! -f install-config.yaml ] ; then
Expand All @@ -39,7 +55,7 @@ if [ ! -f install-config.yaml ] ; then
fi

# Do some PULL_SECRET sanity checking
if [[ "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" == *"registry.svc.ci.openshift.org"* ]]; then
if [[ "${OPENSHIFT_RELEASE_IMAGE}" == *"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
Expand All @@ -51,7 +67,8 @@ if [[ "${PULL_SECRET}" != *"cloud.openshift.com"* ]]; then
fi

mkdir -p ocp
extract_installer "${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE}" ocp/
extract_oc ${OPENSHIFT_RELEASE_IMAGE}
extract_installer "${OPENSHIFT_RELEASE_IMAGE}" ocp/
cp install-config.yaml ocp/
${OPENSHIFT_INSTALLER} --dir ocp --log-level=${LOGLEVEL} create manifests
# TODO - Add custom install time manifests here:
Expand Down