Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions .github/workflows/build-rpms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## MicroShift Bootc Image

Load the image using the following command:

```bash
sudo podman load -i microshift-bootc-image-x86_64.tgz
```

Review the instructions in [Run MicroShift Upstream](../../docs/run.md) to run the image.
169 changes: 115 additions & 54 deletions .github/workflows/build-rpms.yaml
Original file line number Diff line number Diff line change
@@ -1,92 +1,153 @@
name: Trigger Microshift upstream build
name: MicroShift RPM and Container Image Builder

on:
workflow_dispatch:
inputs:
okd-version:
default: "4.18.0-okd-scos.4"
description: okd release from https://quay.io/repository/okd/scos-release?tab=tags
ushift-branch:
default: "main"
description: MicroShift branch from https://github.com/openshift/microshift/branches
type: string
okd-version-tag:
default: "4.19.0-okd-scos.19"
description: OKD version tag from https://quay.io/repository/okd/scos-release?tab=tags
type: string
action:
type: choice
description: what to do?
default: run-in-bootc-container
options:
- build-upstream-rpms
- run-in-bootc-container
description: Action to perform
default: build-all
options:
- build-all
- build-rpms
- build-bootc-image

jobs:
build:
strategy:
matrix:
#disabled arm runner because images for arm no available in okd payload- see USHIFT-5570
# The ARM runner is disabled because OKD images for ARM are not available.
# See USHIFT-5570
runners: [ubuntu-24.04]
name: build microshift upstream
name: Build MicroShift upstream
runs-on: ${{ matrix.runners }}
steps:
- name: Check out microshift-upstream CI repository
- name: Check out MicroShift upstream repository
uses: actions/checkout@v4

- name: Check out microshift repository
uses: actions/checkout@v4
with:
repository: openshift/microshift
path: microshift
ref: main
- name: Prepare the build and run environment
shell: bash
run: |
# The /dev/sdb1 partition is mounted as /mnt.
sudo mkdir -p /mnt/tmp /mnt/rpms /mnt/storage /mnt/release
sudo chmod 1777 /mnt/tmp

- name: Add cwd to path for kubectl.
run: echo `pwd` >> $GITHUB_PATH
sudo apt-get install -y make lvm2 podman

- name: Build Microshift RPMs and Container
# Redirect the container build directories to /mnt/ to avoid running out of disk space.
sudo mv /var/tmp /var/tmp.orig
sudo mv /var/lib/containers/storage /var/lib/containers/storage.orig
sudo ln -s /mnt/tmp /var/tmp
sudo ln -s /mnt/storage /var/lib/containers/storage

- name: Build MicroShift RPMs
if: inputs.action == 'build-rpms' || inputs.action == 'build-all'
shell: bash
run: |
# /dev/sdb1 is mounted as /mnt - disk space needed for the podman build containers layers.
sudo mkdir -p /mnt/tmp/output
# See https://github.com/microshift-io/microshift/blob/main/docs/build.md
# for more information about the build process.

# Raise open file limits to avoid "too many open files" errors.
ulimit -n 65536

# Run the RPM build process.
cd ${GITHUB_WORKSPACE}/
make rpm \
USHIFT_BRANCH=${{ inputs.ushift-branch }} \
OKD_VERSION_TAG=${{ inputs.okd-version-tag }} \
RPM_OUTDIR=/mnt/rpms

- name: Build MicroShift bootc container image
if: inputs.action == 'build-bootc-image' || inputs.action == 'build-all'
shell: bash
run: |
# See https://github.com/microshift-io/microshift/blob/main/docs/build.md
# for more information about the build process.

# Raise open file limits to avoid "too many open files" errors.
ulimit -n 65536

# Run the container image build process, first cleaning up any
# existing container images to generate a smaller artifact.
cd ${GITHUB_WORKSPACE}/
sudo apt-get install podman -y
export OKD_REPO=quay.io/okd/scos-release
# podman version applies bad ulimits default causing "too many open files" errors so we override ulimits.
TMPDIR=/mnt/tmp sudo podman build --layers=false --ulimit nofile=65536:65536 \
--build-arg OKD_VERSION_TAG=${{ inputs.okd-version }} \
--build-arg OKD_REPO=${OKD_REPO} \
--env WITH_TOPOLVM=1 \
--env WITH_KINDNET=1 \
--env OUTPUT_DIR=/output \
-f microshift-okd-multi-build.Containerfile \
-t microshift-okd \
-v /mnt/tmp/output:/output:z .
- name: run test verifying that Microshift is running
if: inputs.action == 'run-in-bootc-container'
make clean image \
USHIFT_BRANCH=${{ inputs.ushift-branch }} \
OKD_VERSION_TAG=${{ inputs.okd-version-tag }}

- name: Run a test to verify that MicroShift is functioning properly.
if: inputs.action == 'build-bootc-image' || inputs.action == 'build-all'
shell: bash
run: |
sudo apt-get -y install lvm2
sudo truncate --size=20G /tmp/lvmdisk
sudo losetup -f /tmp/lvmdisk
device_name=$(losetup -j /tmp/lvmdisk | cut -d: -f1)
sudo vgcreate -f -y myvg1 ${device_name}
sudo lvcreate -T myvg1/thinpool -L 6G
sudo podman run --privileged --rm --name microshift-okd --volume /dev:/dev:rslave --hostname 127.0.0.1.nip.io -d microshift-okd
sleep 3
# wait until everything is running
sudo podman exec -ti microshift-okd bash -c 'microshift healthcheck --namespace topolvm-system --deployments topolvm-controller'
- name: prepare release acrhive
# See https://github.com/microshift-io/microshift/blob/main/docs/run.md
# for more information about the run process.

