Skip to content
Open
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Notes:

Prebuilt MicroShift artifacts are published at the
[Releases](https://github.com/microshift-io/microshift/releases) page.
Nightly MicroShift RPMs are published on the COPR
[@microshift-io/microshift-nightly](https://copr.fedorainfracloud.org/coprs/g/microshift-io/microshift-nightly/).
MicroShift can be run on the host or inside a Bootc container.

* Install the [latest](https://github.com/microshift-io/microshift/releases/latest)
Expand All @@ -48,6 +50,12 @@ MicroShift can be run on the host or inside a Bootc container.
curl -s https://microshift-io.github.io/microshift/quickrpm.sh | sudo bash
```

* Install nightly MicroShift RPM packages on your host and start the MicroShift service.

```bash
curl -s https://microshift-io.github.io/microshift/quickrpm.sh | sudo env RPM_SOURCE=copr-nightly bash
```

* Bootstrap the [latest](https://github.com/microshift-io/microshift/releases/latest)
MicroShift build inside a Bootc container on your host.

Expand Down
34 changes: 25 additions & 9 deletions docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ inside a Bootc container.

### Install RPM

The following optional RPM packages are available in the repository. It is
mandatory to install either `microshift-kindnet` or `microshift-networking`
to enable the Kindnet or OVN-K networking support.

| Package | Description | Comments |
|-----------------------|----------------------------|----------|
| microshift-kindnet | Kindnet CNI | Overrides OVN-K |
| microshift-networking | OVN-K CNI | Uninstall Kindnet to enable OVN-K |
| microshift-topolvm | TopoLVM CSI | Install to enable storage support |
| microshift-olm | Operator Lifecycle Manager | See [Operator Hub Catalogs](https://okd.io/docs/operators/) |

#### RPMs from Releases or built locally

Run the following commands to install MicroShift RPM packages from a local repository.
This repository should be either [built locally](../docs/build.md#create-rpm-packages)
or downloaded from [Releases](https://github.com/microshift-io/microshift/releases).
Expand All @@ -22,16 +35,19 @@ sudo dnf install -y microshift microshift-kindnet
sudo ./src/rpm/create_repos.sh -delete
```

The following optional RPM packages are available in the repository. It is
mandatory to install either `microshift-kindnet` or `microshift-networking`
to enable the Kindnet or OVN-K networking support.
#### RPMs from the COPR

| Package | Description | Comments |
|-----------------------|----------------------------|----------|
| microshift-kindnet | Kindnet CNI | Overrides OVN-K |
| microshift-networking | OVN-K CNI | Uninstall Kindnet to enable OVN-K |
| microshift-topolvm | TopoLVM CSI | Install to enable storage support |
| microshift-olm | Operator Lifecycle Manager | See [Operator Hub Catalogs](https://okd.io/docs/operators/) |
Run the following commands to install MicroShift nightly RPM packages from the COPR.
Before installing MicroShift, RHOCP beta mirror must be enabled to provide dependencies.

> Note: This approach does not remove the configured repositories in order to get updates for
> MicroShift and dependencies whenever `dnf update` is executed.

```bash
sudo dnf copr enable -y @microshift-io/microshift-nightly
sudo ./src/rpm/create_repos.sh -rhocp-mirror
sudo dnf install -y microshift microshift-kindnet
```

### Start MicroShift Service

Expand Down
76 changes: 61 additions & 15 deletions src/quickrpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ OWNER=${OWNER:-microshift-io}
REPO=${REPO:-microshift}
BRANCH=${BRANCH:-main}
TAG=${TAG:-latest}
RPM_SOURCE=${RPM_SOURCE:-github} # Accepted values: github, copr-nightly
COPR_REPO=${COPR_REPO:-@microshift-io/microshift-nightly}

LVM_DISK="/var/lib/microshift-okd/lvmdisk.image"
VG_NAME="myvg1"
Expand Down Expand Up @@ -57,34 +59,64 @@ function centos10_cni_plugins() {
containernetworking-plugins
}

function install_rpms() {
# Download the RPMs from the release
mkdir -p "${WORKDIR}/rpms"
curl -L -s --retry 5 \
"https://github.com/${OWNER}/${REPO}/releases/download/${TAG}/microshift-rpms-$(uname -m).tgz" | \
tar zxf - -C "${WORKDIR}/rpms"
function download_script() {
local -r script=$1
local -r scriptpath="src/rpm/${script}"

curscriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Download the installation scripts
for script in create_repos.sh postinstall.sh ; do
# If the quickrpm.sh is executed from the repository, copy local script.
# Otherwise, fetch them from the github.
if [ -f "${curscriptdir}/../${scriptpath}" ]; then
cp -v "${curscriptdir}/../${scriptpath}" "${WORKDIR}/${script}"
else
curl -fSsL --retry 5 --max-time 60 \
"https://github.com/${OWNER}/${REPO}/raw/${BRANCH}/src/rpm/${script}" \
-o "${WORKDIR}/${script}"
chmod +x "${WORKDIR}/${script}"
done
fi
}

# Create the RPM repository and install the RPMs
"${WORKDIR}/create_repos.sh" -create "${WORKDIR}/rpms"
function install_microshift_packages() {
# Disable weak dependencies to avoid the deployment of the microshift-networking
# RPM, which is not necessary when microshift-kindnet RPM is installed.
dnf install -y --setopt=install_weak_deps=False \
microshift microshift-kindnet microshift-topolvm
"${WORKDIR}/create_repos.sh" -delete

# shellcheck disable=SC1091
source /etc/os-release
if [ "${ID}" == "fedora" ]; then
# Fedora doesn't have old packages - downgrading greenboot is not possible.
return 0
fi

# Pin the greenboot package to 0.15.z until the following issue is resolved:
# https://github.com/fedora-iot/greenboot-rs/issues/132
dnf install -y 'greenboot-0.15.*'
}

function install_rpms_copr() {
dnf copr enable -y "${COPR_REPO}"

"${WORKDIR}/create_repos.sh" -rhocp-mirror
install_microshift_packages
# Keep the repos, so the `dnf update` works for updated MicroShift RPMs and
# updated dependencies.
}

function install_rpms() {
# Download the RPMs from the release
mkdir -p "${WORKDIR}/rpms"
curl -L -s --retry 5 \
"https://github.com/${OWNER}/${REPO}/releases/download/${TAG}/microshift-rpms-$(uname -m).tgz" | \
tar zxf - -C "${WORKDIR}/rpms"

# Create the RPM repository and install the RPMs
"${WORKDIR}/create_repos.sh" -create "${WORKDIR}/rpms"
install_microshift_packages
"${WORKDIR}/create_repos.sh" -delete
}

function prepare_lvm_disk() {
local -r lvm_disk="$1"
local -r vg_name="$2"
Expand Down Expand Up @@ -123,8 +155,8 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1
fi

# Update the 'latest' tag to the latest released version
if [ "${TAG}" == "latest" ] ; then
# Update the 'latest' tag to the latest released version (only for github source)
if [ "${RPM_SOURCE}" == "github" ] && [ "${TAG}" == "latest" ] ; then
dnf install -y jq
TAG="$(curl -s --max-time 60 "https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" | jq -r .tag_name)"
if [ -z "${TAG}" ] || [ "${TAG}" == "null" ] ; then
Expand All @@ -136,7 +168,21 @@ fi
# Run the procedures
check_prerequisites
centos10_cni_plugins
install_rpms
download_script create_repos.sh
download_script postinstall.sh

case "${RPM_SOURCE}" in
github)
install_rpms
;;
copr-nightly)
install_rpms_copr
;;
*)
echo "ERROR: Unsupported RPM_SOURCE: ${RPM_SOURCE}. Use 'github' or 'copr-nightly'."
exit 1
;;
esac
prepare_lvm_disk "${LVM_DISK}" "${VG_NAME}"
setup_lvm_service "${LVM_DISK}" "${VG_NAME}"
start_microshift
Expand Down
49 changes: 32 additions & 17 deletions src/rpm/create_repos.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
#!/bin/bash
set -euo pipefail

USHIFT_LOCAL_REPO_FILE=/etc/yum.repos.d/microshift-local.repo
OCP_MIRROR_REPO_FILE=/etc/yum.repos.d/openshift-mirror-beta.repo
YUM_REPOS_D=/etc/yum.repos.d
USHIFT_LOCAL_REPO_FILE=microshift-local.repo
OCP_MIRROR_REPO_FILE_PREFIX=microshift-deps

function usage() {
echo "Usage: $(basename "$0") [-create <repo_path>] | [-delete]"
echo "Usage: $(basename "$0") [-create <repo_path>] | [-rhocp-mirror <version>] | [-delete]"
exit 1
}

function create_repos() {
local -r repo_path=$1
local -r repo_version=$2
function create_rhocp_repo() {
local -r repo_version=$1

cat > "${USHIFT_LOCAL_REPO_FILE}" <<EOF
[microshift-local]
name=MicroShift Local Repository
baseurl=${repo_path}
local -r file="${YUM_REPOS_D}/${OCP_MIRROR_REPO_FILE_PREFIX}-${repo_version}.repo"
cat > "${file}" <<EOF
[openshift-mirror-beta]
name=OpenShift Mirror Beta Repository
baseurl=https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/dependencies/rpms/${repo_version}-el9-beta/
enabled=1
gpgcheck=0
skip_if_unavailable=0
EOF
}
Comment on lines +13 to +25
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, find README and documentation about OS requirements
find . -type f \( -name "README*" -o -name "*.md" \) | head -20

Repository: microshift-io/microshift

Length of output: 328


🏁 Script executed:

# Search for references to OS version or RHEL/CentOS requirements
rg -i "RHEL|CentOS|Fedora|OS.version|el[0-9]" --type md --type txt | head -20

Repository: microshift-io/microshift

Length of output: 1307


🏁 Script executed:

# Check for other el9-beta references
rg "el9-beta" --type sh

Repository: microshift-io/microshift

Length of output: 357


🏁 Script executed:

# Check the context of create_repos.sh - where is it used?
rg "create_repos\.sh|create_rhocp_repo" --type sh

Repository: microshift-io/microshift

Length of output: 493


🏁 Script executed:

# Look for OS version detection in build scripts
rg "uname|version_id|os.release" --type sh -A 2 | head -30

Repository: microshift-io/microshift

Length of output: 1290


Hardcoded el9-beta will break on CentOS 10 and Fedora.

The baseurl hardcodes el9-beta, but README.md lists CentOS 10 and Fedora as supported platforms. CentOS 10 would require el10-beta, and other versions have different suffixes. Derive the OS suffix dynamically (similar to how quickrpm.sh detects OS versions via /etc/os-release) or constrain this script to RHEL 9/CentOS 9 only.

Note: The same issue exists in ansible/roles/microshift-okd-bootc/files/create_repos.sh.


cat > "${OCP_MIRROR_REPO_FILE}" <<EOF
[openshift-mirror-beta]
name=OpenShift Mirror Beta Repository
baseurl=https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/dependencies/rpms/${repo_version}-el9-beta/
function create_local_microshift_repo() {
local -r repo_path=$1

cat > "${YUM_REPOS_D}/${USHIFT_LOCAL_REPO_FILE}" <<EOF
[microshift-local]
name=MicroShift Local Repository
baseurl=${repo_path}
enabled=1
gpgcheck=0
skip_if_unavailable=0
EOF
}

function delete_repos() {
rm -vf /etc/yum.repos.d/microshift-local.repo
rm -vf /etc/yum.repos.d/openshift-mirror-beta.repo
rm -vf "${YUM_REPOS_D}/${USHIFT_LOCAL_REPO_FILE}"
find "${YUM_REPOS_D}/" -iname "${OCP_MIRROR_REPO_FILE_PREFIX}*" -delete -print
}

if [ $# -lt 1 ] ; then
Expand All @@ -54,6 +59,7 @@ case $1 in
echo "ERROR: The RPM repository path '${repo_path}' does not exist"
exit 1
fi
create_local_microshift_repo "${repo_path}"

repo_version="$(dnf --quiet --disablerepo="*" \
--repofrompath=ushift,file://"${repo_path}" \
Expand All @@ -62,7 +68,16 @@ case $1 in
echo "ERROR: Could not determine the MicroShift version from the RPM repository at '${repo_path}'"
exit 1
fi
create_repos "${repo_path}" "${repo_version}"
create_rhocp_repo "${repo_version}"
;;

-rhocp-mirror)
repo_version=$(dnf repoquery --qf '%{VERSION}' --latest-limit=1 microshift 2>/dev/null | cut -d. -f1,2)
if [ -z "${repo_version}" ] ; then
echo "ERROR: Failed to find version of MicroShift available in the repositories"
usage
fi
create_rhocp_repo "${repo_version}"
;;

-delete)
Expand Down
Loading