Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new rook bundle creation script #584

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile.bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM scratch

# Core bundle labels.
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=rook-ceph-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha

# Copy files to locations specified by labels.
COPY build/csv/ceph /manifests/
COPY build/bundle/annotations.yaml /metadata/
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ gen-csv: export NO_OB_OBC_VOL_GEN=true
gen-csv: csv-clean crds ## Generate a CSV file for OLM.
$(MAKE) -C images/ceph csv

bundle:
@echo generate rook bundle
@build/bundle/gen-bundle.sh

csv-clean: ## Remove existing OLM files.
@$(MAKE) -C images/ceph csv-clean

Expand Down
6 changes: 6 additions & 0 deletions build/bundle/annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
annotations:
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
operators.operatorframework.io.bundle.manifests.v1: manifests/
operators.operatorframework.io.bundle.metadata.v1: metadata/
operators.operatorframework.io.bundle.package.v1: rook-ceph-operator
operators.operatorframework.io.bundle.channels.v1: alpha
21 changes: 21 additions & 0 deletions build/bundle/gen-bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e

source "build/common.sh"

# Use the available container management tool
if [ -z "$DOCKERCMD" ]; then
DOCKERCMD=$(command -v docker || echo "")
fi
if [ -z "$DOCKERCMD" ]; then
DOCKERCMD=$(command -v podman || echo "")
fi

if [ -z "$DOCKERCMD" ]; then
echo -e '\033[1;31m' "podman or docker not found on system" '\033[0m'
exit 1
fi

${DOCKERCMD} build --platform="${GOOS}"/"${GOARCH}" --no-cache -t "$BUNDLE_IMAGE" -f Dockerfile.bundle .
echo
echo "Run '${DOCKERCMD} push ${BUNDLE_IMAGE}' to push operator bundle to image registry."
9 changes: 9 additions & 0 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export OUTPUT_DIR=${BUILD_ROOT}/_output
export WORK_DIR=${BUILD_ROOT}/.work
export CACHE_DIR=${BUILD_ROOT}/.cache
export GOOS
GOOS=$(go env GOOS)
export GOARCH
GOARCH=$(go env GOARCH)
DEFAULT_CSV_VERSION="4.15.0"
CSV_VERSION="${CSV_VERSION:-${DEFAULT_CSV_VERSION}}"
export ROOK_IMAGE="docker.io/rook/ceph:v1.13.0.399.g9c0d795e2"
DEFAULT_BUNDLE_IMAGE=rook/rook-ceph-operator-bundle:"${VERSION}"
BUNDLE_IMAGE="${BUNDLE_IMAGE:-${DEFAULT_BUNDLE_IMAGE}}"

