Skip to content

Commit

Permalink
Merge pull request #27 from ThinkParQ/iamjoemccormick/add-openshift-v…
Browse files Browse the repository at this point in the history
…ersion

Add version annotation for OpenShift
  • Loading branch information
iamjoemccormick authored Mar 6, 2024
2 parents e442ca0 + afecff0 commit 8792f2a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ bundle: manifests kustomize ## Generate bundle manifests and metadata, then vali
operator-sdk generate kustomize manifests --interactive=false -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)
# OpenShift started requiring bundles to specify what versions of OpenShift are supported and
# the fact we did not specify this was caught when submitting the bundle for v1.6.0. Since
# v1.5.0 we don't officially test or support OpenShift anymore, but we still publish bundles as
# a convenience for anyone using OpenShift that wants to run the operator "at their own risk"
# because there is no technical reason it shouldn't work. Here we just require a minimum of
# v4.11 as that was the last version of OpenShift tested with the driver.
# https://redhat-connect.gitbook.io/certified-operator-guide/ocp-deployment/operator-metadata/bundle-directory/managing-openshift-versions
# https://connect.redhat.com/en/blog/updating-your-operators-openshift-when-kubernetes-changes-apis
#
# Further complicating matters, our bundle is generated by operator-sdk so we cannot simply
# modify bundle/metadata/annotations.yaml and bundle.Dockerfile as they will be overwritten.
# Thus far I have not found any documentation on the "correct" way to tell operator-sdk to add
# this. Searching GitHub for how other have solved this shows projects either appear to not be
# maintaining bundles using operator-sdk, or are using some varient of a hack script to set the
# versions after generating the bundle. Our solution is "inspired" by:
# https://github.com/open-telemetry/opentelemetry-operator/pull/2562/files.
./hack/set_openshift_min_version.sh
operator-sdk bundle validate ./bundle --select-optional suite=operatorframework

.PHONY: bundle-build
Expand Down
3 changes: 3 additions & 0 deletions operator/bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
COPY bundle/manifests /manifests/
COPY bundle/metadata /metadata/
COPY bundle/tests/scorecard /tests/scorecard/

# Set minimum OpenShift version
LABEL com.redhat.openshift.versions="v4.11"
3 changes: 3 additions & 0 deletions operator/bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ annotations:
# Annotations for testing.
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
operators.operatorframework.io.test.config.v1: tests/scorecard/

# Set minimum OpenShift version
com.redhat.openshift.versions: "v4.11"
12 changes: 12 additions & 0 deletions operator/hack/set_openshift_min_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

OPENSHIFT_VERSIONS="\"v4.11\""

{
echo ""
echo " # Set minimum OpenShift version"
echo " com.redhat.openshift.versions: $OPENSHIFT_VERSIONS"
} >> bundle/metadata/annotations.yaml

echo "\n# Set minimum OpenShift version" >> bundle.Dockerfile
echo "LABEL com.redhat.openshift.versions=$OPENSHIFT_VERSIONS" >> bundle.Dockerfile

0 comments on commit 8792f2a

Please sign in to comment.