-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add macOS support to quickstart scripts #219
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||
|
|
@@ -17,6 +18,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 +60,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 | ||||||||
| else | ||||||||
| 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 | ||||||||
|
|
||||||||
| 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 +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}" | ||||||||
|
|
||||||||
|
|
@@ -102,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 | ||||||||
|
|
@@ -112,15 +139,15 @@ 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 | ||||||||
|
|
||||||||
| # Verify that DNS resolution works inside the container. | ||||||||
| # 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." | ||||||||
|
|
@@ -130,15 +157,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 "${CONTAINER_NAME}" &>/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 </dev/null; then | ||||||||
| echo "ERROR: Cannot connect to podman." | ||||||||
| echo "Set up a podman machine with rootful mode:" | ||||||||
| echo " podman machine init --memory 4096" | ||||||||
| echo " podman machine set --rootful" | ||||||||
| echo " podman machine start" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
|
|
||||||||
| if [ "$(id -u)" -ne 0 ]; then | ||||||||
| local_rootful="$(podman machine inspect --format '{{.Rootful}}' 2>/dev/null || echo "false")" | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing The variable name suggests local scope but it's not declared with the 🔧 Proposed fix- local_rootful="$(podman machine inspect --format '{{.Rootful}}' 2>/dev/null || echo "false")"
+ local local_rootful
+ local_rootful="$(podman machine inspect --format '{{.Rootful}}' 2>/dev/null || echo "false")"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| if [[ "${local_rootful}" != "true" ]]; then | ||||||||
| echo "ERROR: Podman machine must be in rootful mode (required for MicroShift)." | ||||||||
| echo " podman machine stop && podman machine set --rootful && podman machine start" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| fi | ||||||||
| else | ||||||||
| # Linux: must run as root | ||||||||
| if [ "$(id -u)" -ne 0 ]; then | ||||||||
| echo "ERROR: This script must be run as root (use sudo)" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| fi | ||||||||
|
|
||||||||
| check_prerequisites podman | ||||||||
|
|
@@ -163,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" | ||||||||
|
Comment on lines
+219
to
+222
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Instructions should be platform-aware. On macOS, when not running as root, users don't need 🔧 Suggested approachConditionally emit instructions based on platform and execution context: if [[ "$(uname -s)" == "Darwin" ]] && [ "$(id -u)" -ne 0 ]; then
EXEC_PREFIX=""
else
EXEC_PREFIX="sudo "
fi
echo "To access the container, run the following command:"
echo " - ${EXEC_PREFIX}podman exec -it ${CONTAINER_NAME} /bin/bash -l"🤖 Prompt for AI Agents |
||||||||
| echo | ||||||||
| echo "To uninstall MicroShift, run the following command:" | ||||||||
| echo " - curl -s https://${OWNER}.github.io/${REPO}/quickclean.sh | sudo bash" | ||||||||
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.
Container name mismatch with cleanup script.
quickclean.shhardcodesmicroshift-okdon line 15, so custom container names passed to this script won't be cleaned up.🔧 Options to fix
quickclean.shas an argument (requires updating both scripts and the workflow action)🤖 Prompt for AI Agents