Skip to content

Commit 826641d

Browse files
committed
AGENT-1193: Add mirror-path and registry-cert support for OVE ISO builder
Add support for using pre-mirrored images (--mirror-path) and custom registry certificates (--registry-cert) when building OVE ISOs. This allows building ISOs in disconnected environments without requiring oc-mirror to run during the build process. Note: mirror-path and registry-cert options are only available when using the script build method (build-ove-iso). The container build method (build-ove-iso-container) does not support these options. Changes to hack/build-ove-image.sh: - Add --mirror-path parameter to pass pre-mirrored images directory - Add --registry-cert parameter for custom registry certificates - Mount mirror path and certificate when running appliance container - Override entrypoint to install certificate before running appliance Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7bcf224 commit 826641d

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

tools/iso_builder/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ ARCH ?= x86_64
44
PULL_SECRET_FILE ?= ./pull-secret.json
55
RELEASE_IMAGE_URL ?=
66
RELEASE_IMAGE_VERSION ?=
7+
MIRROR_PATH ?=
8+
REGISTRY_CERT ?=
79

810
ifdef RELEASE_IMAGE_VERSION
911
RELEASE_FLAG := --ocp-version
@@ -25,7 +27,7 @@ clean-appliance-temp-dir:
2527
hack/cleanup.sh clean-appliance-temp-dir
2628

2729
build-ove-iso:
28-
hack/build-ove-image.sh $(RELEASE_FLAG) $(RELEASE_VALUE) --pull-secret-file $(PULL_SECRET_FILE)
30+
hack/build-ove-image.sh $(RELEASE_FLAG) $(RELEASE_VALUE) --pull-secret-file $(PULL_SECRET_FILE) $(if $(MIRROR_PATH),--mirror-path $(MIRROR_PATH)) $(if $(REGISTRY_CERT),--registry-cert $(REGISTRY_CERT))
2931

3032
build-ove-iso-container:
3133
# Build the container with specific capabilities to support podman used by openshift-appliance

tools/iso_builder/hack/build-ove-image.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export RELEASE_IMAGE_VERSION=""
1212
export RELEASE_IMAGE_URL=""
1313
export ARCH=""
1414
export DIR_PATH=""
15+
export MIRROR_PATH=""
16+
export REGISTRY_CERT=""
1517

