Skip to content

Commit

Permalink
Nightly build improvements (#3156)
Browse files Browse the repository at this point in the history
1. add nightly CDI to HCO nightly build (in addtion to the already
   exists nightly KubeVirt).

2. Move to FBC

3. Also create and publish nightly index-image

4. Try to deploy the bundle image on a K8s cluster, before publishing
   the images.

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
  • Loading branch information
nunnatsa authored Nov 10, 2024
1 parent 75527d0 commit 3b32268
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
66 changes: 59 additions & 7 deletions automation/nightly/test-nightly-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,34 @@ wget -q https://dl.google.com/go/go1.22.6.linux-amd64.tar.gz
tar -C /usr/local -xf go*.tar.gz
export PATH=/usr/local/go/bin:$PATH

# get latest commits
# get latest KubeVirt commits
latest_kubevirt=$(curl -sL https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/kubevirt/latest)
latest_kubevirt_image=$(curl -sL "https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/kubevirt/${latest_kubevirt}/kubevirt-operator.yaml" | grep 'OPERATOR_IMAGE' -A1 | tail -n 1 | sed 's/.*value: //g')
IFS=: read -r kv_image kv_tag <<< "${latest_kubevirt_image}"
latest_kubevirt_commit=$(curl -sL "https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/kubevirt/${latest_kubevirt}/commit")

# get latest CDI commits
latest_cdi=$(curl -sL https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/containerized-data-importer/latest)
latest_cdi_image=$(curl -sL "https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/containerized-data-importer/${latest_cdi}/cdi-operator.yaml" | grep "image:" | sed -E "s|^ +image: (.*)$|\1|")
IFS=: read -r cdi_image cdi_tag <<< "${latest_cdi_image}"
latest_cdi_commit=$(curl -sL "https://storage.googleapis.com/kubevirt-prow/devel/nightly/release/kubevirt/containerized-data-importer/${latest_cdi}/commit")

# Update HCO dependencies
go mod edit -require "kubevirt.io/kubevirt@${latest_kubevirt_commit}"
go mod tidy
go mod vendor
rm -rf kubevirt
rm -rf kubevirt cdi

# Get latest kubevirt
git clone https://github.com/kubevirt/kubevirt.git
(cd kubevirt; git checkout "${latest_kubevirt_commit}")
go mod edit -replace kubevirt.io/client-go=./kubevirt/staging/src/kubevirt.io/client-go

# Get latest CDI
git clone https://github.com/kubevirt/containerized-data-importer.git cdi
(cd cdi; git checkout "${latest_cdi_commit}")

go mod edit -replace kubevirt.io/api=./kubevirt/staging/src/kubevirt.io/api
go mod edit -replace kubevirt.io/containerized-data-importer-api=$(grep "kubevirt.io/containerized-data-importer-api v" go.mod | xargs | sed "s/ /@/g")
go mod edit -replace kubevirt.io/containerized-data-importer-api=./cdi/staging/src/kubevirt.io/containerized-data-importer-api

go mod tidy
go mod vendor

Expand All @@ -47,6 +57,7 @@ OPERATOR_IMAGE=${TEMP_OPERATOR_IMAGE} WEBHOOK_IMAGE=${TEMP_WEBHOOK_IMAGE} make c
# Update image digests
sed -i "s#quay.io/kubevirt/virt-#${kv_image/-*/-}#" deploy/images.csv
sed -i "s#^KUBEVIRT_VERSION=.*#KUBEVIRT_VERSION=\"${kv_tag}\"#" hack/config
sed -i "s#^CDI_VERSION=.*#CDI_VERSION=\"${cdi_tag}\"#" hack/config
(cd ./tools/digester && go build .)
export HCO_VERSION="${IMAGE_TAG}"
./automation/digester/update_images.sh
Expand All @@ -57,9 +68,50 @@ HCO_WEBHOOK_IMAGE_DIGEST=$(tools/digester/digester --image ${CSV_WEBHOOK_IMAGE}:
# Build the CSV
HCO_OPERATOR_IMAGE=${HCO_OPERATOR_IMAGE_DIGEST} HCO_WEBHOOK_IMAGE=${HCO_WEBHOOK_IMAGE_DIGEST} ./hack/build-manifests.sh

REGISTRY_NAMESPACE=${IMAGE_PREFIX} CONTAINER_TAG=${IMAGE_TAG} make bundleRegistry
# Download OPM
OPM_VERSION=v1.47.0
wget https://github.com/operator-framework/operator-registry/releases/download/${OPM_VERSION}/linux-amd64-opm -O opm
chmod +x opm
export OPM=$(pwd)/opm

# create and push bundle image and index image
REGISTRY_NAMESPACE=${IMAGE_PREFIX} IMAGE_TAG=${IMAGE_TAG} ./hack/build-index-image.sh latest UNSTABLE

BUNDLE_REGISTRY_IMAGE_NAME=${BUNDLE_REGISTRY_IMAGE_NAME:-hyperconverged-cluster-bundle}
INDEX_REGISTRY_IMAGE_NAME=${INDEX_REGISTRY_IMAGE_NAME:-hyperconverged-cluster-index}
BUNDLE_IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_PREFIX}/${BUNDLE_REGISTRY_IMAGE_NAME}:${IMAGE_TAG}"
INDEX_IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_PREFIX}/${INDEX_REGISTRY_IMAGE_NAME}:${IMAGE_TAG}"

