Skip to content

Commit 3ec564c

Browse files
committed
Build a bootc based EDPM image
See the README.rst for instructions. Jira: OSPRH-10403
1 parent 19cda5d commit 3ec564c

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ ChangeLog
3636
# Editors
3737
*~
3838
*.sw?
39+
bootc/output

bootc/Containerfile.centos9

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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
5+
6+
ARG PACKAGES="\
7+
bind-utils \
8+
buildah \
9+
cephadm \
10+
chrony \
11+
cloud-init \
12+
crudini \
13+
crypto-policies-scripts \
14+
device-mapper-multipath \
15+
driverctl \
16+
grubby \
17+
iproute-tc \
18+
iptables-services \
19+
iscsi-initiator-utils \
20+
jq \
21+
lvm2 \
22+
nftables \
23+
numactl \
24+
openssh-server \
25+
openstack-selinux \
26+
openvswitch \
27+
os-net-config \
28+
podman \
29+
python3-libselinux \
30+
python3-pyyaml \
31+
rsync \
32+
tmpwatch \
33+
tuned-profiles-cpu-partitioning \
34+
sysstat"
35+
ARG ENABLE_UNITS="openvswitch"
36+
37+
RUN dnf -y update && dnf -y install $PACKAGES && dnf clean all && systemctl enable $ENABLE_UNITS

bootc/Makefile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
EDPM_BOOTC_REPO ?= quay.io/openstack-k8s-operators/edpm-bootc
2+
EDPM_BOOTC_TAG ?= latest
3+
EDPM_CONTAINERFILE ?= Containerfile.centos9
4+
EDPM_BOOTC_IMAGE ?= ${EDPM_BOOTC_REPO}:${EDPM_BOOTC_TAG}
5+
EDPM_QCOW2_IMAGE ?= ${EDPM_BOOTC_REPO}:${EDPM_BOOTC_TAG}-qcow2
6+
BUILDER_IMAGE ?= quay.io/centos-bootc/bootc-image-builder:latest
7+
HOST_PACKAGES ?= podman osbuild-selinux
8+
REPO_SETUP ?= current-podified
9+
REPO_SETUP_BRANCH ?= master
10+
REPO_SETUP_DISTRO_MIRROR ?=
11+
REPO_SETUP_MIRROR ?= https://trunk.rdoproject.org
12+
13+
.ONESHELL:
14+
15+
.PHONY: host-deps
16+
host-deps:
17+
sudo dnf install -y ${HOST_PACKAGES}
18+
19+
output:
20+
mkdir -p output
21+
22+
output/repo-setup: output
23+
ls output/repo-setup && exit 0 || true
24+
cd output
25+
curl -sL https://github.com/openstack-k8s-operators/repo-setup/archive/refs/heads/main.tar.gz | tar xvz
26+
cd repo-setup-main
27+
python3 -m venv ./venv
28+
source ./venv/bin/activate
29+
PBR_VERSION=0.0.0 python3 -m pip install ./
30+
cp venv/bin/repo-setup ../repo-setup
31+
32+
output/yum.repos.d: output/repo-setup
33+
ls output/yum.repos.d && exit 0 || true
34+
cd output
35+
mkdir -p yum.repos.d
36+
./repo-setup --output-path yum.repos.d --branch ${REPO_SETUP_BRANCH} --rdo-mirror ${REPO_SETUP_MIRROR} ${REPO_SETUP}
37+
38+
39+
.PHONY: build
40+
build: output/yum.repos.d
41+
sudo buildah inspect ${EDPM_BOOTC_IMAGE} > /dev/null && exit 0 || true
42+
sudo buildah bud -f ${EDPM_CONTAINERFILE} -t ${EDPM_BOOTC_IMAGE} .
43+
44+
.PHONY: edpm-bootc.qcow2
45+
edpm-bootc.qcow2: build
46+
ls output/edpm-bootc.qcow2 && exit 0 || true
47+
sudo podman run --rm -it --privileged \
48+
--security-opt label=type:unconfined_t \
49+
-v ./output:/output \
50+
-v /var/lib/containers/storage:/var/lib/containers/storage \
51+
${BUILDER_IMAGE} \
52+
--type qcow2 \
53+
--local \
54+
${EDPM_BOOTC_IMAGE}
55+
cd output
56+
sudo mv qcow2/disk.qcow2 edpm-bootc.qcow2
57+
sudo sha256sum edpm-bootc.qcow2 > edpm-bootc.qcow2.sha256
58+
59+
.PHONY: package
60+
package: edpm-bootc.qcow2
61+
sudo buildah inspect ${EDPM_QCOW2_IMAGE} > /dev/null && exit 0 || true
62+
cp ../copy_out.sh output/
63+
cp ../Containerfile.image output/
64+
cd output
65+
sudo buildah bud --build-arg IMAGE_NAME=edpm-bootc -f ./Containerfile.image -t ${EDPM_QCOW2_IMAGE}
66+
67+
.PHONY: all
68+
all: build edpm-bootc.qcow2 package
69+
70+
.PHONY: clean
71+
clean:
72+
sudo rm -rf output
73+
74+
.PHONY: realclean
75+
realclean: clean
76+
sudo podman rmi --force ${EDPM_BOOTC_IMAGE} || true
77+
sudo podman rmi --force ${BUILDER_IMAGE} || true
78+
sudo podman rmi --force ${EDPM_QCOW2_IMAGE} || true

bootc/README.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
========================
2+
EDPM bootc image builder
3+
========================
4+
5+
To build a CentOS-9-Stream based bootc EDPM container image, run the following
6+
command::
7+
8+
export EDPM_BOOTC_REPO=quay.io/<account>/edpm-bootc
9+
make build
10+
sudo podman push $EDPM_BOOTC_REPO:latest
11+
12+
To convert this container image to ``output/edpm-bootc.qcow2``, run the
13+
following command::
14+
15+
make edpm-bootc.qcow2
16+
17+
To package ``edpm-bootc.qcow2`` inside a container image EDPM baremetal
18+
deployment, run the following command::
19+
20+
make package
21+
sudo podman push $EDPM_BOOTC_REPO:latest-qcow2
22+
23+
To deploy EDPM baremetal with this image, customize the ``baremetalSetTemplate`` with::
24+
25+
kind: OpenStackDataPlaneNodeSet
26+
spec:
27+
baremetalSetTemplate:
28+
osContainerImageUrl: quay.io/<account>/edpm-bootc:latest-qcow2
29+
osImage: edpm-bootc.qcow2
30+

0 commit comments

Comments
 (0)