# Prepare the TopoLVM CSI backend on the host to be used by MicroShift when compiled with the default `WITH_TOPOLVM=1` built option.
LVM_DISK=/mnt/lvmdisk.image
VG_NAME=myvg1

sudo truncate --size=1G "${LVM_DISK}"
sudo losetup -f "${LVM_DISK}"

DEVICE_NAME="$(sudo losetup -j "${LVM_DISK}" | cut -d: -f1)"
sudo vgcreate -f -y "${VG_NAME}" "${DEVICE_NAME}"

# Run the MicroShift container.
make run && sleep 5

# Wait until everything is up and running.
sudo podman exec -it microshift-okd \
bash -c 'microshift healthcheck -v=2 --timeout=600s --namespace topolvm-system --deployments topolvm-controller'

# Stop the MicroShift container.
make stop

- name: Prepare the RPM archive.
if: inputs.action == 'build-rpms' || inputs.action == 'build-all'
shell: bash
run : |
cd /mnt/tmp/output/rpmbuild/RPMS/
sudo zip microshift-x86_64.zip \
cd /mnt/rpms
find . -type f -name "microshift-*.rpm"

sudo tar zcvf /mnt/release/microshift-rpms-x86_64.tgz \
x86_64/microshift-[0-9]*.rpm \
x86_64/microshift-topolvm-*.rpm \
x86_64/microshift-networking-*.rpm \
x86_64/microshift-kindnet-*.rpm \
noarch/microshift-release-info-*.rpm \
noarch/microshift-greenboot-*.rpm \
noarch/microshift-selinux-*.rpm \
noarch/microshift-topolvm-*.rpm \
noarch/microshift-kindnet-*.rpm

- name: Prepare the bootc image archive.
if: inputs.action == 'build-bootc-image' || inputs.action == 'build-all'
shell: bash
run : |
sudo bash -c \
'podman save microshift-okd | gzip > /mnt/release/microshift-bootc-image-x86_64.tgz'

- name: Release RPMs.
if: inputs.action == 'build-rpms' || inputs.action == 'build-all'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.ushift-branch }}-${{ inputs.okd-version-tag }}
files: |
/mnt/release/microshift-rpms-x86_64.tgz
overwrite_files: true

- name: Release if the previous test passed
- name: Release bootc image.
if: inputs.action == 'build-bootc-image' || inputs.action == 'build-all'
uses: softprops/action-gh-release@v2
with:
tag_name: 4.19.0
tag_name: ${{ inputs.ushift-branch }}-${{ inputs.okd-version-tag }}
files: |
/mnt/tmp/output/rpmbuild/RPMS/microshift-x86_64.zip
/mnt/release/microshift-bootc-image-x86_64.tgz
overwrite_files: true
body_path: .github/workflows/build-rpms.md
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ run:
sudo podman run --privileged --rm -d \
--name microshift-okd \
--volume /dev:/dev:rslave \
--hostname 127.0.0.1.nip.io \
microshift-okd

.PHONY: login
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ The goal is to enable contributors and testers to work with an upstream build of
set up using OKD components, making it easier to develop, verify, and iterate on features
outside the downstream Red Hat payloads.

## Build and Run
## Documentation

* [Build MicroShift Upstream](./docs/build.md)
* [Run MicroShift Upstream](./docs/run.md)
* [GitHub Workflows](./docs/workflows.md)
34 changes: 34 additions & 0 deletions docs/workflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## GitHub Workflows

The following GitHub workflows are defined at the `.github/workflows` folder:
* `MicroShift RPM and Container Image Builder` in `build-rpms.yaml`

These workflows can be run under the [Actions](https://github.com/microshift-io/microshift/actions)
tab by the repository maintainers. Other contributors can
[create a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository)
from the [MicroShift Upstream](https://github.com/microshift-io/microshift) repository
and run existing or create new workflows in their private repository branches.

The remainder of this document describes the existing workflows and their functionality.

### MicroShift RPM and Container Image Builder

The workflow implements a build process producing MicroShift RPM and Bootc
container image artifacts.

The following parameters determine the MicroShift source code branch and OKD
container dependencies used during the build process.
* MicroShift branch from https://github.com/openshift/microshift/branches
* OKD version tag from https://quay.io/repository/okd/scos-release?tab=tags

The following actions are suppported.
* `build-all`: Builds both MicroShift RPMs and Bootc container images
* `build-rpms`: Builds only the MicroShift RPM packages
* `build-bootc-images`: Builds only the Bootc container images

Note: When the Bootc container images are built, one of the workflow steps tests
the validity of the produced artifacts by attempting to run the container image
and making sure all the MicroShift services are functional.

The build artifacts are available for download under [Releases](https://github.com/microshift-io/microshift/releases)
after the job finishes successfully.
20 changes: 0 additions & 20 deletions gh-workflows/README.md

This file was deleted.

Binary file removed gh-workflows/build-upstream-rpms-only.png
Binary file not shown.
68 changes: 0 additions & 68 deletions gh-workflows/microshift-build-example.yaml

This file was deleted.

Binary file removed gh-workflows/run-in-bootc-container.png
Binary file not shown.
2 changes: 1 addition & 1 deletion packaging/microshift-cos9.Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN echo '{"auths":{"fake":{"auth":"aWQ6cGFzcwo="}}}' > /tmp/.pull-secret && \

# Building Microshift RPMs and local repo
RUN WITH_KINDNET="${WITH_KINDNET}" WITH_TOPOLVM="${WITH_TOPOLVM}" WITH_OLM="${WITH_OLM}" \
make rpm srpm && \
make rpm && \
createrepo -v "${REPO_DIR}"

# Building microshift container from local RPMs
Expand Down