1618
# Check user provided params
1719
[[ $# -lt 2 ]] && usage
@@ -62,9 +64,34 @@ EOF
6264

6365
function build_live_iso() {
6466
if [ ! -f "${appliance_work_dir}"/appliance.iso ]; then
65-
local appliance_image=registry.ci.openshift.org/ocp/${major_minor_version}:agent-preinstall-image-builder
67+
#local appliance_image=registry.ci.openshift.org/ocp/${major_minor_version}:agent-preinstall-image-builder
68+
local appliance_image=quay.io/rwsu1/openshift-appliance:dev-scripts
6669
echo "Building appliance ISO (image: ${appliance_image})"
67-
$SUDO podman run --authfile "${PULL_SECRET_FILE}" --rm -it --privileged --pull always --net=host -v "${appliance_work_dir}"/:/assets:Z "${appliance_image}" build live-iso --log-level debug
70+
71+
# Build the podman run command with optional mirror path
72+
local podman_cmd="$SUDO podman run --authfile \"${PULL_SECRET_FILE}\" --rm -it --privileged --pull always --net=host -v \"${appliance_work_dir}\"/:/assets:Z"
73+
local appliance_cmd="build live-iso --log-level debug"
74+
75+
# Add mirror path mount and flag if provided
76+
if [[ -n "${MIRROR_PATH}" ]]; then
77+
echo "Using pre-mirrored images from: ${MIRROR_PATH}"
78+
podman_cmd="${podman_cmd} -v \"${MIRROR_PATH}\":/mirror:Z"
79+
appliance_cmd="${appliance_cmd} --mirror-path /mirror"
80+
fi
81+
82+
# Add registry certificate mount if provided (for custom registries with self-signed certs)
83+
if [[ -n "${REGISTRY_CERT}" ]]; then
84+
echo "Mounting registry certificate for TLS verification: ${REGISTRY_CERT}"
85+
podman_cmd="${podman_cmd} -v \"${REGISTRY_CERT}\":/etc/pki/ca-trust/source/anchors/registry.crt:Z,ro"
86+
# Override entrypoint to run update-ca-trust before openshift-appliance
87+
# Must include --dir assets as it's in the original entrypoint
88+
podman_cmd="${podman_cmd} --entrypoint sh"
89+
appliance_cmd="-c 'update-ca-trust && /openshift-appliance --dir assets ${appliance_cmd}'"
90+
fi
91+
92+
set -x
93+
eval "${podman_cmd} \"${appliance_image}\" ${appliance_cmd}"
94+
set +x
6895
else
6996
echo "Skip building appliance ISO. Reusing ${appliance_work_dir}/appliance.iso."
7097
fi

tools/iso_builder/hack/helper.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ set -euo pipefail
66
function parse_inputs() {
77
while [[ "$#" -gt 0 ]]; do
88
case $1 in
9-
--release-image-url)
9+
--release-image-url)
1010
if [[ -n "$RELEASE_IMAGE_VERSION" ]]; then
1111
echo "Error: Cannot specify both --release-image-url and --ocp-version." >&2
1212
usage
1313
exit 1
1414
fi
1515
RELEASE_IMAGE_URL="$2"; shift ;;
16-
--ocp-version)
16+
--ocp-version)
1717
if [[ -n "$RELEASE_IMAGE_URL" ]]; then
1818
echo "Error: Cannot specify both --release-image-url and --ocp-version." >&2
1919
usage
@@ -23,9 +23,11 @@ function parse_inputs() {
2323
--arch) ARCH="$2"; shift ;;
2424
--pull-secret-file) PULL_SECRET_FILE="$2"; shift ;;
2525
--ssh-key-file) SSH_KEY_FILE="$2"; shift ;;
26+
--mirror-path) MIRROR_PATH="$2"; shift ;;
27+
--registry-cert) REGISTRY_CERT="$2"; shift ;;
2628
--dir) DIR_PATH="$2"; shift ;;
2729
--step) STEP="$2"; shift ;;
28-
*)
30+
*)
2931
echo "Unknown parameter: $1" >&2
3032
usage
3133
exit 1 ;;
@@ -70,6 +72,16 @@ function validate_inputs() {
7072
exit 1
7173
fi
7274

75+
if [[ -n "$REGISTRY_CERT" && ! -f "$REGISTRY_CERT" ]]; then
76+
echo "Error: Registry certificate file $REGISTRY_CERT does not exist." >&2
77+
exit 1
78+
fi
79+
80+
if [[ -n "$MIRROR_PATH" && ! -d "$MIRROR_PATH" ]]; then
81+
echo "Error: Mirror path $MIRROR_PATH does not exist or is not a directory." >&2
82+
exit 1
83+
fi
84+
7385
if [[ -z "${DIR_PATH:-}" ]]; then
7486
DIR_PATH="/tmp/iso_builder"
7587
echo "Directory path not specified. Using default location: $DIR_PATH."
@@ -155,6 +167,8 @@ function usage() {
155167
echo " --arch <architecture> Target CPU architecture (default: x86_64)"
156168
echo " --ssh-key-file <path> Path to the SSH key file (e.g., ~/.ssh/id_rsa)"
157169
echo " --dir <path> Path for ISOBuilder assets (default: /tmp/iso_builder)"
170+
echo " --mirror-path <path> Path to pre-mirrored images (skips oc-mirror if provided)"
171+
echo " --registry-cert <path> Path to registry certificate for custom registries with self-signed certs"
158172
echo " --step <step> Control the steps that will be invoked, options are all, configure, and create-iso (default: all)"
159173
echo ""
160174
echo "Examples:"

0 commit comments

Comments
 (0)