Skip to content

Commit f915e4c

Browse files
authored
Build Multus RPM (#211)
* Build Multus RPM * Build cli-artifacts image * Test for isolated ovnk+multus
1 parent c2e15e2 commit f915e4c

8 files changed

Lines changed: 106 additions & 2 deletions

File tree

.github/actions/build/action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
description: Use OVN-K networking
2525
required: false
2626
default: 0
27+
with-multus:
28+
description: Enable Multus CNI
29+
required: false
30+
default: 0
2731
node-count:
2832
description: Number of nodes in the MicroShift cluster
2933
required: false
@@ -76,6 +80,7 @@ runs:
7680
make_opts=()
7781
[ "${{ inputs.isolated-network }}" = "1" ] && make_opts+=("EMBED_CONTAINER_IMAGES=1")
7882
[ "${{ inputs.ovnk-networking }}" = "1" ] && make_opts+=("WITH_KINDNET=0")
83+
[ "${{ inputs.with-multus }}" = "1" ] && make_opts+=("WITH_MULTUS=1")
7984
8085
make image \
8186
BOOTC_IMAGE_URL="${{ inputs.bootc-image-url }}" \

.github/workflows/builders.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,15 @@ jobs:
9393
- name: kindnet
9494
runner: ubuntu-24.04
9595
ovnk-networking: 0
96+
with-multus: 0
9697
- name: ovnk
9798
runner: ubuntu-24.04
9899
ovnk-networking: 1
100+
with-multus: 0
101+
- name: ovnk-multus
102+
runner: ubuntu-24.04
103+
ovnk-networking: 1
104+
with-multus: 1
99105
runs-on: ${{ matrix.runner }}
100106
steps:
101107
- name: Check out MicroShift upstream repository
@@ -112,3 +118,4 @@ jobs:
112118
okd-version-tag: ${{ steps.detect-okd-version.outputs.okd-version-tag }}
113119
isolated-network: 1
114120
ovnk-networking: ${{ matrix.ovnk-networking }}
121+
with-multus: ${{ matrix.with-multus }}

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ BOOTC_IMAGE_TAG ?= stream9
2121
WITH_KINDNET ?= 1
2222
WITH_TOPOLVM ?= 1
2323
WITH_OLM ?= 0
24+
WITH_MULTUS ?= 0
2425
EMBED_CONTAINER_IMAGES ?= 0
2526

2627
# Options used in the 'run' target
@@ -130,6 +131,7 @@ image:
130131
--env WITH_KINDNET="${WITH_KINDNET}" \
131132
--env WITH_TOPOLVM="${WITH_TOPOLVM}" \
132133
--env WITH_OLM="${WITH_OLM}" \
134+
--env WITH_MULTUS="${WITH_MULTUS}" \
133135
--env EMBED_CONTAINER_IMAGES="${EMBED_CONTAINER_IMAGES}" \
134136
-f packaging/bootc.Containerfile .
135137

packaging/bootc.Containerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ARG BUILDER_RSHARED_SERVICE=/home/microshift/microshift/packaging/imagemode/syst
1818
ENV WITH_KINDNET=${WITH_KINDNET:-1}
1919
ENV WITH_TOPOLVM=${WITH_TOPOLVM:-1}
2020
ENV WITH_OLM=${WITH_OLM:-0}
21+
ENV WITH_MULTUS=${WITH_MULTUS:-0}
2122
ENV EMBED_CONTAINER_IMAGES=${EMBED_CONTAINER_IMAGES:-0}
2223

2324
# Run repository configuration script, install MicroShift and cleanup
@@ -36,6 +37,9 @@ RUN ${REPO_CONFIG_SCRIPT} -create ${USHIFT_RPM_REPO_PATH} && \
3637
if [ "${WITH_OLM}" = "1" ] ; then \
3738
dnf install -y microshift-olm microshift-olm-release-info ; \
3839
fi && \
40+
if [ "${WITH_MULTUS}" = "1" ] ; then \
41+
dnf install -y microshift-multus microshift-multus-release-info ; \
42+
fi && \
3943
${REPO_CONFIG_SCRIPT} -delete && \
4044
rm -vf ${REPO_CONFIG_SCRIPT} && \
4145
rm -rvf ${USHIFT_RPM_REPO_PATH} && \

packaging/srpm.Containerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ COPY ./src/topolvm/greenboot/ ./packaging/greenboot/
5858
COPY ./src/topolvm/release/ ./assets/optional/topolvm/
5959

6060
RUN ARCH="x86_64" "${USHIFT_PREBUILD_SCRIPT}" --replace-kindnet "${OKD_RELEASE_IMAGE_X86_64}" "${OKD_VERSION_TAG}" && \
61-
ARCH="aarch64" "${USHIFT_PREBUILD_SCRIPT}" --replace-kindnet "${OKD_RELEASE_IMAGE_AARCH64}" "${OKD_VERSION_TAG}"
61+
ARCH="aarch64" "${USHIFT_PREBUILD_SCRIPT}" --replace-kindnet "${OKD_RELEASE_IMAGE_AARCH64}" "${OKD_VERSION_TAG}" && \
62+
ARCH="x86_64" "${USHIFT_PREBUILD_SCRIPT}" --replace-multus "${OKD_RELEASE_IMAGE_X86_64}" "${OKD_VERSION_TAG}" && \
63+
ARCH="aarch64" "${USHIFT_PREBUILD_SCRIPT}" --replace-multus "${OKD_RELEASE_IMAGE_AARCH64}" "${OKD_VERSION_TAG}"
6264

6365
COPY --chmod=755 ./src/image/modify-spec.py ${USHIFT_MODIFY_SPEC_SCRIPT}
6466
# Disable the RPM and SRPM checks in the make-rpm.sh script

src/image/modify-spec.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
# Subpackages to remove
1414
pkgs_to_remove = [
15-
'multus',
1615
'low-latency',
1716
'gateway-api',
1817
'ai-model-serving',

src/image/prebuild.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,36 @@ replace_kindnet_assets() {
168168
mv "${temp_json}" "${MICROSHIFT_ROOT}/assets/optional/kube-proxy/release-kube-proxy-${ARCH}.json"
169169
}
170170

171+
replace_multus_assets() {
172+
local -r okd_url=$1
173+
local -r okd_releaseTag=$2
174+
local -r temp_json="$(mktemp "/tmp/release-multus-${ARCH}.XXXXX.json")"
175+
176+
# Install the yq tool
177+
"${MICROSHIFT_ROOT}"/scripts/fetch_tools.sh yq
178+
179+
local -r multus_release_json="${MICROSHIFT_ROOT}/assets/components/multus/release-multus-${ARCH}.json"
180+
local -r kustomization_arch_file="${MICROSHIFT_ROOT}/assets/components/multus/kustomization.${ARCH}.yaml"
181+
182+
for container in multus-cni-microshift containernetworking-plugins-microshift ; do
183+
local image_with_hash
184+
image_with_hash=$(oc_release_info "${okd_url}" "${okd_releaseTag}" "${container}")
185+
echo "[${ARCH}] Replacing '${container}' with '${image_with_hash}'"
186+
local image_name="${image_with_hash%%@*}"
187+
local image_hash="${image_with_hash##*@}"
188+
189+
# Update the kustomization file with the new image name and digest
190+
"${MICROSHIFT_ROOT}"/_output/bin/yq eval \
191+
".images[] |= select(.name == \"${container}\") |= (.newName = \"${image_name}\" | .digest = \"${image_hash}\")" \
192+
-i "${kustomization_arch_file}"
193+
194+
# Update the release JSON file
195+
jq --arg container "${container}" --arg img "${image_with_hash}" \
196+
'.images[$container] = $img' "${multus_release_json}" >"${temp_json}"
197+
mv "${temp_json}" "${multus_release_json}"
198+
done
199+
}
200+
171201
fix_rpm_spec() {
172202
# Fix the RPM spec by removing the microshift-networking package hard dependency
173203
sed -i 's/Requires: microshift-networking/Recommends: microshift-networking/' "${MICROSHIFT_ROOT}/packaging/rpm/microshift.spec"
@@ -178,6 +208,7 @@ usage() {
178208
echo "$(basename "$0") --verify OKD_URL RELEASE_TAG verify OKD upstream release"
179209
echo "$(basename "$0") --replace OKD_URL RELEASE_TAG replace MicroShift assets with OKD upstream images"
180210
echo "$(basename "$0") --replace-kindnet OKD_URL RELEASE_TAG replace Kindnet assets with OKD upstream images"
211+
echo "$(basename "$0") --replace-multus OKD_URL RELEASE_TAG replace Multus assets with OKD upstream images"
181212
exit 1
182213
}
183214

@@ -199,6 +230,10 @@ case "$1" in
199230
verify_okd_release "$2" "$3"
200231
replace_kindnet_assets "$2" "$3"
201232
;;
233+
--replace-multus)
234+
verify_okd_release "$2" "$3"
235+
replace_multus_assets "$2" "$3"
236+
;;
202237
--verify)
203238
verify_okd_release "$2" "$3"
204239
;;

src/okd/build_images.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,21 @@ cli_image() {
212212
podman build --platform "linux/${TARGET_ARCH}" -t "${images[cli]}" -f "${dockerfile_path}" .
213213
}
214214

215+
# Function to handle cli-artifacts-image repository (same repo as cli)
216+
cli_artifacts_image() {
217+
local -r dockerfile_path="images/cli-artifacts/Dockerfile.rhel"
218+
local -r repo="${WORKDIR}/oc"
219+
220+
# Reuse the already cloned oc repository from cli_image()
221+
cd "${repo}" || { echo "Failed to access oc repository directory"; return 1; }
222+
sed -i 's|FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang|FROM registry.ci.openshift.org/openshift/release:rhel-8-release-golang|' "${dockerfile_path}"
223+
sed -i 's|FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang|FROM registry.ci.openshift.org/openshift/release:rhel-9-release-golang|' "${dockerfile_path}"
224+
sed -i "s|^FROM registry.ci.openshift.org/ocp/.*:base-rhel9|FROM ${images[base]}|" "${dockerfile_path}"
225+
sed -i "s|^FROM registry.ci.openshift.org/ocp/.*:cli|FROM ${images[cli]}|" "${dockerfile_path}"
226+
227+
podman build --platform "linux/${TARGET_ARCH}" -t "${images[cli-artifacts]}" -f "${dockerfile_path}" .
228+
}
229+
215230
# Function to handle service-ca-operator-image repository
216231
service_ca_operator_image() {
217232
local -r repo_url="https://github.com/openshift/service-ca-operator"
@@ -263,6 +278,32 @@ ovn_kubernetes_microshift_image() {
263278
podman build --platform "linux/${TARGET_ARCH}" -t "${images[ovn-kubernetes-microshift]}" -f "${dockerfile_microshift_path}" .
264279
}
265280

281+
# Function to handle multus-cni-microshift image repository
282+
multus_cni_microshift_image() {
283+
local -r repo_url="https://github.com/openshift/multus-cni"
284+
local -r dockerfile_path="Dockerfile.microshift"
285+
local -r repo="${WORKDIR}/$(basename "${repo_url}")"
286+
287+
git_clone_repo "${repo_url}" "${OCP_BRANCH}" "${repo}"
288+
sed -i 's|FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang|FROM registry.ci.openshift.org/openshift/release:rhel-9-release-golang|' "${dockerfile_path}"
289+
sed -i "s|^FROM registry.ci.openshift.org/ocp/.*:base-rhel9|FROM ${images[base]}|" "${dockerfile_path}"
290+
291+
podman build --platform "linux/${TARGET_ARCH}" -t "${images[multus-cni-microshift]}" -f "${dockerfile_path}" .
292+
}
293+
294+
# Function to handle containernetworking-plugins-microshift image repository
295+
containernetworking_plugins_microshift_image() {
296+
local -r repo_url="https://github.com/openshift/containernetworking-plugins"
297+
local -r dockerfile_path="Dockerfile.microshift"
298+
local -r repo="${WORKDIR}/$(basename "${repo_url}")"
299+
300+
git_clone_repo "${repo_url}" "${OCP_BRANCH}" "${repo}"
301+
sed -i 's|FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang|FROM registry.ci.openshift.org/openshift/release:rhel-9-release-golang|' "${dockerfile_path}"
302+
sed -i "s|^FROM registry.ci.openshift.org/ocp/.*:base-rhel9|FROM ${images[base]}|" "${dockerfile_path}"
303+
304+
podman build --platform "linux/${TARGET_ARCH}" -t "${images[containernetworking-plugins-microshift]}" -f "${dockerfile_path}" .
305+
}
306+
266307
# Run all the image creation procedures
267308
create_images() {
268309
base_image
@@ -273,8 +314,11 @@ create_images() {
273314
kube_rbac_proxy_image
274315
pod_image
275316
cli_image
317+
cli_artifacts_image
276318
service_ca_operator_image
277319
operator_lifecycle_manager_image
320+
multus_cni_microshift_image
321+
containernetworking_plugins_microshift_image
278322
# ovn_kubernetes_microshift_image
279323
}
280324

@@ -327,6 +371,7 @@ create_new_okd_release() {
327371
oc adm release new --from-release "quay.io/okd/scos-release:${OKD_VERSION}" \
328372
--keep-manifest-list \
329373
"cli=${images_sha[cli]}" \
374+
"cli-artifacts=${images_sha[cli-artifacts]}" \
330375
${haproxy_router_image} \
331376
"kube-proxy=${images_sha[kube-proxy]}" \
332377
"coredns=${images_sha[coredns]}" \
@@ -336,6 +381,8 @@ create_new_okd_release() {
336381
"service-ca-operator=${images_sha[service-ca-operator]}" \
337382
"operator-lifecycle-manager=${images_sha[operator-lifecycle-manager]}" \
338383
"operator-registry=${images_sha[operator-registry]}" \
384+
"multus-cni-microshift=${images_sha[multus-cni-microshift]}" \
385+
"containernetworking-plugins-microshift=${images_sha[containernetworking-plugins-microshift]}" \
339386
--to-image "${OKD_RELEASE_IMAGE}"
340387

341388
# "ovn-kubernetes-base=${images_sha[ovn-kubernetes-base]}" \
@@ -508,6 +555,7 @@ fi
508555
images=(
509556
[base]="${TARGET_REGISTRY}/scos-${OKD_VERSION}:base-stream9-${TARGET_ARCH}"
510557
[cli]="${TARGET_REGISTRY}/cli:${OKD_VERSION}-${TARGET_ARCH}"
558+
[cli-artifacts]="${TARGET_REGISTRY}/cli-artifacts:${OKD_VERSION}-${TARGET_ARCH}"
511559
[haproxy-router-base]="${TARGET_REGISTRY}/haproxy-router-base:${OKD_VERSION}-${TARGET_ARCH}"
512560
[haproxy-router]="${TARGET_REGISTRY}/haproxy-router:${OKD_VERSION}-${TARGET_ARCH}"
513561
[kube-proxy]="${TARGET_REGISTRY}/kube-proxy:${OKD_VERSION}-${TARGET_ARCH}"
@@ -518,6 +566,8 @@ images=(
518566
[service-ca-operator]="${TARGET_REGISTRY}/service-ca-operator:${OKD_VERSION}-${TARGET_ARCH}"
519567
[operator-lifecycle-manager]="${TARGET_REGISTRY}/operator-lifecycle-manager:${OKD_VERSION}-${TARGET_ARCH}"
520568
[operator-registry]="${TARGET_REGISTRY}/operator-registry:${OKD_VERSION}-${TARGET_ARCH}"
569+
[multus-cni-microshift]="${TARGET_REGISTRY}/multus-cni-microshift:${OKD_VERSION}-${TARGET_ARCH}"
570+
[containernetworking-plugins-microshift]="${TARGET_REGISTRY}/containernetworking-plugins-microshift:${OKD_VERSION}-${TARGET_ARCH}"
521571
# [ovn-kubernetes-base]="${TARGET_REGISTRY}/ovn-kubernetes-base:${OKD_VERSION}-${TARGET_ARCH}"
522572
# [ovn-kubernetes-microshift]="${TARGET_REGISTRY}/ovn-kubernetes-microshift:${OKD_VERSION}-${TARGET_ARCH}"
523573
)

0 commit comments

Comments
 (0)