From 6a3f5433c2616b1b40ac231849c76ce8cfcdcce7 Mon Sep 17 00:00:00 2001 From: Alejandro Gullon Date: Wed, 13 May 2026 15:06:22 +0200 Subject: [PATCH 1/2] feat: add macOS support to quickstart.sh quickstart.sh now detects macOS and handles podman machine validation (rootful mode required) and LVM setup via `podman machine ssh`. The pre-built image is pulled from GHCR, same as Linux. Also adds macOS to the installers CI workflow matrix. Co-Authored-By: Claude Opus 4.6 pre-commit.check-secrets: ENABLED --- .github/actions/quick-start-clean/action.yaml | 10 ++- .github/workflows/installers.yaml | 10 ++- src/quickclean.sh | 59 ++++++++----- src/quickstart.sh | 83 +++++++++++++++---- 4 files changed, 118 insertions(+), 44 deletions(-) diff --git a/.github/actions/quick-start-clean/action.yaml b/.github/actions/quick-start-clean/action.yaml index 1e668fc0..cb8b41d1 100644 --- a/.github/actions/quick-start-clean/action.yaml +++ b/.github/actions/quick-start-clean/action.yaml @@ -52,10 +52,12 @@ runs: sudo podman image exists microshift-okd && exit 1 # Verify the LVM volume group and backing storage are removed - sudo vgs | grep myvg1 && exit 1 - if [ -e /var/lib/microshift-okd ]; then - ls -la /var/lib/microshift-okd/ - exit 1 + if [ "$(uname -s)" != "Darwin" ]; then + sudo vgs | grep myvg1 && exit 1 + if [ -e /var/lib/microshift-okd ]; then + ls -la /var/lib/microshift-okd/ + exit 1 + fi fi # Uncomment this to enable tmate-debug on failure diff --git a/.github/workflows/installers.yaml b/.github/workflows/installers.yaml index d477162d..2c8ecc9e 100644 --- a/.github/workflows/installers.yaml +++ b/.github/workflows/installers.yaml @@ -9,12 +9,20 @@ jobs: if: ${{ !github.event.pull_request.draft }} strategy: matrix: - runners: [ubuntu-24.04, ubuntu-24.04-arm] + runners: [ubuntu-24.04, ubuntu-24.04-arm, macos-latest] runs-on: ${{ matrix.runners }} steps: - name: Check out MicroShift upstream repository uses: actions/checkout@v4 + - name: Install and configure podman (macOS) + if: runner.os == 'macOS' + run: | + brew install podman + podman machine init --memory 4096 + podman machine set --rootful + podman machine start + # Test the quick Bootc image installation and clean procedures with the latest # published build of the MicroShift container image. - name: Run the quick Bootc image installation and clean scripts diff --git a/src/quickclean.sh b/src/quickclean.sh index 898b8533..a51b871b 100755 --- a/src/quickclean.sh +++ b/src/quickclean.sh @@ -18,28 +18,45 @@ if [ -n "${image_ref:-}" ]; then podman rmi -f "${image_ref}" || true fi -# Clean up the MicroShift data and uninstall RPMs -if rpm -q microshift &>/dev/null ; then - echo y | microshift-cleanup-data --all - - # Remove the LVM configuration - if [ -f "${LVM_CONFIG}" ] ; then - rm -f "${LVM_CONFIG}" - systemctl daemon-reload +if [[ "$(uname -s)" == "Darwin" ]]; then + # macOS: clean up LVM inside the podman machine VM + MACHINE_SSH="podman machine ssh" + if [ -n "${SUDO_USER:-}" ]; then + MACHINE_SSH="sudo -u ${SUDO_USER} podman machine ssh" fi + ${MACHINE_SSH} " + if [ -f '${LVM_DISK}' ]; then + sudo lvremove -y '${VG_NAME}' || true + sudo vgremove -y '${VG_NAME}' || true + DEVICE_NAME=\$(sudo losetup -j '${LVM_DISK}' | cut -d: -f1) + [ -n \"\${DEVICE_NAME}\" ] && sudo losetup -d \${DEVICE_NAME} + sudo rm -rf '$(dirname "${LVM_DISK}")' + fi + " /dev/null ; then + echo y | microshift-cleanup-data --all - dnf remove -y 'microshift*' - # Undo post-installation configuration - rm -f /etc/sysctl.d/99-microshift.conf - rm -f /root/.kube/config -fi + # Remove the LVM configuration + if [ -f "${LVM_CONFIG}" ] ; then + rm -f "${LVM_CONFIG}" + systemctl daemon-reload + fi -# Remove the LVM disk -if [ -f "${LVM_DISK}" ]; then - lvremove -y "${VG_NAME}" || true - vgremove -y "${VG_NAME}" || true - DEVICE_NAME="$(losetup -j "${LVM_DISK}" | cut -d: -f1)" - # shellcheck disable=SC2086 - [ -n "${DEVICE_NAME}" ] && losetup -d ${DEVICE_NAME} - rm -rf "$(dirname "${LVM_DISK}")" + dnf remove -y 'microshift*' + # Undo post-installation configuration + rm -f /etc/sysctl.d/99-microshift.conf + rm -f /root/.kube/config + fi + + # Remove the LVM disk + if [ -f "${LVM_DISK}" ]; then + lvremove -y "${VG_NAME}" || true + vgremove -y "${VG_NAME}" || true + DEVICE_NAME="$(losetup -j "${LVM_DISK}" | cut -d: -f1)" + # shellcheck disable=SC2086 + [ -n "${DEVICE_NAME}" ] && losetup -d ${DEVICE_NAME} + rm -rf "$(dirname "${LVM_DISK}")" + fi fi diff --git a/src/quickstart.sh b/src/quickstart.sh index 14757c04..6d96e5ee 100755 --- a/src/quickstart.sh +++ b/src/quickstart.sh @@ -17,6 +17,8 @@ function check_prerequisites() { echo "Install it with:" if command -v dnf &>/dev/null; then echo " sudo dnf install -y ${tool}" + elif command -v brew &>/dev/null; then + echo " brew install ${tool}" elif command -v apt-get &>/dev/null; then echo " sudo apt-get install -y ${tool}" elif command -v zypper &>/dev/null; then @@ -57,17 +59,41 @@ function prepare_lvm_disk() { local -r lvm_disk="$1" local -r vg_name="$2" - if [ -f "${lvm_disk}" ]; then - echo "INFO: '${lvm_disk}' already exists. Clearing and reusing it." - dd if=/dev/zero of="${lvm_disk}" bs=1M count=100 >/dev/null - return 0 - fi + if [[ "$(uname -s)" == "Darwin" ]]; then + local lvm_dir machine_ssh + lvm_dir="$(dirname "${lvm_disk}")" + machine_ssh="podman machine ssh" + if [ "$(id -u)" -eq 0 ] && [ -n "${SUDO_USER:-}" ]; then + machine_ssh="sudo -u ${SUDO_USER} podman machine ssh" + fi + ${machine_ssh} " + sudo mkdir -p '${lvm_dir}' + if [ -f '${lvm_disk}' ]; then + echo 'INFO: LVM disk already exists, reusing' + else + sudo truncate --size=1G '${lvm_disk}' + fi + if sudo vgs '${vg_name}' &>/dev/null; then + echo 'INFO: Volume group ${vg_name} already exists, reusing' + else + DEVICE=\$(sudo losetup --find --show --nooverlap '${lvm_disk}') + sudo vgcreate -f -y '${vg_name}' \"\${DEVICE}\" + echo 'INFO: Created volume group ${vg_name}' + fi + " /dev/null + return 0 + fi - mkdir -p "$(dirname "${lvm_disk}")" - truncate --size=1G "${lvm_disk}" + mkdir -p "$(dirname "${lvm_disk}")" + truncate --size=1G "${lvm_disk}" - local -r device_name="$(losetup --find --show --nooverlap "${lvm_disk}")" - vgcreate -f -y "${vg_name}" "${device_name}" + local -r device_name="$(losetup --find --show --nooverlap "${lvm_disk}")" + vgcreate -f -y "${vg_name}" "${device_name}" + fi } function run_bootc_image() { @@ -93,7 +119,7 @@ function run_bootc_image() { podman run --privileged --rm -d \ --replace \ ${vol_opts} \ - --name microshift-okd \ + --name "microshift-okd" \ --hostname 127.0.0.1.nip.io \ "${image_ref}" @@ -102,7 +128,7 @@ function run_bootc_image() { local -r max_wait=300 local waited=0 while [ "${waited}" -lt "${max_wait}" ] ; do - if podman exec microshift-okd /bin/test -f "${kubeconfig}" &>/dev/null ; then + if podman exec "microshift-okd" /bin/test -f "${kubeconfig}" &>/dev/null ; then break fi sleep 1 @@ -112,7 +138,7 @@ function run_bootc_image() { echo "ERROR: Timed out waiting for MicroShift to start after ${max_wait}s" echo echo "Stopping the container..." - podman stop microshift-okd &>/dev/null || true + podman stop "microshift-okd" &>/dev/null || true exit 1 fi @@ -120,7 +146,7 @@ function run_bootc_image() { # VPN connections or custom DNS configurations on the host may # prevent the container from resolving external hostnames, causing # pods to stay in ContainerCreating while image pulls time out. - if ! podman exec microshift-okd getent hosts quay.io &>/dev/null ; then + if ! podman exec "microshift-okd" getent hosts quay.io &>/dev/null ; then echo echo "ERROR: DNS resolution for 'quay.io' failed inside the container." echo "MicroShift pods will not be able to pull container images." @@ -130,15 +156,36 @@ function run_bootc_image() { echo "Consider disconnecting from VPN or configuring DNS manually." echo echo "Stopping the container..." - podman stop microshift-okd &>/dev/null || true + podman stop "microshift-okd" &>/dev/null || true exit 1 fi } -# Check if the script is running as root -if [ "$(id -u)" -ne 0 ]; then - echo "ERROR: This script must be run as root (use sudo)" - exit 1 +# Platform-specific initialization +if [[ "$(uname -s)" == "Darwin" ]]; then + if ! podman info &>/dev/null Date: Wed, 13 May 2026 15:07:45 +0200 Subject: [PATCH 2/2] feat: make container name configurable via parameter Usage: ./src/quickstart.sh [container-name] Defaults to 'microshift-okd' when no argument is provided. Co-Authored-By: Claude Opus 4.6 pre-commit.check-secrets: ENABLED --- src/quickstart.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/quickstart.sh b/src/quickstart.sh index 6d96e5ee..14043c3b 100755 --- a/src/quickstart.sh +++ b/src/quickstart.sh @@ -6,6 +6,7 @@ REPO=${REPO:-microshift} IMAGE=${IMAGE:-"ghcr.io/${OWNER}/${REPO}"} TAG=${TAG:-latest} +CONTAINER_NAME="${1:-microshift-okd}" LVM_DISK="/var/lib/microshift-okd/lvmdisk.image" VG_NAME="myvg1" PODMAN_VMAJOR=4 @@ -119,7 +120,7 @@ function run_bootc_image() { podman run --privileged --rm -d \ --replace \ ${vol_opts} \ - --name "microshift-okd" \ + --name "${CONTAINER_NAME}" \ --hostname 127.0.0.1.nip.io \ "${image_ref}" @@ -128,7 +129,7 @@ function run_bootc_image() { local -r max_wait=300 local waited=0 while [ "${waited}" -lt "${max_wait}" ] ; do - if podman exec "microshift-okd" /bin/test -f "${kubeconfig}" &>/dev/null ; then + if podman exec "${CONTAINER_NAME}" /bin/test -f "${kubeconfig}" &>/dev/null ; then break fi sleep 1 @@ -138,7 +139,7 @@ function run_bootc_image() { echo "ERROR: Timed out waiting for MicroShift to start after ${max_wait}s" echo echo "Stopping the container..." - podman stop "microshift-okd" &>/dev/null || true + podman stop "${CONTAINER_NAME}" &>/dev/null || true exit 1 fi @@ -146,7 +147,7 @@ function run_bootc_image() { # VPN connections or custom DNS configurations on the host may # prevent the container from resolving external hostnames, causing # pods to stay in ContainerCreating while image pulls time out. - if ! podman exec "microshift-okd" getent hosts quay.io &>/dev/null ; then + if ! podman exec "${CONTAINER_NAME}" getent hosts quay.io &>/dev/null ; then echo echo "ERROR: DNS resolution for 'quay.io' failed inside the container." echo "MicroShift pods will not be able to pull container images." @@ -156,7 +157,7 @@ function run_bootc_image() { echo "Consider disconnecting from VPN or configuring DNS manually." echo echo "Stopping the container..." - podman stop "microshift-okd" &>/dev/null || true + podman stop "${CONTAINER_NAME}" &>/dev/null || true exit 1 fi } @@ -210,15 +211,15 @@ run_bootc_image "${IMAGE}:${TAG}" echo echo "MicroShift is running in a bootc container" echo "Hostname: 127.0.0.1.nip.io" -echo "Container: microshift-okd" +echo "Container: ${CONTAINER_NAME}" echo "LVM disk: ${LVM_DISK}" echo "VG name: ${VG_NAME}" echo echo "To access the container, run the following command:" -echo " - sudo podman exec -it microshift-okd /bin/bash -l" +echo " - sudo podman exec -it ${CONTAINER_NAME} /bin/bash -l" echo echo "To verify that MicroShift pods are up and running, run the following command:" -echo " - sudo podman exec -it microshift-okd kubectl get pods -A" +echo " - sudo podman exec -it ${CONTAINER_NAME} kubectl get pods -A" echo echo "To uninstall MicroShift, run the following command:" echo " - curl -s https://${OWNER}.github.io/${REPO}/quickclean.sh | sudo bash"