Embedding in a RHEL for Edge image Red Hat build of MicroShift 4.18 Embedding in a RHEL for Edge image Red Hat OpenShift Documentation Team

Commands:
sudo mkdir -p /etc/osbuild-composer/repositories
sudo cp /usr/share/osbuild-composer/repositories/rhel-9.4.json /etc/osbuild-composer/repositories/rhel-9.4.json
"baseurl": "https://cdn.redhat.com/content/eus/rhel<9>/<9.4>//baseos/os", 1
sudo sed -i "s,dist/rhel<9>/<9.4>/USD(uname -m)/baseos/,eus/rhel<9>/<9.4>/USD(uname -m)/baseos/,g" /etc/osbuild-composer/repositories/rhel-<9.4>.json 1
"baseurl": "https://cdn.redhat.com/content/eus/rhel<9>/<9.4>//appstream/os", 1
sudo sed -i "s,dist/rhel<9>/<9.4>/USD(uname -m)/appstream/,eus/rhel<9>/<9.4>/USD(uname -m)/appstream/,g" /etc/osbuild-composer/repositories/rhel-<9.4>.json 1
sudo composer-cli sources info baseos | grep 'url ='
url = "https://cdn.redhat.com/content/eus/rhel9/9.4/x86_64/baseos/os"
sudo composer-cli sources info appstream | grep 'url ='
url = "https://cdn.redhat.com/content/eus/rhel9/9.4/x86_64/appstream/os"
cat > rhocp-4.18.toml <<EOF id = "rhocp-4.18" name = "Red Hat OpenShift Container Platform 4.18 for RHEL 9" type = "yum-baseurl" url = "https://cdn.redhat.com/content/dist/layered/rhel9/USD(uname -m)/rhocp/4.18/os" check_gpg = true check_ssl = true system = false rhsm = true EOF
cat > fast-datapath.toml <<EOF id = "fast-datapath" name = "Fast Datapath for RHEL 9" type = "yum-baseurl" url = "https://cdn.redhat.com/content/dist/layered/rhel9/USD(uname -m)/fast-datapath/os" check_gpg = true check_ssl = true system = false rhsm = true EOF
sudo composer-cli sources add rhocp-4.18.toml
sudo composer-cli sources add fast-datapath.toml
sudo composer-cli sources list
appstream baseos fast-datapath rhocp-4.18
cat > <microshift_blueprint.toml> <<EOF 1 name = " <microshift_blueprint> " 2 description = "" version = "0.0.1" modules = [] groups = [] [[packages]] name = "microshift" version = "4.18.1" 3 [customizations.services] enabled = ["microshift"] EOF
name = "microshift_blueprint" description = "MicroShift 4.17.1 on x86_64 platform" version = "0.0.1" modules = [] groups = [] [[packages]] 1 name = "microshift" version = "4.17.1" [customizations.services] 2 enabled = ["microshift"] [customizations.firewall] ports = ["22:tcp", "80:tcp", "443:tcp", "5353:udp", "6443:tcp", "30000-32767:tcp", "30000-32767:udp"] [[containers]] 3 source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f41e79c17e8b41f1b0a5a32c3e2dd7cd15b8274554d3f1ba12b2598a347475f4" [[containers]] source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:dbc65f1fba7d92b36cf7514cd130fe83a9bd211005ddb23a8dc479e0eea645fd" ... EOF
sudo composer-cli blueprints push <microshift_blueprint.toml> 1
sudo composer-cli blueprints depsolve <microshift_blueprint> | grep microshift 1
blueprint: microshift_blueprint v0.0.1 microshift-greenboot-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.noarch microshift-networking-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.x86_64 microshift-release-info-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.noarch microshift-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.x86_64 microshift-selinux-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.noarch
sudo composer-cli blueprints depsolve <microshift_blueprint> 1
vi <microshift_blueprint.toml> 1
[[packages]] 1 name = " <microshift-additional-package-name> " 2 version = "*"
[[customizations.directories]] path = "/etc/pki/ca-trust/source/anchors"
[[customizations.files]] path = "/etc/pki/ca-trust/source/anchors/cert1.pem" data = "<value>"
sudo update-ca-trust
%post Update certificate trust storage in case new certificates were installed at /etc/pki/ca-trust/source/anchors directory update-ca-trust %end
BUILDID=USD(sudo composer-cli compose start-ostree --ref "rhel/{op-system-version-major}/USD(uname -m)/edge" <microshift_blueprint> edge-container | awk '/^Compose/ {print USD2}') 1
sudo composer-cli compose status
ID Status Time Blueprint Version Type Size cc3377ec-4643-4483-b0e7-6b0ad0ae6332 RUNNING Wed Jun 7 12:26:23 2023 microshift_blueprint 0.0.1 edge-container
ID Status Time Blueprint Version Type Size cc3377ec-4643-4483-b0e7-6b0ad0ae6332 FINISHED Wed Jun 7 12:32:37 2023 microshift_blueprint 0.0.1 edge-container
sudo composer-cli compose image USD{BUILDID}
sudo chown USD(whoami). USD{BUILDID}-container.tar
sudo chmod a+r USD{BUILDID}-container.tar
IMAGEID=USD(cat < "./USD{BUILDID}-container.tar" | sudo podman load | grep -o -P '(?<=sha256[@:])[a-z0-9]*')
sudo podman run -d --name=minimal-microshift-server -p 8085:8080 USD{IMAGEID}
cat > microshift-installer.toml <<EOF name = "microshift-installer" description = "" version = "0.0.0" modules = [] groups = [] packages = [] EOF
sudo composer-cli blueprints push microshift-installer.toml
BUILDID=USD(sudo composer-cli compose start-ostree --url http://localhost:8085/repo/ --ref "rhel/9/USD(uname -m)/edge" microshift-installer edge-installer | awk '{print USD2}')
sudo composer-cli compose status
ID Status Time Blueprint Version Type Size c793c24f-ca2c-4c79-b5b7-ba36f5078e8d RUNNING Wed Jun 7 13:22:20 2023 microshift-installer 0.0.0 edge-installer
ID Status Time Blueprint Version Type Size c793c24f-ca2c-4c79-b5b7-ba36f5078e8d FINISHED Wed Jun 7 13:34:49 2023 microshift-installer 0.0.0 edge-installer
sudo composer-cli compose image USD{BUILDID}
sudo chown USD(whoami). USD{BUILDID}-installer.iso
sudo chmod a+r USD{BUILDID}-installer.iso
Partition disk such that it contains an LVM volume group called `rhel` with a 10GB+ system root but leaving free space for the LVMS CSI driver for storing data. # For example, a 20GB disk would be partitioned in the following way: # NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda1 8:1 0 800M 0 part /boot └─sda2 8:2 0 19G 0 part └─rhel-root 253:0 0 10G 0 lvm /sysroot # ostreesetup --nogpg --osname=rhel --remote=edge --url=file:///run/install/repo/ostree/repo --ref=rhel/<RHEL VERSION NUMBER>/x86_64/edge zerombr clearpart --all --initlabel part /boot/efi --fstype=efi --size=200 part /boot --fstype=xfs --asprimary --size=800 Uncomment this line to add a SWAP partition of the recommended size #part swap --fstype=swap --recommended part pv.01 --grow volgroup rhel pv.01 logvol / --vgname=rhel --fstype=xfs --size=10000 --name=root To add users, use a line such as the following user --name=<YOUR_USER_NAME> --password=<YOUR_HASHED_PASSWORD> --iscrypted --groups=<YOUR_USER_GROUPS>
%post --log=/var/log/anaconda/post-install.log --erroronfail Add the pull secret to CRI-O and set root user-only read/write permissions cat > /etc/crio/openshift-pull-secret << EOF YOUR_OPENSHIFT_PULL_SECRET_HERE EOF chmod 600 /etc/crio/openshift-pull-secret Configure the firewall with the mandatory rules for MicroShift firewall-offline-cmd --zone=trusted --add-source=10.42.0.0/16 firewall-offline-cmd --zone=trusted --add-source=169.254.169.1 %end
sudo yum install -y lorax
sudo mkksiso <your_kickstart>.ks <your_installer>.iso <updated_installer>.iso
mkdir -p ~/.kube/
sudo cat /var/lib/microshift/resources/kubeadmin/kubeconfig > ~/.kube/config
chmod go-r ~/.kube/config
oc get all -A
[user@microshift]USD sudo firewall-cmd --permanent --zone=public --add-port=6443/tcp && sudo firewall-cmd --reload
[user@microshift]USD oc get all -A
[user@workstation]USD mkdir -p ~/.kube/
[user@workstation]USD MICROSHIFT_MACHINE=<name or IP address of MicroShift machine>
[user@workstation]USD ssh <user>@USDMICROSHIFT_MACHINE "sudo cat /var/lib/microshift/resources/kubeadmin/USDMICROSHIFT_MACHINE/kubeconfig" > ~/.kube/config
chmod go-r ~/.kube/config
[user@workstation]USD oc get all -A
rpm -ql microshift-release-info
/usr/share/microshift/release/release-x86_64.json
rpm2cpio microshift-release-info*.noarch.rpm | cpio -idmv
/usr/share/microshift/release/release-x86_64.json
RELEASE_FILE=/usr/share/microshift/release/release-USD(uname -m).json
jq -r '.images | .[]' USD{RELEASE_FILE} > microshift-container-refs.txt
"<microshift_quay:8443>": { 1 "auth": "<microshift_auth>", 2 "email": "<microshift_quay@example.com>" 3 },
sudo dnf install -y skopeo
PULL_SECRET_FILE=~/.pull-secret-mirror.json
IMAGE_LIST_FILE=~/microshift-container-refs.txt
IMAGE_LOCAL_DIR=~/microshift-containers
while read -r src_img ; do # Remove the source registry prefix dst_img=USD(echo "USD{src_img}" | cut -d '/' -f 2-) # Run the image download command echo "Downloading 'USD{src_img}' to 'USD{IMAGE_LOCAL_DIR}'" mkdir -p "USD{IMAGE_LOCAL_DIR}/USD{dst_img}" skopeo copy --all --quiet --preserve-digests --authfile "USD{PULL_SECRET_FILE}" docker://"USD{src_img}" dir://"USD{IMAGE_LOCAL_DIR}/USD{dst_img}" done < "USD{IMAGE_LIST_FILE}"
sudo dnf install -y skopeo
IMAGE_PULL_FILE=~/.pull-secret-mirror.json
IMAGE_LOCAL_DIR=~/microshift-containers
TARGET_REGISTRY= <registry_host>:<port> 1
pushd "USD{IMAGE_LOCAL_DIR}" >/dev/null while read -r src_manifest ; do local src_img src_img=USD(dirname "USD{src_manifest}") # Add the target registry prefix and remove SHA local -r dst_img="USD{TARGET_REGISTRY}/USD{src_img}" local -r dst_img_no_tag="USD{TARGET_REGISTRY}/USD{src_img%%[@:]*}" # Run the image upload echo "Uploading 'USD{src_img}' to 'USD{dst_img}'" skopeo copy --all --quiet --preserve-digests --authfile "USD{IMAGE_PULL_FILE}" dir://"USD{IMAGE_LOCAL_DIR}/USD{src_img}" docker://"USD{dst_img}" done < <(find . -type f -name manifest.json -printf '%P\n') popd >/dev/null
sudo update-ca-trust
[[registry]] prefix = "" location = "<registry_host>:<port>" 1 mirror-by-digest-only = true insecure = false [[registry]] prefix = "" location = "quay.io" mirror-by-digest-only = true [[registry.mirror]] location = "<registry_host>:<port>" insecure = false [[registry]] prefix = "" location = "registry.redhat.io" mirror-by-digest-only = true [[registry.mirror]] location = "<registry_host>:<port>" insecure = false [[registry]] prefix = "" location = "registry.access.redhat.com" mirror-by-digest-only = true [[registry.mirror]] location = "<registry_host>:<port>" insecure = false
sudo systemctl enable microshift
sudo reboot
sudo dnf install -y microshift-release-info-<release_version>
sudo ls /usr/share/microshift/release
release-x86_64.json release-aarch64.json
sudo dnf download microshift-release-info- <release_version> 1
microshift-release-info-4.18.1.-202511101230.p0.g7dc6a00.assembly.4.18.1.el9.noarch.rpm
rpm2cpio <my_microshift_release_info> | cpio -idmv 1 ./usr/share/microshift/release/release-aarch64.json ./usr/share/microshift/release/release-x86_64.json
RELEASE_FILE= </path/to/your/release-USD(uname -m).json> 1
BLUEPRINT_FILE= </path/to/your/blueprint.toml> 1
jq -r '.images | .[] | ("[[containers]]\nsource = \"" + . + "\"\n")' "USD{RELEASE_FILE}" >> "USD{BLUEPRINT_FILE}"
[[containers]] source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:82cfef91557f9a70cff5a90accba45841a37524e9b93f98a97b20f6b2b69e5db" [[containers]] source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:82cfef91557f9a70cff5a90accba45841a37524e9b93f98a97b20f6b2b69e5db"
[[containers]] source = " <my_image_pullspec_with_tag_or_digest> "
[containers] auth_file_path = "/etc/osbuild-worker/pull-secret.json"
cat > <microshift_blueprint.toml> <<EOF 1 name = " <microshift_blueprint> " 2 description = "" version = "0.0.1" modules = [] groups = [] [[packages]] name = "microshift" version = "4.18.1" 3 [customizations.services] enabled = ["microshift"] EOF
name = "microshift_blueprint" description = "MicroShift 4.17.1 on x86_64 platform" version = "0.0.1" modules = [] groups = [] [[packages]] 1 name = "microshift" version = "4.17.1" [customizations.services] 2 enabled = ["microshift"] [customizations.firewall] ports = ["22:tcp", "80:tcp", "443:tcp", "5353:udp", "6443:tcp", "30000-32767:tcp", "30000-32767:udp"] [[containers]] 3 source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f41e79c17e8b41f1b0a5a32c3e2dd7cd15b8274554d3f1ba12b2598a347475f4" [[containers]] source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:dbc65f1fba7d92b36cf7514cd130fe83a9bd211005ddb23a8dc479e0eea645fd" ... EOF
sudo composer-cli blueprints push <microshift_blueprint.toml> 1
sudo composer-cli blueprints depsolve <microshift_blueprint> | grep microshift 1
blueprint: microshift_blueprint v0.0.1 microshift-greenboot-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.noarch microshift-networking-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.x86_64 microshift-release-info-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.noarch microshift-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.x86_64 microshift-selinux-4.17.1-202305250827.p0.g4105d3b.assembly.4.17.1.el9.noarch
sudo composer-cli blueprints depsolve <microshift_blueprint> 1
BUILDID=USD(sudo composer-cli compose start-ostree --ref "rhel/{op-system-version-major}/USD(uname -m)/edge" <microshift_blueprint> edge-container | awk '/^Compose/ {print USD2}') 1
sudo composer-cli compose status
ID Status Time Blueprint Version Type Size cc3377ec-4643-4483-b0e7-6b0ad0ae6332 RUNNING Wed Jun 7 12:26:23 2023 microshift_blueprint 0.0.1 edge-container
ID Status Time Blueprint Version Type Size cc3377ec-4643-4483-b0e7-6b0ad0ae6332 FINISHED Wed Jun 7 12:32:37 2023 microshift_blueprint 0.0.1 edge-container
sudo composer-cli compose image USD{BUILDID}
sudo chown USD(whoami). USD{BUILDID}-container.tar
sudo chmod a+r USD{BUILDID}-container.tar
IMAGEID=USD(cat < "./USD{BUILDID}-container.tar" | sudo podman load | grep -o -P '(?<=sha256[@:])[a-z0-9]*')
sudo podman run -d --name=minimal-microshift-server -p 8085:8080 USD{IMAGEID}
cat > microshift-installer.toml <<EOF name = "microshift-installer" description = "" version = "0.0.0" modules = [] groups = [] packages = [] EOF