Skip to content

Commit 187eb31

Browse files
Merge pull request #67 from steveb/bootc-rhel
Bootc: add RHEL support with internal repos and RHSM
2 parents 1692923 + 4541bab commit 187eb31

File tree

8 files changed

+127
-29
lines changed

8 files changed

+127
-29
lines changed

bootc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rhsm-custom.sh
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
FROM quay.io/centos-bootc/centos-bootc:stream9
2-
3-
RUN rm -rf /etc/yum.repos.d/*.repo
4-
COPY output/yum.repos.d /etc/yum.repos.d
1+
ARG EDPM_BASE_IMAGE
2+
FROM $EDPM_BASE_IMAGE
53

64
ARG PACKAGES="\
75
bind-utils \
@@ -53,7 +51,14 @@ ARG LIBVIRT_PACKAGES="\
5351
cyrus-sasl-scram \
5452
"
5553

56-
RUN dnf -y install $PACKAGES $LIBVIRT_PACKAGES && dnf clean all && systemctl enable $ENABLE_UNITS
54+
ARG RHSM_SCRIPT=empty.sh
55+
COPY $RHSM_SCRIPT /var/tmp/rhsm-script.sh
56+
RUN /var/tmp/rhsm-script.sh && \
57+
dnf -y install $PACKAGES $LIBVIRT_PACKAGES && \
58+
dnf clean all && \
59+
(subscription-manager remove --all || true) && \
60+
(subscription-manager unregister || true) && \
61+
systemctl enable $ENABLE_UNITS
5762

5863
# Drop Ansible fact into place
5964
COPY ansible-facts/bootc.fact /etc/ansible/facts.d/bootc.fact

bootc/Makefile

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
SHELL := /bin/bash
22
EDPM_BOOTC_REPO ?= quay.io/openstack-k8s-operators/edpm-bootc
33
EDPM_BOOTC_TAG ?= latest
4-
EDPM_CONTAINERFILE ?= Containerfile.centos9
4+
EDPM_CONTAINERFILE ?= Containerfile
5+
EDPM_BASE_IMAGE ?= quay.io/centos-bootc/centos-bootc:stream9
56
EDPM_BOOTC_IMAGE ?= ${EDPM_BOOTC_REPO}:${EDPM_BOOTC_TAG}
67
EDPM_QCOW2_IMAGE ?= ${EDPM_BOOTC_REPO}:${EDPM_BOOTC_TAG}-qcow2
78
BUILDER_IMAGE ?= quay.io/centos-bootc/bootc-image-builder:latest
8-
HOST_PACKAGES ?= podman osbuild-selinux
9-
REPO_SETUP ?= current-podified
10-
REPO_SETUP_BRANCH ?= master
11-
REPO_SETUP_DISTRO ?= centos9
12-
REPO_SETUP_DISTRO_MIRROR ?=
13-
REPO_SETUP_MIRROR ?= https://trunk.rdoproject.org
9+
HOST_PACKAGES ?= podman osbuild-selinux https://download.devel.redhat.com/rcm-guest/puddles/OpenStack/rhos-release/rhos-release-latest.noarch.rpm
10+
RHSM_SCRIPT ?= empty.sh
1411

1512
.ONESHELL:
1613

@@ -23,25 +20,23 @@ output:
2320

2421
output/repo-setup: output
2522
ls output/repo-setup && exit 0 || true
26-
cd output
27-
curl -sL https://github.com/openstack-k8s-operators/repo-setup/archive/refs/heads/main.tar.gz | tar xvz
28-
cd repo-setup-main
29-
python3 -m venv ./venv
30-
source ./venv/bin/activate
31-
PBR_VERSION=0.0.0 python3 -m pip install ./
32-
cp venv/bin/repo-setup ../repo-setup
23+
./install-repo-setup.sh
3324

3425
output/yum.repos.d: output/repo-setup
3526
ls output/yum.repos.d && exit 0 || true
36-
cd output
37-
mkdir -p yum.repos.d
38-
./repo-setup --output-path yum.repos.d --branch ${REPO_SETUP_BRANCH} --rdo-mirror ${REPO_SETUP_MIRROR} -d ${REPO_SETUP_DISTRO} ${REPO_SETUP}
39-
27+
mkdir -p output/yum.repos.d
28+
./run-repo-setup.sh
4029

4130
.PHONY: build
4231
build: output/yum.repos.d
4332
sudo buildah inspect ${EDPM_BOOTC_IMAGE} > /dev/null && exit 0 || true
44-
sudo buildah bud -f ${EDPM_CONTAINERFILE} -t ${EDPM_BOOTC_IMAGE} .
33+
sudo buildah bud \
34+
--build-arg EDPM_BASE_IMAGE=${EDPM_BASE_IMAGE} \
35+
--build-arg RHSM_SCRIPT=${RHSM_SCRIPT} \
36+
--volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro,Z \
37+
--volume $(shell pwd)/output/yum.repos.d:/etc/yum.repos.d:rw,Z \
38+
-f ${EDPM_CONTAINERFILE} \
39+
-t ${EDPM_BOOTC_IMAGE} .
4540

4641
.PHONY: build-push
4742
build-push: build

bootc/README.rst

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,58 @@
22
EDPM bootc image builder
33
========================
44

5+
Pre-requesites can be installed by running::
6+
7+
make host-deps
8+
59
To build a CentOS-9-Stream based bootc EDPM container image, run the following
6-
command::
10+
commands::
11+
12+
export EDPM_BOOTC_REPO=quay.io/<account>/edpm-bootc
13+
export EDPM_BOOTC_TAG=centos9
14+
make build
15+
sudo podman push $EDPM_BOOTC_REPO:$EDPM_BOOTC_TAG
16+
17+
To build a RHEL-9.4 based bootc EDPM container image using internal
18+
repositories, install the required certificates then run the following
19+
commands::
20+
21+
# switch to RHEL-9.4 images
22+
export BUILDER_IMAGE=registry.redhat.io/rhel9/bootc-image-builder:9.4
23+
export EDPM_BASE_IMAGE=registry.redhat.io/rhel9/rhel-bootc:9.4
24+
25+
# Config to build repository files for internal repos
26+
export CURL_CA_BUNDLE=/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
27+
export REPO_SETUP_DISTRO=rhel9
28+
export REPO_SETUP=current-podified
29+
export REPO_SETUP_BRANCH=osp18
30+
export REPO_SETUP_MIRROR=<mirror for internal repos>
31+
export REPO_SETUP_EXTRA="rhos-release ceph-6.0 -r 9.4 -t yum.repos.d"
32+
33+
# login to the registry
34+
sudo podman login registry.redhat.io
35+
36+
export EDPM_BOOTC_REPO=quay.io/<account>/edpm-bootc
37+
export EDPM_BOOTC_TAG=rhel9-rhos-release
38+
make build
39+
sudo podman push $EDPM_BOOTC_REPO:$EDPM_BOOTC_TAG
40+
41+
To build a RHEL-9.4 based bootc EDPM container using published packages, run
42+
the following commands::
43+
44+
# switch to RHEL-9.4 images
45+
export BUILDER_IMAGE=registry.redhat.io/rhel9/bootc-image-builder:9.4
46+
export EDPM_BASE_IMAGE=registry.redhat.io/rhel9/rhel-bootc:9.4
47+
48+
# make a custom copy of the subscription-manager script and edit it for
49+
# your registration details
50+
cp rhsm.sh rhsm-custom.sh
51+
export RHSM_SCRIPT=rhsm-custom.sh
752

853
export EDPM_BOOTC_REPO=quay.io/<account>/edpm-bootc
54+
export EDPM_BOOTC_TAG=rhel9-rhsm
955
make build
10-
sudo podman push $EDPM_BOOTC_REPO:latest
56+
sudo podman push $EDPM_BOOTC_REPO:$EDPM_BOOTC_TAG
1157

1258
To convert this container image to ``output/edpm-bootc.qcow2``, run the
1359
following command::
@@ -18,12 +64,14 @@ To package ``edpm-bootc.qcow2`` inside a container image EDPM baremetal
1864
deployment, run the following command::
1965

2066
make package
21-
sudo podman push $EDPM_BOOTC_REPO:latest-qcow2
67+
sudo podman push $EDPM_BOOTC_REPO:$EDPM_BOOTC_TAG-qcow2
2268

23-
To deploy EDPM baremetal with this image, customize the ``baremetalSetTemplate`` with::
69+
To deploy EDPM baremetal with this image, customize the
70+
``baremetalSetTemplate`` substituting values for ``<EDPM_BOOTC_REPO>`` and
71+
``<EDPM_BOOTC_TAG>`` ::
2472

2573
kind: OpenStackDataPlaneNodeSet
2674
spec:
2775
baremetalSetTemplate:
28-
osContainerImageUrl: quay.io/<account>/edpm-bootc:latest-qcow2
76+
osContainerImageUrl: <EDPM_BOOTC_REPO>:<EDPM_BOOTC_TAG>-qcow2
2977
osImage: edpm-bootc.qcow2

bootc/empty.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
# script deliberately left empty

bootc/install-repo-setup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
pushd output
6+
curl -sL https://github.com/openstack-k8s-operators/repo-setup/archive/refs/heads/main.tar.gz | tar xvz
7+
pushd repo-setup-main
8+
python3 -m venv ./venv
9+
source ./venv/bin/activate
10+
PBR_VERSION=0.0.0 python3 -m pip install ./
11+
cp venv/bin/repo-setup ../repo-setup
12+
popd
13+
popd

bootc/rhsm.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
# Edit RHSM_ values for the subscription configuration
6+
RHSM_USER=unset
7+
RHSM_PASSWORD=unset
8+
RHSM_REPOS="--enable=rhoso-18.0-for-rhel-9-x86_64-rpms \
9+
--enable=rhceph-8-tools-for-rhel-9-x86_64-rpms \
10+
--enable=fast-datapath-for-rhel-9-x86_64-rpms"
11+
# Only required when Simple Content Access (SCA) is disabled
12+
RHSM_POOL=""
13+
14+
rm /etc/yum.repos.d/*.repo
15+
subscription-manager register --username=$RHSM_USER --password=$RHSM_PASSWORD
16+
if [ -n "${RHSM_POOL}" ]; then
17+
subscription-manager attach --pool=$RHSM_POOL
18+
fi
19+
subscription-manager repos $RHSM_REPOS

bootc/run-repo-setup.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
REPO_SETUP=${REPO_SETUP:-current-podified}
6+
REPO_SETUP_BRANCH=${REPO_SETUP_BRANCH:-antelope}
7+
REPO_SETUP_DISTRO=${REPO_SETUP_DISTRO:-centos9}
8+
REPO_SETUP_MIRROR=${REPO_SETUP_MIRROR:-https://trunk.rdoproject.org}
9+
REPO_SETUP_EXTRA=${REPO_SETUP_EXTRA:-echo Done}
10+
11+
pushd output
12+
./repo-setup --output-path yum.repos.d --branch ${REPO_SETUP_BRANCH} --rdo-mirror ${REPO_SETUP_MIRROR} -d ${REPO_SETUP_DISTRO} ${REPO_SETUP}
13+
$REPO_SETUP_EXTRA
14+
popd

0 commit comments

Comments
 (0)