-
Notifications
You must be signed in to change notification settings - Fork 16
Implement MicroShift ISO creation and deployment procedures #181
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
ggiguash
wants to merge
5
commits into
microshift-io:main
Choose a base branch
from
ggiguash:bootc-iso-release
base: main
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.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
70a6622
Implement custom ISO build script and docs
ggiguash 0f0ed11
Document installing using custom and stock ISO images
ggiguash ce4aba0
Add bootc image override option in make iso
ggiguash d1e6220
Merge branch 'main' into bootc-iso-release
ggiguash 4121d82
Address AI review comments
ggiguash 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
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
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
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
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,182 @@ | ||
| # MicroShift ISO Deployment | ||
|
|
||
| MicroShift ISO can be installed on a physical host or a virtual machine. | ||
| This document describes how to install MicroShift ISO inside a virtual machine. | ||
|
|
||
| > Hardware-level configuration is host-dependent and excluded from this document | ||
| > to maintain a vendor-neutral deployment guide. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Virtualization | ||
|
|
||
| The procedures described in this document must be run on a physical hypervisor host | ||
| of the supported `x86_64` or `aarch64` architecture. The [libvirt](https://libvirt.org/) | ||
| toolkit for managing virtualization platforms is used for starting virtual machines. | ||
|
|
||
| ### Kickstart | ||
|
|
||
| MicroShift ISO uses [Anaconda Installer](https://anaconda-installer.readthedocs.io/), | ||
| which can be customized using [Kickstart](https://anaconda-installer.readthedocs.io/en/latest/kickstart.html). | ||
|
|
||
| It is recommended to customize the system with user-specific settings like | ||
| hostname, user names and passwords, SSH keys, disk partitioning, etc. | ||
|
|
||
| An opinionated example of such a customization can be found at [kickstart.ks.template](../src/iso/kickstart.ks.template). | ||
| The file is used during the installation procedures described below. | ||
|
|
||
| ### Installer Types | ||
|
|
||
| Two installation techniques are presented below: | ||
| - Using a custom ISO installer with an embedded Bootc container image | ||
| - Using a stock ISO installer image with a Bootc container image from registry | ||
|
|
||
| > Stock ISO deployment is recommended for most use cases to minimize maintenance. | ||
| > Custom builds are reserved for specific environmental needs that fall outside | ||
| > the scope of Kickstart automation. | ||
|
|
||
| When using a custom ISO installer, follow the instructions in [Create ISO](./build.md#create-iso) | ||
| to build the ISO installer. | ||
|
|
||
| When using a stock ISO installer, download it from one of the following sites. | ||
|
|
||
| | OS | Link | | ||
| |-----------|-----------------| | ||
| | Fedora | [Booting via ISO](https://docs.fedoraproject.org/en-US/fedora-coreos/live-booting/#_booting_via_iso) | | ||
| | CentOS 10 | [x86_64](https://mirror.stream.centos.org/10-stream/BaseOS/x86_64/iso/) [aarch64](https://mirror.stream.centos.org/10-stream/BaseOS/aarch64/iso/) | | ||
| | CentOS 9 | [x86_64](https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/) [aarch64](https://mirror.stream.centos.org/9-stream/BaseOS/aarch64/iso/) | | ||
|
|
||
| ## Installation | ||
|
|
||
| Follow instructions in one of [Custom ISO](#custom-iso) or [Stock ISO](#stock-iso) | ||
| sections below, depending on the installation type of choice. | ||
|
|
||
| ### Custom ISO | ||
|
|
||
| Copy the `install.iso` file to the `/var/lib/libvirt/images` directory and set | ||
| the following variables to be used during the virtual machine creation. | ||
|
|
||
| ```bash | ||
| VMNAME="microshift-okd" | ||
| NETNAME="default" | ||
| ISOFILE="install.iso" | ||
| ``` | ||
|
|
||
| Convert the kickstart template to a configuration suitable for the custom ISO | ||
| installation by resetting transport and URL variables. | ||
|
|
||
| ```bash | ||
| KSTEMP="./src/iso/kickstart.ks.template" | ||
| KSFILE=/tmp/kickstart-custom-iso.ks | ||
|
|
||
| # Loading the bootc image bundled in the ISO | ||
| export BOOTC_IMAGE_TRANSPORT=oci | ||
| export BOOTC_IMAGE_URL=/run/install/repo/container | ||
|
|
||
| envsubst '${BOOTC_IMAGE_TRANSPORT} ${BOOTC_IMAGE_URL}' \ | ||
| < "${KSTEMP}" > "${KSFILE}" | ||
| ``` | ||
|
|
||
| Run the following commands to create a virtual machine. You can watch the | ||
| installation progress at the console of the created virtual machine. | ||
|
|
||
| ```bash | ||
| # Always use a full path for kickstart files | ||
| KSFILE="$(readlink -f "${KSFILE}")" | ||
|
|
||
| sudo bash -c " \ | ||
| cd /var/lib/libvirt/images/ && \ | ||
| virt-install \ | ||
| --name "${VMNAME}" \ | ||
| --vcpus 2 \ | ||
| --memory 3072 \ | ||
| --disk "path=./${VMNAME}.qcow2,size=20" \ | ||
| --network "network=${NETNAME},model=virtio" \ | ||
| --events on_reboot=restart \ | ||
| --location "${ISOFILE}" \ | ||
| --initrd-inject "${KSFILE}" \ | ||
| --extra-args "inst.ks=file:/$(basename "${KSFILE}") console=tty0" \ | ||
| --wait \ | ||
| " | ||
| ``` | ||
|
|
||
| The virtual machine should reboot in the event of a successful installation and | ||
| present a user login prompt. | ||
|
|
||
| ### Stock ISO | ||
|
|
||
| Download an ISO from one of the locations mentioned in the [Installer Types](#installer-types) | ||
| and copy the file to the `/var/lib/libvirt/images` directory. | ||
| Set the following variables to be used during the virtual machine creation. | ||
|
|
||
| ```bash | ||
| VMNAME="microshift-okd" | ||
| NETNAME="default" | ||
| ISOFILE="CentOS-Stream-10-latest-$(uname -m)-boot.iso" | ||
| ``` | ||
|
|
||
| Convert the kickstart template to a configuration suitable for the stock ISO | ||
| installation by resetting transport and URL variables. | ||
|
|
||
| ```bash | ||
| KSTEMP="./src/iso/kickstart.ks.template" | ||
| KSFILE=/tmp/kickstart-stock-iso.ks | ||
|
|
||
| # Loading the bootc image from a container registry | ||
| export BOOTC_IMAGE_TRANSPORT=registry | ||
| export BOOTC_IMAGE_URL="ghcr.io/microshift-io/microshift:<IMAGE_TAG>" | ||
|
|
||
| envsubst '${BOOTC_IMAGE_TRANSPORT} ${BOOTC_IMAGE_URL}' \ | ||
| < "${KSTEMP}" > "${KSFILE}" | ||
| ``` | ||
|
|
||
| Run the following commands to create a virtual machine. You can watch the | ||
| installation progress at the console of the created virtual machine. | ||
|
|
||
| ```bash | ||
| # Always use a full path for kickstart files | ||
| KSFILE="$(readlink -f "${KSFILE}")" | ||
|
|
||
| sudo bash -c " \ | ||
| cd /var/lib/libvirt/images/ && \ | ||
| virt-install \ | ||
| --name "${VMNAME}" \ | ||
| --vcpus 2 \ | ||
| --memory 3072 \ | ||
| --disk "path=./${VMNAME}.qcow2,size=20" \ | ||
| --network "network=${NETNAME},model=virtio" \ | ||
| --events on_reboot=restart \ | ||
| --location "${ISOFILE}" \ | ||
| --initrd-inject "${KSFILE}" \ | ||
| --extra-args "inst.ks=file:/$(basename "${KSFILE}") console=tty0" \ | ||
| --wait \ | ||
| " | ||
| ``` | ||
|
|
||
| The virtual machine should reboot in the event of a successful installation and | ||
| present a user login prompt. | ||
|
|
||
| ## Login | ||
|
|
||
| Log into the virtual machine console by running the following command. Enter the | ||
| `microshift:microshift` credentials when prompted. | ||
|
|
||
| ```bash | ||
| sudo virsh console --force "${VMNAME}" | ||
| ``` | ||
|
|
||
| Verify that all the MicroShift services are up and running successfully. | ||
| ```bash | ||
| sudo oc get nodes | ||
| sudo oc get pods -A | ||
| ``` | ||
|
|
||
| ## Cleanup | ||
|
|
||
| Run the following commands to shut down and delete the virtual machine. | ||
|
|
||
| ```bash | ||
| sudo virsh destroy "${VMNAME}" | ||
| sudo virsh undefine "${VMNAME}" | ||
| sudo rm -f "/var/lib/libvirt/images/${VMNAME}.qcow2" | ||
| ``` |
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,80 @@ | ||
| lang en_US.UTF-8 | ||
| keyboard us | ||
| timezone UTC | ||
| text | ||
| reboot | ||
|
|
||
| # Partition the disk with hardware-specific boot and swap partitions, adding an | ||
| # LVM volume that contains a system root partition of the specified size. | ||
| # The remainder of the volume will be used by the CSI driver for storing data. | ||
| # | ||
| # For example, a 20GB disk with 15GB system root may be partitioned in the following way. | ||
| # | ||
| # NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS | ||
| # loop0 7:0 0 7.9M 1 loop | ||
| # sda 8:0 0 20G 0 disk | ||
| # ├─sda1 8:1 0 1G 0 part /boot | ||
| # └─sda2 8:2 0 19G 0 part | ||
| # └─rhel-root 253:0 0 15G 0 lvm /sysroot | ||
| # sr0 11:0 1 1024M 0 rom | ||
| # zram0 252:0 0 3.8G 0 disk [SWAP] | ||
| # | ||
| zerombr | ||
| clearpart --all --initlabel | ||
| # Create boot and swap partitions as required by the current hardware platform | ||
| reqpart --add-boot | ||
| # Add an LVM volume group and allocate a system root logical volume | ||
| part pv.01 --grow | ||
| volgroup myvg1 pv.01 | ||
| logvol / --vgname=myvg1 --fstype=xfs --size=15360 --name=root | ||
|
|
||
| # Lock root user account | ||
| rootpw --lock | ||
|
|
||
| # Configure network to use DHCP and activate on boot | ||
| network --bootproto=dhcp --device=link --activate --onboot=on --hostname=microshift-okd | ||
|
|
||
| # Configure bootc to install from the local embedded container repository or | ||
| # a remote container registry | ||
| # | ||
| # Transport: 'oci' for local or 'registry' for remote | ||
| # URL: '/run/install/repo/container' for local or FQDN for remote | ||
| ostreecontainer --transport $BOOTC_IMAGE_TRANSPORT --url $BOOTC_IMAGE_URL | ||
|
|
||
| %post --log=/dev/console --erroronfail | ||
|
|
||
| # Create a default microshift user, allowing it to run sudo commands without password. | ||
| # NOTE: Remove or change the password hash for production deployments. | ||
| useradd -m -p \$5\$XCVQ6AZVF6D5YW6V\$7wV451u/3oxvWA8vlqX.bWiBAYO/M8VRpZidA0vmzj5 microshift | ||
| echo -e 'microshift\tALL=(ALL)\tNOPASSWD: ALL' > /etc/sudoers.d/microshift | ||
|
|
||
| # Make the KUBECONFIG from MicroShift directly available for the root user | ||
| if [ ! -d /root ]; then | ||
| # Workaround for bootc container init. | ||
| # /var/roothome (which /root symlinks to) is not present when init | ||
| # entrypoint starts (before systemd). So it needs to be pre-populated, | ||
| # so it exists when /var/roothome is mounted. | ||
| mkdir -p /var/roothome/ | ||
| echo -e 'export KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig' >> /var/roothome/.bash_profile | ||
| else | ||
| echo -e 'export KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig' >> /root/.bash_profile | ||
| fi | ||
|
|
||
| # Configure systemd journal service to persist logs between boots and limit their size to 1G | ||
| mkdir -p /etc/systemd/journald.conf.d | ||
| cat > /etc/systemd/journald.conf.d/microshift.conf <<EOF | ||
| [Journal] | ||
| Storage=persistent | ||
| SystemMaxUse=1G | ||
| RuntimeMaxUse=1G | ||
| EOF | ||
| mkdir -p /var/log/journal | ||
|
|
||
| # Enable the getty service to allow VM access from the hypervisor using the | ||
| # 'virsh console vm-name' command. | ||
| systemctl enable serial-getty@ttyS0.service | ||
|
|
||
| # Bind /tmp to /var/tmp to avoid lack of space in /tmp when tmpfs is used. | ||
| echo "/var/tmp /tmp none bind 0 0" >> /etc/fstab | ||
|
|
||
| %end | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.