-
Notifications
You must be signed in to change notification settings - Fork 200
Fetch kni-installer binary from a release payload #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b1a455c
Add script for building release payloads
markmc 5caa909
Add script for building installer images
markmc c959b3c
Include kni-install in custom release payload
markmc abec978
Document the installer and release build process
markmc 44ea0ea
Don't get the RHCOS image URL from kni-installer
markmc 0130f7a
Extract kni-install from release payload
markmc df675eb
Minor tweaks to prep_release.sh
markmc bacc2fd
Add a proper release name for our releases
markmc 294ef8e
Make prep_release.sh a little more generic
markmc 9b51e53
Pin to release payload with our installer
markmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Publishing a KNI Release Payload | ||
|
|
||
| OpenShift publishes a release payload image which includes information | ||
| about cluster operator images and their resource manifests, along with | ||
| references to installer and CLI images. The recommended method for | ||
| obtaining an installer binary is to first choose a release version and | ||
| then use the `oc adm release extract --tools` command to extract the | ||
| installer binary from the release payload. | ||
|
|
||
| Since KNI has temporarily forked the installer, we build custom and | ||
| publish custom release payloads that include a reference to the forked | ||
| installer. | ||
|
|
||
| ## Preparation and Configuration | ||
|
|
||
| We build and publish within a namespace on an OpenShift | ||
| cluster. First, prepare a `kubeconfig` with credentials to this | ||
| cluster, and with the desired namespace set as the default: | ||
|
|
||
| ``` | ||
| $ oc --config=release-kubeconfig login https://api.ci.openshift.org --token=... | ||
| $ oc --config=release-kubeconfig new-project kni | ||
| $ oc --config=release-kubeconfig project kni | ||
| $ oc --config=release-kubeconfig adm policy add-role-to-user admin <other admin> | ||
stbenjam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ```` | ||
|
|
||
| We need a docker registry credentials file which contains credentials | ||
| for the registry on this OpenShift cluster: | ||
|
|
||
| ``` | ||
| $ oc --config=release-kubeconfig registry login --to=release-pullsecret | ||
| ``` | ||
|
|
||
| But also, we need credentials for any registry hosting images | ||
| referenced from release payloads (e.g. ```quay.io```) | ||
|
|
||
| ``` | ||
| $ TOKEN=$((. ../config_$USER.sh && echo $PULL_SECRET) 2>/dev/null | jq -r '.auths["quay.io"].auth' | base64 -d) | ||
| $ podman login --authfile=release-pullsecret -u ${TOKEN%:*} -p ${TOKEN#*:} quay.io | ||
| ``` | ||
|
|
||
| Images are published to imagestream tags, and we need an image stream | ||
| for our installer builds and our custom release payloads: | ||
|
|
||
| ``` | ||
| $ oc --config=release-kubeconfig create imagestream release | ||
| $ oc --config=release-kubeconfig create imagestream installer | ||
| ``` | ||
|
|
||
| We need to create a ```docker-registry``` secret so the image stream | ||
| can import referenced images: | ||
|
|
||
| ``` | ||
| $ oc --config=release-kubeconfig \ | ||
| create secret docker-registry quay-pullsecret \ | ||
| --docker-server=quay.io \ | ||
| --docker-username=${TOKEN%:*} \ | ||
| --docker-password=${TOKEN#*:} | ||
| ``` | ||
|
|
||
| Finally, create a ```release_config_$USER.sh``` file with information | ||
| about all of the above: | ||
|
|
||
| ``` | ||
| $ cat > release_config_$USER.sh <<EOF | ||
| RELEASE_NAMESPACE=kni | ||
| RELEASE_STREAM=release | ||
| INSTALLER_STREAM=installer | ||
| RELEASE_KUBECONFIG=release-kubeconfig | ||
| RELEASE_PULLSECRET=release-pullsecret | ||
| INSTALLER_GIT_URI=https://github.com/openshift-metal3/kni-installer.git | ||
| INSTALLER_GIT_REF=master | ||
| EOF | ||
| ``` | ||
|
|
||
| ## Building an Installer and Payload | ||
|
|
||
| When we want to move to a newer OpenShift release, we pick a release | ||
| payload: | ||
|
|
||
| ``` | ||
| $ oc adm release info quay.io/openshift-release-dev/ocp-release:4.1.0-rc.3 -a release-pullsecret -o json | jq -r .metadata.version | ||
| 4.1.0-rc.3 | ||
| ``` | ||
|
|
||
| Next, rebase ```openshift-metal3/kni-installer``` to the | ||
| ```openshift/installer``` commit referenced by that payload: | ||
|
|
||
| ``` | ||
| $ oc adm release info -a release-pullsecret -o json \ | ||
| quay.io/openshift-release-dev/ocp-release:4.1.0-rc.3 | \ | ||
| jq -r '.references.spec.tags[] | select(.name == "installer") | .annotations["io.openshift.build.commit.id"]' | ||
| 403a93d1f683384800597ac38e9c2fc0180b3a5d | ||
| ``` | ||
|
|
||
| And then kick off a build, with the resulting image tagged into the | ||
| installer image stream using the supplied version as the tag: | ||
|
|
||
| ``` | ||
| $ ./build_installer.sh 4.1.0-rc.3-kni.0 | ||
| ``` | ||
|
|
||
| Now, finally, we can build a new payload referencing our installer, | ||
| and tag it into the release imagestream: | ||
|
|
||
| ``` | ||
| $ ./prep_release.sh \ | ||
| 4.1.0-rc.3-kni.1 \ | ||
| quay.io/openshift-release-dev/ocp-release:4.1.0-rc.3 \ | ||
| installer=registry.svc.ci.openshift.org/kni/installer:4.1.0-rc.3-kni.0 \ | ||
| baremetal-machine-controllers=quay.io/openshift-metal3/baremetal-machine-controllers@sha256:1faf4a863b261c948f5f38c148421603f51c74cbf44142882826ee6cb37d8bd3 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/usr/bin/env bash | ||
| set -xe | ||
|
|
||
| # | ||
| # Build a new installer image | ||
| # | ||
| # See release_config_example.sh for required configuration steps | ||
| # | ||
|
|
||
| SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| USER=`whoami` | ||
|
|
||
| # Get variables from the config file | ||
| if [ -z "${RELEASE_CONFIG:-}" ]; then | ||
| # See if there's a release_config_$USER.sh in the SCRIPTDIR | ||
| if [ -f "${SCRIPTDIR}/release_config_${USER}.sh" ]; then | ||
| echo "Using RELEASE_CONFIG ${SCRIPTDIR}/release_config_${USER}.sh" | ||
| RELEASE_CONFIG="${SCRIPTDIR}/release_config_${USER}.sh" | ||
| else | ||
| echo "Please run with a configuration environment set." >&2 | ||
| echo "eg RELEASE_CONFIG=release_config_example.sh $0" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
| source $RELEASE_CONFIG | ||
|
|
||
| INSTALLER_VERSION="$1" | ||
| if [ -z "${INSTALLER_VERSION}" ]; then | ||
| echo "usage: $0 <installer version>" >&2 | ||
| echo "example: $0 4.0.0-0.9" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Building kni-installer from ${INSTALLER_GIT_URI}:${INSTALLER_GIT_REF} to ${INSTALLER_STREAM}:${INSTALLER_VERSION}" | ||
|
|
||
| # Check prerequisites | ||
| if [ $(oc --config "${RELEASE_KUBECONFIG}" project -q) != "${RELEASE_NAMESPACE}" ]; then | ||
| echo "Wrong namespace configured, run 'oc --config ${RELEASE_KUBECONFIG} project ${RELEASE_NAMESPACE}'" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! oc --config "${RELEASE_KUBECONFIG}" get imagestream "${INSTALLER_STREAM}" 2>/dev/null; then | ||
| echo "No '${INSTALLER_STREAM}' imagestream in '${RELEASE_NAMESPACE}' namespace" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| oc --config "${RELEASE_KUBECONFIG}" apply -f - <<EOF | ||
| apiVersion: build.openshift.io/v1 | ||
| kind: Build | ||
| metadata: | ||
| name: kni-installer-${INSTALLER_VERSION} | ||
| spec: | ||
| source: | ||
| type: Git | ||
| git: | ||
| uri: ${INSTALLER_GIT_URI} | ||
| ref: ${INSTALLER_GIT_REF} | ||
| strategy: | ||
| type: Docker | ||
| dockerStrategy: | ||
| imageOptimizationPolicy: SkipLayers | ||
| dockerfilePath: images/baremetal/Dockerfile.ci | ||
| output: | ||
| to: | ||
| kind: ImageStreamTag | ||
| name: ${INSTALLER_STREAM}:${INSTALLER_VERSION} | ||
| EOF | ||
|
|
||
| BUILD_POD=$(oc --config "${RELEASE_KUBECONFIG}" get build "kni-installer-${INSTALLER_VERSION}" -o json | jq -r '.metadata.annotations["openshift.io/build.pod-name"]') | ||
| oc --config "${RELEASE_KUBECONFIG}" wait --for condition=Ready pod "${BUILD_POD}" | ||
| oc --config "${RELEASE_KUBECONFIG}" logs -f "${BUILD_POD}" | ||
|
|
||
| BUILD_PHASE=$(oc --config release-kubeconfig get build "kni-installer-${INSTALLER_VERSION}" -o json | jq -r .status.phase) | ||
| if [ "${BUILD_PHASE}" = "Complete" ]; then | ||
| BUILD_OUTPUT=$(oc --config release-kubeconfig get build "kni-installer-${INSTALLER_VERSION}" -o json | jq -r .status.output.to.imageDigest) | ||
| echo "Installer built to ${BUILD_OUTPUT}" | ||
| else | ||
| echo "Installer build failed? Build phase is ${BUILD_PHASE}" | ||
| fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.