-
Notifications
You must be signed in to change notification settings - Fork 129
Add Konflux build support for node image #1932
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
Draft
redhat-chai-bot
wants to merge
2
commits into
openshift:master
Choose a base branch
from
redhat-chai-bot:ship-help/konflux-build-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−0
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # This builds the OCP node image on top of the base CoreOS image using | ||
| # Konflux. Unlike the main `Containerfile`, this does not use | ||
| # `packages-openshift.yaml` or `rpm-ostree treefile-apply`. Instead, the | ||
| # package list and all postprocess steps are embedded directly in the | ||
| # `konflux-build-node-image.sh` script. | ||
| # | ||
| # This file intentionally does not modify any existing build path — it can | ||
| # coexist with `Containerfile` and `build-node-image.sh` on `master`. | ||
| # | ||
| # See also: https://github.com/openshift/os/pull/1929 | ||
|
|
||
| # TODO: Replace this with the appropriate base image reference for Konflux. | ||
| # For now, use the same base as the main Containerfile. | ||
| FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev:c9s-coreos as build | ||
| RUN --mount=type=bind,target=/run/src --mount=type=secret,id=yumrepos,target=/etc/yum.repos.d/secret.repo /run/src/konflux-build-node-image.sh | ||
|
|
||
| FROM build as metadata | ||
| RUN --mount=type=bind,target=/run/src /run/src/scripts/generate-metadata | ||
|
|
||
| FROM build | ||
| COPY --from=metadata /usr/share/openshift /usr/share/openshift | ||
| LABEL io.openshift.metalayer=true | ||
| LABEL ostree.linux=true |
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,124 @@ | ||
| #!/bin/bash | ||
| set -euxo pipefail | ||
|
|
||
| # This script builds the OpenShift node image for Konflux builds. | ||
| # It's called from `Containerfile.konflux`. | ||
| # | ||
| # Unlike `build-node-image.sh` (which uses rpm-ostree treefile-apply with | ||
| # packages-openshift.yaml), this script uses direct rpm-ostree install and | ||
| # embeds all postprocess steps inline. This keeps the Konflux build path | ||
| # fully independent of the existing CI/Jenkins build path. | ||
| # | ||
| # See also: https://github.com/openshift/os/pull/1929 | ||
|
|
||
| # Avoid shipping modified .pyc files. Due to | ||
| # https://github.com/ostreedev/ostree/issues/1469, any Python apps that | ||
| # run (e.g. dnf) will cause pyc creation. We do this by backing them up and | ||
| # restoring them at the end. | ||
| find /usr -name '*.pyc' -exec mv {} {}.bak \; | ||
|
|
||
| # Install the OCP packages. Repos are expected to be injected via | ||
| # Konflux secrets/mounts in the Containerfile. | ||
| rpm-ostree install \ | ||
| cri-o cri-tools conmon-rs \ | ||
| openshift-clients openshift-kubelet \ | ||
| openvswitch3.5 \ | ||
| NetworkManager-ovs \ | ||
| ose-aws-ecr-image-credential-provider \ | ||
| ose-azure-acr-image-credential-provider \ | ||
| ose-gcp-gcr-image-credential-provider \ | ||
| ose-crio-credential-provider | ||
|
|
||
| # --- postprocess steps --- | ||
| # These are migrated from the `postprocess` section of packages-openshift.yaml. | ||
| # They must run after package installation. | ||
|
|
||
| # Disable any built-in repos. We need to work in disconnected environments by | ||
| # default, and default-enabled repos will be attempted to be fetched by | ||
| # rpm-ostree when doing node-local kernel overrides today for e.g. kernel-rt. | ||
| mkdir -p /etc/yum.repos.d | ||
| for x in $(find /etc/yum.repos.d/ -name '*.repo'); do | ||
| # ignore repo files that are mountpoints since they're likely secrets | ||
| if ! mountpoint "$x"; then | ||
| sed -i -e 's/enabled\s*=\s*1/enabled=0/g' "$x" | ||
| fi | ||
| done | ||
|
|
||
| # Enable librhsm which enables host subscriptions to work in containers | ||
| # https://github.com/rpm-software-management/librhsm/blob/fcd972cbe7c8a3907ba9f091cd082b1090231492/rhsm/rhsm-context.c#L30 | ||
| ln -sr /run/secrets/etc-pki-entitlement /etc/pki/entitlement-host | ||
| ln -sr /run/secrets/rhsm /etc/rhsm-host | ||
|
|
||
| # Manually modify SELinux booleans that are needed for OCP use cases | ||
| semanage boolean --modify --on container_use_cephfs # RHBZ#1694045 | ||
| semanage boolean --modify --on virt_use_samba # RHBZ#1754825 | ||
|
|
||
| # https://gitlab.cee.redhat.com/coreos/redhat-coreos/merge_requests/812 | ||
| # https://bugzilla.redhat.com/show_bug.cgi?id=1796537 | ||
| mkdir -p /usr/share/containers/oci/hooks.d | ||
|
|
||
| # crio conmon symlink | ||
| mkdir -p /usr/libexec/crio | ||
| ln -sr /usr/bin/conmon /usr/libexec/crio/conmon | ||
|
|
||
| # Inject OpenShift-specific release fields | ||
| # NOTE: The OCP version here should be kept in sync with the version used | ||
| # in the branch-specific packages-openshift.yaml. For master, we use | ||
| # the latest version. | ||
| cat >> /usr/lib/os-release <<EOF | ||
| OPENSHIFT_VERSION="4.22" | ||
| EOF | ||
|
|
||
| # Generate MOTD | ||
| . /etc/os-release | ||
| # For Konflux RHCOS builds, we always use the RHCOS variant | ||
| colloquial_name=RHCOS | ||
| project_name=OpenShift | ||
| # in the el-only variants, we already have CoreOS in the NAME, so don't | ||
| # re-add it when building the node image | ||
| if [[ $NAME != *CoreOS* ]]; then | ||
| NAME="$NAME CoreOS" | ||
| fi | ||
| cat > /etc/motd <<EOF | ||
| $NAME $OSTREE_VERSION | ||
| Part of ${project_name} ${OPENSHIFT_VERSION}, ${colloquial_name} is a Kubernetes-native operating system | ||
| managed by the Machine Config Operator (\`clusteroperator/machine-config\`). | ||
|
|
||
| WARNING: Direct SSH access to machines is not recommended; instead, | ||
| make configuration changes via \`machineconfig\` objects: | ||
| https://docs.openshift.com/container-platform/${OPENSHIFT_VERSION}/architecture/architecture-rhcos.html | ||
|
|
||
| --- | ||
| EOF | ||
|
|
||
| # Delete leftover files in the layering path | ||
| if [ -f /run/.containerenv ]; then | ||
| # lockfiles and backup files | ||
| rm -f /etc/.pwd.lock /etc/group- /etc/gshadow- /etc/shadow- /etc/passwd- | ||
| rm -f /etc/selinux/targeted/*.LOCK | ||
| # cache, logs, etc... | ||
| rm -rf /var && mkdir /var | ||
| # All the entries here should instead be part of their respective | ||
| # packages. But we carry them here for now to maintain compatibility. | ||
| cat > /usr/lib/tmpfiles.d/openshift.conf << EOF | ||
| L /opt/cni - - - - ../../usr/lib/opt/cni | ||
| d /var/lib/cni 0755 root root - - | ||
| d /var/lib/cni/bin 0755 root root - - | ||
| d /var/lib/containers 0755 root root - - | ||
| d /var/lib/openvswitch 0755 root root - - | ||
| d /var/lib/openvswitch/pki 0755 root root - - | ||
| d /var/log/openvswitch 0750 openvswitch hugetlbfs - - | ||
| d /var/lib/unbound 0755 unbound unbound - - | ||
| EOF | ||
| fi | ||
|
|
||
| # --- end postprocess steps --- | ||
|
|
||
| # Cleanup any repo files we injected | ||
| rm -f /etc/yum.repos.d/{ocp,git,okd,secret}.repo | ||
|
|
||
| # Restore .pyc files | ||
| find /usr -name '*.pyc.bak' -exec sh -c 'mv $1 ${1%.bak}' _ {} \; | ||
|
|
||
| # Commit the ostree changes | ||
| ostree container commit | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.