From c109bf533babf89b5e7688e72aa0ee709bda3741 Mon Sep 17 00:00:00 2001 From: "Frank A. Zdarsky" Date: Thu, 15 Dec 2022 12:15:28 +0000 Subject: [PATCH 1/2] Add release-info package Introduces a new subpackage microshift-release-info that contains JSON files with the pull specs of the container images used by the respective MicroShift version. Also moves this release info from code (release_*.go) into a JSON in the assets folder (release-*.json) for more robust processing using jq. That also allows to remove the get.sh script. Updates scripts and docs accordingly. Signed-off-by: Frank A. Zdarsky --- Makefile | 2 +- assets/embed.go | 2 +- assets/release/release-aarch64.json | 20 ++++++++++ assets/release/release-x86_64.json | 20 ++++++++++ docs/devenv_rhel8.md | 9 +++-- docs/rhel4edge_iso.md | 7 ++-- packaging/rpm/microshift.spec | 29 ++++++++++++-- pkg/release/get.sh | 45 ---------------------- pkg/release/release.go | 56 +++++++++++++++++++-------- pkg/release/release_amd64.go | 38 ------------------ pkg/release/release_arm64.go | 38 ------------------ scripts/auto-rebase/rebase.sh | 60 ++++++++++++++++------------- scripts/image-builder/build.sh | 15 +++----- scripts/verify_images.sh | 2 +- 14 files changed, 155 insertions(+), 188 deletions(-) create mode 100644 assets/release/release-aarch64.json create mode 100644 assets/release/release-x86_64.json delete mode 100755 pkg/release/get.sh delete mode 100644 pkg/release/release_amd64.go delete mode 100644 pkg/release/release_arm64.go diff --git a/Makefile b/Makefile index 58da1f5273..175ede69b9 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ export BIN_TIMESTAMP ?=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') export TIMESTAMP ?=$(shell echo $(BIN_TIMESTAMP) | tr -d ':' | tr 'T' '-' | tr -d 'Z') SOURCE_GIT_COMMIT_TIMESTAMP ?= $(shell TZ=UTC0 git show --quiet --date='format-local:%Y%m%d%H%M%S' --format="%cd") -OCP_VERSION := $(shell awk -F'["-]' '/var Base/ {print $$2}' ${PROJECT_DIR}/pkg/release/release.go) +OCP_VERSION := $(shell jq -r '.release.base' ${PROJECT_DIR}/assets/release/release-$(shell uname -i).json) MICROSHIFT_VERSION ?= $(subst -clean,,$(shell echo '${OCP_VERSION}-${SOURCE_GIT_COMMIT_TIMESTAMP}-${SOURCE_GIT_COMMIT}-${SOURCE_GIT_TREE_STATE}')) # Overload SOURCE_GIT_TAG value set in vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk diff --git a/assets/embed.go b/assets/embed.go index e5e29cec4f..85b1de4249 100644 --- a/assets/embed.go +++ b/assets/embed.go @@ -2,7 +2,7 @@ package embedded import "embed" -//go:embed components controllers core crd version +//go:embed components controllers core crd version release var content embed.FS func Asset(name string) ([]byte, error) { diff --git a/assets/release/release-aarch64.json b/assets/release/release-aarch64.json new file mode 100644 index 0000000000..57d3af5815 --- /dev/null +++ b/assets/release/release-aarch64.json @@ -0,0 +1,20 @@ +{ + "release": { + "base": "4.12.0-0.nightly-arm64-2022-12-15-220457" + }, + "images": { + "cli": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:caa0fe9b53e4b0d2c9988fc20fa745ad80817a7cec36ba098d1812fab03e2add", + "coredns": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:cbe32c3940f369eb9093d2b6669a22ce4fd3b1c0781c2afd74f1b0b1e6bd3a9d", + "haproxy-router": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:e19d3bcfc797cd879db6043ef59c1d9e9c8c199181f5f2b6cca5e4c7cfed0a5d", + "kube-rbac-proxy": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:329566d40a19ff6914c4d584c7526c2093917a1437eb32c9f299f1c62350d035", + "odf-topolvm": "quay.io/rh-storage-partners/microshift-topolvm@sha256:616fe64c9f2d1315cec655d482e7b26596594e879e07017e0e610d37c72bacd0", + "openssl": "registry.access.redhat.com/ubi8/openssl@sha256:9e743d947be073808f7f1750a791a3dbd81e694e37161e8c6c6057c2c342d671", + "csi-external-provisioner": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f8a246885c509a113cbd7ce43f78ea764752fad2f1bf2b61849abcaa77baacff", + "csi-external-resizer": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:b9524eb63c3408c2889ec926f2ebdf9d4ab4689c3ad50594eb8d80a9bdd0dbc9", + "csi-node-driver-registrar": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:66d99027850fac4ed6f6f9cef8f6247c08881f75648492b76a9e7f50ff9dc115", + "csi-livenessprobe": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:ea75863f09d2a45ef549e08b6c75fe2058ca142ecc53d793408d5a80982c90d7", + "ovn-kubernetes-microshift": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:1f114ebd882e37adeeea576de1d73f64eec0696c0950f8b70434a1a2c68433ed", + "pod": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:506004700e9de44e72552ce080113563a50c00e90289cbec2ca45d8eb5580b7b", + "service-ca-operator": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:2b601e2889b25a6175c9d65c834c310262696094a9bcb5f49d6c4e2682392727" + } +} diff --git a/assets/release/release-x86_64.json b/assets/release/release-x86_64.json new file mode 100644 index 0000000000..0c9b0fb8c6 --- /dev/null +++ b/assets/release/release-x86_64.json @@ -0,0 +1,20 @@ +{ + "release": { + "base": "4.12.0-0.nightly-2022-12-15-175145" + }, + "images": { + "cli": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:9945c3f5475a37e145160d2fe6bb21948f1024a856827bc9e7d5bc882f44a750", + "coredns": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:82cfef91557f9a70cff5a90accba45841a37524e9b93f98a97b20f6b2b69e5db", + "haproxy-router": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a66f5038b4499e3c069067365c8426388d09bf3ac4dd8eb8bcbd39cd5f6c6ed0", + "kube-rbac-proxy": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:dac19e13041b0bb5d60ecaab219a43c2b4ea57a082cf13bc6305acf86254432e", + "odf-topolvm": "quay.io/rh-storage-partners/microshift-topolvm@sha256:616fe64c9f2d1315cec655d482e7b26596594e879e07017e0e610d37c72bacd0", + "openssl": "registry.access.redhat.com/ubi8/openssl@sha256:9e743d947be073808f7f1750a791a3dbd81e694e37161e8c6c6057c2c342d671", + "csi-external-provisioner": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:82983bdae16b3cadc78539f687ea39f6bb7af1ed99f3382fdbcb61500ed30398", + "csi-external-resizer": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:e2b951d8b5f88142bc1a7f5ca8529e3a6a89c8ff2dd78c9c06e8f6194e3d681f", + "csi-node-driver-registrar": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f8f85305bd4a9fc8796a05cb27676e084e80562c8af421fa99b44ef0441beff9", + "csi-livenessprobe": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:46bfcb0440620f12a91be6493039b07bf7c96d104a1a59b3e8ed3caaec2dda5c", + "ovn-kubernetes-microshift": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:10ad432ad8c4c3e6d61dfb63e1f5304e6d87c5f5be67d332c82e5364880838b7", + "pod": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:32d435c9ff716e2d7e123f9b16f17059356ce8cceb7f10a95bfa99373b844e89", + "service-ca-operator": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:20fd4b23b852db6f9f0d0134ad8d9128cb771af16723a8e239bcd97e5cd874b4" + } +} diff --git a/docs/devenv_rhel8.md b/docs/devenv_rhel8.md index 6083df777f..705f959d79 100644 --- a/docs/devenv_rhel8.md +++ b/docs/devenv_rhel8.md @@ -91,10 +91,11 @@ make srpm The artifacts of the build are located in the `_output/rpmbuild` directory. ```bash $ cd ~/microshift/ && find _output -name \*.rpm -_output/rpmbuild/RPMS/x86_64/microshift-4.12.0-2022_10_30_114426_untagged.el8.x86_64.rpm -_output/rpmbuild/RPMS/x86_64/microshift-networking-4.12.0-2022_10_30_114426_untagged.el8.x86_64.rpm -_output/rpmbuild/RPMS/noarch/microshift-selinux-4.12.0-2022_10_30_114426_untagged.el8.noarch.rpm -_output/rpmbuild/SRPMS/microshift-4.12.0-2022_10_30_114426_untagged.el8.src.rpm +_output/rpmbuild/RPMS/x86_64/microshift-4.12.0_20221215165847_758c8b61-1.el8.x86_64.rpm +_output/rpmbuild/RPMS/x86_64/microshift-networking-4.12.0_20221215165847_758c8b61-1.el8.x86_64.rpm +_output/rpmbuild/RPMS/noarch/microshift-release-info-4.12.0_20221215165847_758c8b61-1.el8.noarch.rpm +_output/rpmbuild/RPMS/noarch/microshift-selinux-4.12.0_20221215165847_758c8b61-1.el8.noarch.rpm +_output/rpmbuild/SRPMS/microshift-4.12.0_20221215165847_758c8b61-1.el8.src.rpm ``` ## Run MicroShift Executable diff --git a/docs/rhel4edge_iso.md b/docs/rhel4edge_iso.md index b3285ca83b..630330f23a 100644 --- a/docs/rhel4edge_iso.md +++ b/docs/rhel4edge_iso.md @@ -55,8 +55,7 @@ Optional arguments: Path to one or more comma-separated RPM packages to be included in the image (default: none) -embed_containers - Embed the MicroShift container dependencies in the image using the - 'pkg/release/get.sh images $(uname -i)' command to get their list + Embed the MicroShift container dependencies in the image -ostree_server_name name_or_ip Name or IP address and optionally port of the ostree server (default: 127.0.0.1:8080) @@ -153,7 +152,7 @@ Proceed by running the build script with the `-embed_containers` argument to inc When executed in this mode, the `scripts/image-builder/build.sh` script performs an extra step to append the list of the MicroShift container images to the blueprint so that they are installed when the operating system boots for the first time. The list of these images can be obtained by the following command. ```bash -~/microshift/pkg/release/get.sh images $(uname -i) +jq -r '.images | .[]' ~/microshift/assets/release/release-$(uname -i).json ``` ## Install MicroShift for Edge @@ -167,7 +166,7 @@ sudo scp microshift@microshift-dev:/home/microshift/microshift/_output/image-bui Run the following commands to create a virtual machine using the installer image. ```bash VMNAME="microshift-edge" -VERSION=$(~/microshift/pkg/release/get.sh base) +VERSION=$(grep "^var Base =" ~/microshift/pkg/release/release.go | cut -d\" -f 2) sudo -b bash -c " \ cd /var/lib/libvirt/images/ && \ virt-install \ diff --git a/packaging/rpm/microshift.spec b/packaging/rpm/microshift.spec index 2967405bed..b72c2f072d 100644 --- a/packaging/rpm/microshift.spec +++ b/packaging/rpm/microshift.spec @@ -61,7 +61,18 @@ Requires: sos %{?systemd_requires} %description -The MicroShift package provides an OpenShift Kubernetes distribution optimized for small form factor and edge computing. +The microshift package provides an OpenShift Kubernetes distribution optimized for small form factor and edge computing. + + +%package release-info +Summary: Release information for MicroShift +BuildArch: noarch + +%description release-info +The microshift-release package provides release information files for this +release. These files contain the list of container image references used by +MicroShift and can be used to embed those images into osbuilder blueprints. + %package selinux Summary: SELinux policies for MicroShift @@ -72,7 +83,8 @@ BuildArch: noarch %{?selinux_requires} %description selinux -The MicroShift SELinux package provides the SELinux policy modules required by MicroShift. +The microshift-selinux package provides the SELinux policy modules required by MicroShift. + %package networking Summary: Networking components for MicroShift @@ -82,7 +94,8 @@ Requires: NetworkManager-ovs Requires: jq %description networking -The MicroShift Networking package provides the networking components necessary for the MicroShift default CNI driver. +The microshift-networking package provides the networking components necessary for the MicroShift default CNI driver. + %prep @@ -143,6 +156,10 @@ install -p -m644 packaging/systemd/microshift.service %{buildroot}%{_unitdir}/mi install -d -m755 %{buildroot}/%{_sysconfdir}/microshift install -p -m644 packaging/microshift/config.yaml %{buildroot}%{_sysconfdir}/microshift/config.yaml.default +# release-info files +mkdir -p -m755 %{buildroot}%{_datadir}/microshift/release +install -p -m644 assets/release/release*.json %{buildroot}%{_datadir}/microshift/release + # Memory tweaks to the OpenvSwitch services mkdir -p -m755 %{buildroot}%{_sysconfdir}/systemd/system/ovs-vswitchd.service.d mkdir -p -m755 %{buildroot}%{_sysconfdir}/systemd/system/ovsdb-server.service.d @@ -212,6 +229,9 @@ systemctl enable --now --quiet openvswitch || true %{_sysconfdir}/crio/crio.conf.d/microshift.conf %config(noreplace) %{_sysconfdir}/microshift/config.yaml.default +%files release-info +%{_datadir}/microshift/release/release*.json + %files selinux /var/run/kubelet @@ -237,6 +257,9 @@ systemctl enable --now --quiet openvswitch || true # Use Git command to generate the log and replace the VERSION string # LANG=C git log --date="format:%a %b %d %Y" --pretty="tformat:* %cd %an <%ae> VERSION%n- %s%n" packaging/rpm/microshift.spec %changelog +* Wed Dec 14 2022 Frank A. Zdarsky 4.12.0 +- Add microshift-release-info subpackage + * Wed Dec 07 2022 Gregory Giguashvili 4.12.0 - Update the summaries and descriptions of MicroShift RPM packages diff --git a/pkg/release/get.sh b/pkg/release/get.sh deleted file mode 100755 index 0b386f6249..0000000000 --- a/pkg/release/get.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -function get_base { - grep "var Base" "${SCRIPT_DIR}/release.go" | cut -d\" -f 2 -} - -function add_bases { - base=$(get_base) - sed "s/:$/:${base}/g" # some lines have "xxxxx:" + Base like pause -} - -function get_image_list { - - cat $1 | grep "Image = map\[string\]string" -A 100 | grep '":' | cut -d\" -f4 | \ - add_bases -} - -function get_images { - arch=$1 - case $arch in - x86_64|amd64) get_image_list "${SCRIPT_DIR}/release_amd64.go" ;; - arm|aarch64|arm64) get_image_list "${SCRIPT_DIR}/release_arm64.go" ;; - all) - for f in ${SCRIPT_DIR}/release*.go; do - shortf=$(echo $f | sed -e 's|.*pkg/|pkg/|') - get_image_list $f | sed -e "s|^|$shortf |g" - done;; - *) get_image_list "${SCRIPT_DIR}/release.go" ;; - esac -} - -function usage { - echo "usage:" - echo " get.sh base : prints the OCP base version for this MicroShift codebase" - echo " get.sh images : prints image list used by this MicroShift codebase and architecture" - exit 1 -} - -case $1 in - base) get_base ;; - images) get_images $2 ;; - *) usage -esac diff --git a/pkg/release/release.go b/pkg/release/release.go index 552af8ff69..421f5540a7 100644 --- a/pkg/release/release.go +++ b/pkg/release/release.go @@ -16,20 +16,44 @@ limitations under the License. package release -var Base = "4.12.0-0.nightly-2022-12-15-175145" - -var Image = map[string]string{ - "cli": "quay.io/microshift/cli:" + Base, - "coredns": "quay.io/microshift/coredns:" + Base, - "haproxy_router": "quay.io/microshift/haproxy-router:" + Base, - "kube_rbac_proxy": "quay.io/microshift/kube-rbac-proxy:" + Base, - "odf_topolvm": "quay.io/microshift/odf-topolvm-rhel8" + Base, - "openssl": "quay.io/microshift/openssl" + Base, - "csi_external_provisioner": "quay.io/microshift/csi-external-provisioner" + Base, - "csi_external_resizer": "quay.io/microshift/csi-external-resizer" + Base, - "csi_node_driver_registrar": "quay.io/microshift/csi-node-driver-registrar" + Base, - "csi_livenessprobe": "quay.io/microshift/csi-livenessprobe" + Base, - "ovn_kubernetes_microshift": "quay.io/microshift/ovn-kubernetes-microshift:" + Base, - "pod": "quay.io/microshift/pause:" + Base, - "service_ca_operator": "quay.io/microshift/service-ca-operator:" + Base, +import ( + "encoding/json" + "fmt" + "runtime" + "strings" + + embedded "github.com/openshift/microshift/assets" +) + +var Base = "undefined" + +var Image = map[string]string{} + +func init() { + arch_replacer := strings.NewReplacer("amd64", "x86_64", "arm64", "aarch64") + arch := arch_replacer.Replace(runtime.GOARCH) + + release_file := "release/release-" + arch + ".json" + data, err := embedded.Asset(release_file) + if err != nil { + // If there is no release file for this architecture, work with the generic specs + return + } + + var release map[string]any + if err := json.Unmarshal(data, &release); err != nil { + panic(fmt.Errorf("unmarshaling %s: %v", release_file, err)) + } + + // Copy in the OCP base version + metadata := release["release"].(map[string]any) + Base = metadata["base"].(string) + + // Copy in the pullspecs, translating the keys as used by the OCP release image + // (with '-'s) into keys we can use in go templates (need to use '_'s instead). + images := release["images"].(map[string]any) + for name, pullspec := range images { + name := strings.Replace(name, "-", "_", -1) + Image[name] = pullspec.(string) + } } diff --git a/pkg/release/release_amd64.go b/pkg/release/release_amd64.go deleted file mode 100644 index 0b6e2a6ac5..0000000000 --- a/pkg/release/release_amd64.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright © 2021 MicroShift Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package release - -// For the amd64 architecture we use the existing and tested and -// published OCP or other component upstream images - -func init() { - Image = map[string]string{ - "cli": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:9945c3f5475a37e145160d2fe6bb21948f1024a856827bc9e7d5bc882f44a750", - "coredns": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:82cfef91557f9a70cff5a90accba45841a37524e9b93f98a97b20f6b2b69e5db", - "haproxy_router": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a66f5038b4499e3c069067365c8426388d09bf3ac4dd8eb8bcbd39cd5f6c6ed0", - "kube_rbac_proxy": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:dac19e13041b0bb5d60ecaab219a43c2b4ea57a082cf13bc6305acf86254432e", - "odf_topolvm": "quay.io/rh-storage-partners/microshift-topolvm@sha256:616fe64c9f2d1315cec655d482e7b26596594e879e07017e0e610d37c72bacd0", - "openssl": "registry.access.redhat.com/ubi8/openssl@sha256:9e743d947be073808f7f1750a791a3dbd81e694e37161e8c6c6057c2c342d671", - "csi_external_provisioner": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:82983bdae16b3cadc78539f687ea39f6bb7af1ed99f3382fdbcb61500ed30398", - "csi_external_resizer": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:e2b951d8b5f88142bc1a7f5ca8529e3a6a89c8ff2dd78c9c06e8f6194e3d681f", - "csi_node_driver_registrar": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f8f85305bd4a9fc8796a05cb27676e084e80562c8af421fa99b44ef0441beff9", - "csi_livenessprobe": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:46bfcb0440620f12a91be6493039b07bf7c96d104a1a59b3e8ed3caaec2dda5c", - "ovn_kubernetes_microshift": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:10ad432ad8c4c3e6d61dfb63e1f5304e6d87c5f5be67d332c82e5364880838b7", - "pod": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:32d435c9ff716e2d7e123f9b16f17059356ce8cceb7f10a95bfa99373b844e89", - "service_ca_operator": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:20fd4b23b852db6f9f0d0134ad8d9128cb771af16723a8e239bcd97e5cd874b4", - } -} diff --git a/pkg/release/release_arm64.go b/pkg/release/release_arm64.go deleted file mode 100644 index e5a3ee6367..0000000000 --- a/pkg/release/release_arm64.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright © 2021 MicroShift Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package release - -// For the amd64 architecture we use the existing and tested and -// published OCP or other component upstream images - -func init() { - Image = map[string]string{ - "cli": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:caa0fe9b53e4b0d2c9988fc20fa745ad80817a7cec36ba098d1812fab03e2add", - "coredns": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:cbe32c3940f369eb9093d2b6669a22ce4fd3b1c0781c2afd74f1b0b1e6bd3a9d", - "haproxy_router": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:e19d3bcfc797cd879db6043ef59c1d9e9c8c199181f5f2b6cca5e4c7cfed0a5d", - "kube_rbac_proxy": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:329566d40a19ff6914c4d584c7526c2093917a1437eb32c9f299f1c62350d035", - "odf_topolvm": "quay.io/rh-storage-partners/microshift-topolvm@sha256:616fe64c9f2d1315cec655d482e7b26596594e879e07017e0e610d37c72bacd0", - "openssl": "registry.access.redhat.com/ubi8/openssl@sha256:9e743d947be073808f7f1750a791a3dbd81e694e37161e8c6c6057c2c342d671", - "csi_external_provisioner": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:f8a246885c509a113cbd7ce43f78ea764752fad2f1bf2b61849abcaa77baacff", - "csi_external_resizer": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:b9524eb63c3408c2889ec926f2ebdf9d4ab4689c3ad50594eb8d80a9bdd0dbc9", - "csi_node_driver_registrar": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:66d99027850fac4ed6f6f9cef8f6247c08881f75648492b76a9e7f50ff9dc115", - "csi_livenessprobe": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:ea75863f09d2a45ef549e08b6c75fe2058ca142ecc53d793408d5a80982c90d7", - "ovn_kubernetes_microshift": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:1f114ebd882e37adeeea576de1d73f64eec0696c0950f8b70434a1a2c68433ed", - "pod": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:506004700e9de44e72552ce080113563a50c00e90289cbec2ca45d8eb5580b7b", - "service_ca_operator": "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:2b601e2889b25a6175c9d65c834c310262696094a9bcb5f49d6c4e2682392727", - } -} diff --git a/scripts/auto-rebase/rebase.sh b/scripts/auto-rebase/rebase.sh index 2afe50b0bf..aa6dd85357 100755 --- a/scripts/auto-rebase/rebase.sh +++ b/scripts/auto-rebase/rebase.sh @@ -36,6 +36,7 @@ EMBEDDED_COMPONENTS="route-controller-manager cluster-policy-controller hyperkub EMBEDDED_COMPONENT_OPERATORS="cluster-kube-apiserver-operator cluster-kube-controller-manager-operator cluster-openshift-controller-manager-operator cluster-kube-scheduler-operator machine-config-operator" LOADED_COMPONENTS="cluster-dns-operator cluster-ingress-operator service-ca-operator cluster-network-operator" +declare -A GOARCH_TO_UNAME_MAP=( ["amd64"]="x86_64" ["arm64"]="aarch64" ) title() { echo -e "\E[34m$1\E[00m"; @@ -355,33 +356,38 @@ update_images() { fi pushd "${STAGING_DIR}" >/dev/null - title "Rebasing release_*.go" - - # Update the base release - base_release=$(jq -r ".metadata.version" "${STAGING_DIR}/release_amd64.json") - sed -i "/^var Base/c\var Base = \"${base_release}\"" "${REPOROOT}/pkg/release/release.go" - - # Update the image digests for all architectures - images="$(get_release_images "${REPOROOT}/pkg/release/release.go" | xargs)" - for arch in amd64 arm64; do - # Compute the max length of image names incl. enclosing quotes - w=$(awk "BEGIN {n=split(\"${images}\", images, \" \"); max=0; for (i=1;i<=n;i++) {if (length(images[i]) > max) {max=length(images[i])}}; print max+2; exit}") - for i in ${images}; do - digest=$(jq -r ".references.spec.tags[] | select(.name == \"${i//_/-}\") | .from.name" release_${arch}.json) - if [[ -n "${digest}" ]]; then - echo "Updating image ${i//_/-} (${arch}) to ${digest}." - awk "!/\"${i}\"/ {print \$0} /\"${i}\"/ {printf(\"\\t\\t%-${w}s %s\n\", \"\\\"${i}\\\":\", \"\\\"${digest}\\\",\")}" \ - "${REPOROOT}/pkg/release/release_${arch}.go" > t - mv t "${REPOROOT}/pkg/release/release_${arch}.go" - if [[ "$i" == "pod" ]]; then - echo "Updating image pod (${arch}) in packaging/crio.conf.d/microshift_${arch}.conf" - sed -i "s|pause_image =.*|pause_image = \"${digest}\"|g" \ - "${REPOROOT}/packaging/crio.conf.d/microshift_${arch}.conf" - fi - else - echo "Skipping ${i//_/-} (${arch}): Not part of release image." - fi - done + title "Rebasing release_*.json" + for goarch in amd64 arm64; do + arch=${GOARCH_TO_UNAME_MAP["${goarch}"]:-noarch} + + # Update the base release + base_release=$(jq -r ".metadata.version" "${STAGING_DIR}/release_${goarch}.json") + jq --arg base "${base_release}" ' + .release.base = $base + ' "${REPOROOT}/assets/release/release-${arch}.json" > "${REPOROOT}/assets/release/release-${arch}.json.tmp" + mv "${REPOROOT}/assets/release/release-${arch}.json.tmp" "${REPOROOT}/assets/release/release-${arch}.json" + + # Get list of MicroShift's container images + images=$(jq -r '.images | keys[]' "${REPOROOT}/assets/release/release-${arch}.json" | xargs) + + # Extract the pullspecs for these images from OCP's release info + jq --arg images "$images" ' + reduce .references.spec.tags[] as $img ({}; . + {($img.name): $img.from.name}) + | with_entries(select(.key == ($images | split(" ")[]))) + ' "release_${goarch}.json" > "update_${goarch}.json" + + # Update MicroShift's release info with these pullspecs + jq --slurpfile updates "update_${goarch}.json" ' + .images += $updates[0] + ' "${REPOROOT}/assets/release/release-${arch}.json" > "${REPOROOT}/assets/release/release-${arch}.json.tmp" + mv "${REPOROOT}/assets/release/release-${arch}.json.tmp" "${REPOROOT}/assets/release/release-${arch}.json" + + # Update crio's pause image + pause_image_digest=$(jq -r ' + .references.spec.tags[] | select(.name == "pod") | .from.name + ' "release_${goarch}.json") + sed -i "s|pause_image =.*|pause_image = \"${pause_image_digest}\"|g" \ + "${REPOROOT}/packaging/crio.conf.d/microshift_${goarch}.conf" done popd >/dev/null diff --git a/scripts/image-builder/build.sh b/scripts/image-builder/build.sh index 21e96f5551..c2ae3f3b2d 100755 --- a/scripts/image-builder/build.sh +++ b/scripts/image-builder/build.sh @@ -4,7 +4,7 @@ set -e -o pipefail ROOTDIR=$(git rev-parse --show-toplevel) SCRIPTDIR=${ROOTDIR}/scripts/image-builder IMGNAME=microshift -IMAGE_VERSION=$(${ROOTDIR}/pkg/release/get.sh base) +IMAGE_VERSION=$(jq -r '.release.base' assets/release/release-$(uname -i).json) BUILD_ARCH=$(uname -i) OSTREE_SERVER_NAME=127.0.0.1:8080 LVM_SYSROOT_SIZE_MIN=10240 @@ -42,8 +42,7 @@ usage() { echo " Path to one or more comma-separated RPM packages to be" echo " included in the image (default: none)" echo " -embed_containers" - echo " Embed the MicroShift container dependencies in the image using the" - echo " 'pkg/release/get.sh images \$(uname -i)' command to get their list" + echo " Embed the MicroShift container dependencies in the image" echo " -ostree_server_name name_or_ip" echo " Name or IP address and optionally port of the ostree" echo " server (default: ${OSTREE_SERVER_NAME})" @@ -312,13 +311,9 @@ if ${EMBED_CONTAINERS} ; then sudo composer-cli sources add ${BUILDDIR}/${repo_name}.toml # Add the list of all the container images - for img in $(${ROOTDIR}/pkg/release/get.sh images $(uname -i)) ; do - cat >> blueprint_v0.0.1.toml <> blueprint_v0.0.1.toml fi # Add the firewall customization required by Prometheus diff --git a/scripts/verify_images.sh b/scripts/verify_images.sh index e5fbf08eec..8bcc01adb7 100755 --- a/scripts/verify_images.sh +++ b/scripts/verify_images.sh @@ -15,7 +15,7 @@ function debug() { ROOTDIR=$(git rev-parse --show-toplevel) approved=true -${ROOTDIR}/pkg/release/get.sh images all | while read source_file image; do +jq -r '.images | .[] | (input_filename) + " " + (.)' assets/release/release-*.json | while read source_file image; do case $image in quay.io/microshift/*) debug "$image OK";; From 8fc3c1d6a0541877c1e52083cf0bdb2245192f94 Mon Sep 17 00:00:00 2001 From: "Frank A. Zdarsky" Date: Fri, 16 Dec 2022 12:13:34 +0000 Subject: [PATCH 2/2] Add offline container doc Signed-off-by: Frank A. Zdarsky --- README.md | 1 + docs/howto_offline_containers.md | 57 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 docs/howto_offline_containers.md diff --git a/README.md b/README.md index 130bca49fc..89cd5e75a2 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ To install, configure and run MicroShift, refer to the following documentation: - [Getting Started with MicroShift](./docs/getting_started.md) - [MicroShift Configuration](./docs/howto_config.md) +- [Embeddding MicroShift's containers for offline deployments](./docs/howto_offline_containers.md) - [MicroShift Behind Proxy](./docs/howto_http_proxy.md) - [Load Balancer for User Workloads](./docs/howto_load_balancer.md) - [AMQ Broker on MicroShift](./docs/howto_amq_broker.md) diff --git a/docs/howto_offline_containers.md b/docs/howto_offline_containers.md new file mode 100644 index 0000000000..2cd936086f --- /dev/null +++ b/docs/howto_offline_containers.md @@ -0,0 +1,57 @@ +# Embedding MicroShift's container iamges for offline deployments + +Image Builder supports building `rpm-ostree` system images with embedded container images. Embedded container images are immediately available to container engines like `podman` and `cri-o` after booting the system, without having to pull images over the network from a container registry. This means container workloads can start up without delay and without requiring network connectivity. + +To embed a container image, add it to the Image Builder blueprint as follows: + +``` +[[containers]] +source = "" +``` + +To embed MicroShift's container images, you need to know the exact list of container image references used by the MicroShift version you're deploying. You can obtain this list by installing the `microshift-release-info` RPM package of the same version, for example: + +``` +$ sudo dnf install -y microshift-release-info-4.12.0-1 +$ ls /usr/share/microshift/release +release-aarch64.json release-x86_64.json +``` + +Alternatively, you can download and unpack the RPM package without installing it: + +``` +$ sudo dnf download microshift-release-info-4.12.0-1 +microshift-release-info-4.12.0-1.el8.noarch.rpm +$ rpm2cpio microshift-release-info-4.12.0-1.el8.noarch.rpm | cpio -idmv +./usr/share/microshift/release/release-aarch64.json +./usr/share/microshift/release/release-x86_64.json +``` + +Using the release info for your CPU architecture, you can now generate the section to embed the container images to your `blueprint.toml`: + +``` +$ jq -r '.images | .[] | ("[[containers]]\nsource = \"" + . + "\"\n")' release-$(uname -i).json >> blueprint.tonl +``` + +Remember to pin the version of the MicroShift RPMs in the blueprint to the version matching your container images. The resulting `blueprint.toml` should look simiar to this: + +``` +name = "microshift-offline" + +description = "" +version = "0.0.1" +modules = [] +groups = [] + +[[packages]] +name = "microshift" +version = "4.12.0-1" + +[[containers]] +source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:9945c3f5475a37e145160d2fe6bb21948f1024a856827bc9e7d5bc882f44a750" + +[[containers]] +source = "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:82cfef91557f9a70cff5a90accba45841a37524e9b93f98a97b20f6b2b69e5db" + +... +``` \ No newline at end of file