# download operator-sdk
sdk_url=$(curl https://api.github.com/repos/operator-framework/operator-sdk/releases/latest | jq -rM '.assets[] | select(.name == "operator-sdk_linux_amd64") | .browser_download_url')
wget $sdk_url -O operator-sdk
chmod +x operator-sdk

# start K8s cluster
export KUBEVIRT_PROVIDER=k8s-1.31
make cluster-up
export KUBECONFIG=$(_kubevirtci/cluster-up/kubeconfig.sh)

export KUBEVIRTCI_TAG=$(curl -L -Ss https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirtci/latest)
export KUBECTL=$(pwd)/cluster-up/kubectl.sh

# install OLM on the cluster
# latest OLM, v0.29.0 is broken. Forcing a working OLM version
# TODO: drop the --version command line parameter when https://github.com/operator-framework/operator-lifecycle-manager/issues/3419 is resolved.
./operator-sdk olm install --version=v0.28.0

# install HCO on the cluster
$KUBECTL create ns kubevirt-hyperconverged
./operator-sdk run bundle -n kubevirt-hyperconverged --timeout=10m ${BUNDLE_IMAGE_NAME}

# deploy the HyperConverged CR
$KUBECTL apply -n kubevirt-hyperconverged deploy/hco.cr.yaml
$KUBECTL wait -n kubevirt-hyperconverged hco kubevirt-hyperconverged --for=condition=Available --timeout=5m

hco_bucket="kubevirt-prow/devel/nightly/release/kubevirt/hyperconverged-cluster-operator"
echo "${build_date}" > build-date
echo "${IMAGE_REGISTRY}/${IMAGE_PREFIX}/hco-container-registry:${IMAGE_TAG}" > hco-bundle
echo "${BUNDLE_IMAGE_NAME}" > hco-bundle
echo "${INDEX_IMAGE_NAME}" > hco-index
gsutil cp ./hco-bundle "gs://${hco_bucket}/${build_date}/hco-bundle-image"
gsutil cp ./hco-index "gs://${hco_bucket}/${build_date}/hco-index-image"
gsutil cp ./build-date gs://${hco_bucket}/latest
9 changes: 7 additions & 2 deletions hack/build-index-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ function create_index_image() {
mv ${PACKAGE_NAME}/${CURRENT_VERSION} ${PACKAGE_NAME}/${CURRENT_VERSION}-unstable
CURRENT_VERSION=${CURRENT_VERSION}-unstable
fi
BUNDLE_IMAGE_NAME="${IMAGE_REGISTRY}/${REGISTRY_NAMESPACE}/${BUNDLE_REGISTRY_IMAGE_NAME}:${CURRENT_VERSION}"
INDEX_IMAGE_NAME="${IMAGE_REGISTRY}/${REGISTRY_NAMESPACE}/${INDEX_REGISTRY_IMAGE_NAME}:${CURRENT_VERSION}"

if [[ -z ${IMAGE_TAG} ]]; then
IMAGE_TAG=${CURRENT_VERSION}
fi

BUNDLE_IMAGE_NAME="${IMAGE_REGISTRY}/${REGISTRY_NAMESPACE}/${BUNDLE_REGISTRY_IMAGE_NAME}:${IMAGE_TAG}"
INDEX_IMAGE_NAME="${IMAGE_REGISTRY}/${REGISTRY_NAMESPACE}/${INDEX_REGISTRY_IMAGE_NAME}:${IMAGE_TAG}"

podman build -t "${BUNDLE_IMAGE_NAME}" -f bundle.Dockerfile --build-arg "VERSION=${CURRENT_VERSION}" .
podman push "${BUNDLE_IMAGE_NAME}"
Expand Down

0 comments on commit 3b32268

Please sign in to comment.