function ver() {
local full_ver maj min bug build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ metadata:
operators.operatorframework.io/project_layout: unknown
tectonic-visibility: ocs
repository: https://github.com/red-hat-storage/rook
containerImage: '{{.RookOperatorImage}}'
containerImage: docker.io/rook/ceph:v1.13.0.399.g9c0d795e2
externalClusterScript: |-
IiIiCkNvcHlyaWdodCAyMDIwIFRoZSBSb29rIEF1dGhvcnMuIEFsbCByaWdodHMgcmVzZXJ2ZWQu
CgpMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxp
Expand Down Expand Up @@ -1860,7 +1860,7 @@ metadata:
OgogICAgICAgIHByaW50KGYiS2V5RXJyb3I6IHtrRXJyfSIpCiAgICBleGNlcHQgT1NFcnJvciBh
cyBvc0VycjoKICAgICAgICBwcmludChmIkVycm9yIHdoaWxlIHRyeWluZyB0byBvdXRwdXQgdGhl
IGRhdGE6IHtvc0Vycn0iKQogICAgZmluYWxseToKICAgICAgICByak9iai5zaHV0ZG93bigpCg==
name: rook-ceph.v{{.RookOperatorCsvVersion}}
name: rook-ceph-operator.v4.15.0
namespace: placeholder
relatedImages:
- image: docker.io/rook/ceph:master
Expand Down Expand Up @@ -3034,7 +3034,7 @@ spec:
fieldPath: metadata.namespace
- name: ROOK_OBC_WATCH_OPERATOR_NAMESPACE
value: "true"
image: {{.RookOperatorImage}}
image: docker.io/rook/ceph:v1.13.0.399.g9c0d795e2
name: rook-ceph-operator
resources: {}
securityContext:
Expand Down Expand Up @@ -3374,5 +3374,5 @@ spec:
provider:
name: Provider Name
url: https://your.domain
version: {{.RookOperatorCsvVersion}}
version: 4.15.0
minKubeVersion: 1.16.0
16 changes: 9 additions & 7 deletions build/csv/csv-gen.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -e

source "../../build/common.sh"

#############
# VARIABLES #
#############
Expand All @@ -13,7 +15,7 @@ YQ_CMD_DELETE=("$yq" delete -i)
YQ_CMD_MERGE_OVERWRITE=("$yq" merge --inplace --overwrite --prettyPrint)
YQ_CMD_MERGE=("$yq" merge --arrays=append --inplace)
YQ_CMD_WRITE=("$yq" write --inplace -P)
CSV_FILE_NAME="../../build/csv/ceph/$PLATFORM/manifests/rook-ceph.clusterserviceversion.yaml"
CSV_FILE_NAME="../../build/csv/ceph/$PLATFORM/manifests/rook-ceph-operator.clusterserviceversion.yaml"
CEPH_EXTERNAL_SCRIPT_FILE="../../deploy/examples/create-external-cluster-resources.py"
ASSEMBLE_FILE_COMMON="../../deploy/olm/assemble/metadata-common.yaml"
ASSEMBLE_FILE_OCP="../../deploy/olm/assemble/metadata-ocp.yaml"
Expand All @@ -23,7 +25,7 @@ ASSEMBLE_FILE_OCP="../../deploy/olm/assemble/metadata-ocp.yaml"
#############

function generate_csv() {
kubectl kustomize ../../deploy/examples/ | "$operator_sdk" generate bundle --package="rook-ceph" --output-dir="../../build/csv/ceph/$PLATFORM" --extra-service-accounts=rook-ceph-default,rook-csi-rbd-provisioner-sa,rook-csi-rbd-plugin-sa,rook-csi-cephfs-provisioner-sa,rook-csi-nfs-provisioner-sa,rook-csi-nfs-plugin-sa,rook-csi-cephfs-plugin-sa,rook-ceph-system,rook-ceph-rgw,rook-ceph-purge-osd,rook-ceph-osd,rook-ceph-mgr,rook-ceph-cmd-reporter
kubectl kustomize ../../deploy/examples/ | "$operator_sdk" generate bundle --package="rook-ceph-operator" --output-dir="../../build/csv/ceph/$PLATFORM" --extra-service-accounts=rook-ceph-default,rook-csi-rbd-provisioner-sa,rook-csi-rbd-plugin-sa,rook-csi-cephfs-provisioner-sa,rook-csi-nfs-provisioner-sa,rook-csi-nfs-plugin-sa,rook-csi-cephfs-plugin-sa,rook-ceph-system,rook-ceph-rgw,rook-ceph-purge-osd,rook-ceph-osd,rook-ceph-mgr,rook-ceph-cmd-reporter

# cleanup to get the expected state before merging the real data from assembles
"${YQ_CMD_DELETE[@]}" "$CSV_FILE_NAME" 'spec.icon[*]'
Expand All @@ -33,7 +35,7 @@ function generate_csv() {

"${YQ_CMD_MERGE_OVERWRITE[@]}" "$CSV_FILE_NAME" "$ASSEMBLE_FILE_COMMON"
"${YQ_CMD_WRITE[@]}" "$CSV_FILE_NAME" metadata.annotations.externalClusterScript "$(base64 <$CEPH_EXTERNAL_SCRIPT_FILE)"
"${YQ_CMD_WRITE[@]}" "$CSV_FILE_NAME" metadata.name "rook-ceph.v${VERSION}"
"${YQ_CMD_WRITE[@]}" "$CSV_FILE_NAME" metadata.name "rook-ceph-operator.v${CSV_VERSION}"

"${YQ_CMD_MERGE[@]}" "$CSV_FILE_NAME" "$ASSEMBLE_FILE_OCP"

Expand All @@ -47,11 +49,11 @@ function generate_csv() {
return
fi

sed -i 's/image: rook\/ceph:.*/image: {{.RookOperatorImage}}/g' "$CSV_FILE_NAME"
sed -i 's/name: rook-ceph.v.*/name: rook-ceph.v{{.RookOperatorCsvVersion}}/g' "$CSV_FILE_NAME"
sed -i 's/version: 0.0.0/version: {{.RookOperatorCsvVersion}}/g' "$CSV_FILE_NAME"
sed -i "s|containerImage: rook/ceph:.*|containerImage: $ROOK_IMAGE|" "$CSV_FILE_NAME"
sed -i "s|image: rook/ceph:.*|image: $ROOK_IMAGE|" "$CSV_FILE_NAME"
sed -i "s/name: rook-ceph.v.*/name: rook-ceph-operator.v$CSV_VERSION/g" "$CSV_FILE_NAME"
sed -i "s/version: 0.0.0/version: $CSV_VERSION/g" "$CSV_FILE_NAME"

mv "$CSV_FILE_NAME" "../../build/csv/"
mv "../../build/csv/ceph/$PLATFORM/manifests/"* "../../build/csv/ceph/"
rm -rf "../../build/csv/ceph/$PLATFORM"
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/olm/assemble/metadata-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ metadata:
annotations:
tectonic-visibility: ocs
repository: https://github.com/red-hat-storage/rook
containerImage: "{{.RookOperatorImage}}"
containerImage: rook/ceph:master
alm-examples: |-
[
{
Expand Down
Loading