Skip to content

Commit 85a2b1f

Browse files
authored
Create a separate bundle for OpenShift installations (#3056)
* Create a separate bundle for OpenShift installations Signed-off-by: Israel Blancas <[email protected]> * Retrigger tests Signed-off-by: Israel Blancas <[email protected]> * Revert Signed-off-by: Israel Blancas <[email protected]> --------- Signed-off-by: Israel Blancas <[email protected]>
1 parent d3f105b commit 85a2b1f

36 files changed

+13284
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: bundle
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: "Create an specific bundle for OpenShift environments."
9+
10+
# One or more tracking issues related to the change
11+
issues: [3054]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

.ci/create-release-github.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ gh release create \
1010
--notes-file ${NOTES_FILE} \
1111
--draft \
1212
"v${DESIRED_VERSION}" \
13-
'dist/opentelemetry-operator.yaml#Installation manifest for Kubernetes'
13+
'dist/opentelemetry-operator.yaml#Installation manifest for Kubernetes' \
14+
'dist/opentelemetry-operator-openshift.yaml#Installation manifest for OpenShift'

.github/workflows/publish-operator-bundle.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
paths:
66
- '.github/workflows/publish-operator-bundle.yaml'
7-
- 'bundle.Dockerfile'
87
- 'bundle/**'
98
branches:
109
- main
@@ -70,7 +69,7 @@ jobs:
7069
uses: docker/build-push-action@v6
7170
with:
7271
context: .
73-
file: ./bundle.Dockerfile
72+
file: ./bundle/community/bundle.Dockerfile
7473
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
7574
push: ${{ github.event_name != 'pull_request' }}
7675
tags: ${{ steps.docker_meta.outputs.tags }}

.github/workflows/publish-operator-hub.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
with:
1010
org: redhat-openshift-ecosystem
1111
repo: community-operators-prod
12+
folder: openshift
1213
secrets:
1314
OPENTELEMETRYBOT_GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
1415

@@ -17,5 +18,6 @@ jobs:
1718
with:
1819
org: k8s-operatorhub
1920
repo: community-operators
21+
folder: community
2022
secrets:
2123
OPENTELEMETRYBOT_GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}

.github/workflows/reusable-operator-hub-release.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
repo:
1010
type: string
1111
required: true
12+
folder:
13+
type: string
14+
required: true
1215
secrets:
1316
OPENTELEMETRYBOT_GITHUB_TOKEN:
1417
required: true
@@ -54,7 +57,7 @@ jobs:
5457
VERSION: ${{ env.version }}
5558
run: |
5659
mkdir operators/opentelemetry-operator/${VERSION}
57-
cp -R ./tmp/bundle/* operators/opentelemetry-operator/${VERSION}
60+
cp -R ./tmp/bundle/${{ inputs.folder }}/* operators/opentelemetry-operator/${VERSION}
5861
rm -rf ./tmp
5962
6063
- name: Use CLA approved github bot

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ When using OpenShift, the OLM is already installed.
199199

200200
### Create the bundle and related images
201201

202-
The following commands will generate a bundle under `bundle/`, build an image with its contents, build and publish the operator image.
202+
The following commands will generate two bundles (one for regular Kubernetes and another one for OpenShift) under `bundle/`, build an image with its contents, build and publish the operator image.
203203

204204
```bash
205205
BUNDLE_IMG=docker.io/${USER}/opentelemetry-operator-bundle:latest IMG=docker.io/${USER}/opentelemetry-operator:latest make bundle container container-push bundle-build bundle-push

Makefile

+83-27
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,6 @@ TARGETALLOCATOR_IMG ?= ${IMG_PREFIX}/${TARGETALLOCATOR_IMG_REPO}:$(addprefix v,$
3535
OPERATOROPAMPBRIDGE_IMG_REPO ?= operator-opamp-bridge
3636
OPERATOROPAMPBRIDGE_IMG ?= ${IMG_PREFIX}/${OPERATOROPAMPBRIDGE_IMG_REPO}:$(addprefix v,${VERSION})
3737

38-
# Options for 'bundle-build'
39-
ifneq ($(origin CHANNELS), undefined)
40-
BUNDLE_CHANNELS := --channels=$(CHANNELS)
41-
endif
42-
ifneq ($(origin DEFAULT_CHANNEL), undefined)
43-
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
44-
endif
45-
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
46-
47-
MANIFEST_DIR ?= config/crd/bases
48-
# kubectl apply does not work on large CRDs.
49-
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=0"
50-
5138
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5239
ifeq (,$(shell go env GOBIN))
5340
GOBIN=$(shell go env GOPATH)/bin
@@ -84,6 +71,49 @@ LOCALBIN ?= $(shell pwd)/bin
8471
$(LOCALBIN):
8572
mkdir -p $(LOCALBIN)
8673

74+
# CHANNELS define the bundle channels used in the bundle.
75+
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
76+
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
77+
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
78+
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
79+
ifneq ($(origin CHANNELS), undefined)
80+
BUNDLE_CHANNELS := --channels=$(CHANNELS)
81+
endif
82+
83+
# DEFAULT_CHANNEL defines the default channel used in the bundle.
84+
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
85+
# To re-generate a bundle for any other default channel without changing the default setup, you can:
86+
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
87+
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
88+
ifneq ($(origin DEFAULT_CHANNEL), undefined)
89+
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
90+
endif
91+
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
92+
93+
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
94+
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(OPERATOR_VERSION) $(BUNDLE_METADATA_OPTS)
95+
96+
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
97+
# You can enable this value if you would like to use SHA Based Digests
98+
# To enable set flag to true
99+
USE_IMAGE_DIGESTS ?= false
100+
ifeq ($(USE_IMAGE_DIGESTS), true)
101+
BUNDLE_GEN_FLAGS += --use-image-digests
102+
endif
103+
MANIFEST_DIR ?= config/crd/bases
104+
105+
# kubectl apply does not work on large CRDs.
106+
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=0"
107+
108+
# Choose wich version to generate
109+
BUNDLE_VARIANT ?= community
110+
BUNDLE_DIR = ./bundle/$(BUNDLE_VARIANT)
111+
MANIFESTS_DIR = config/manifests/$(BUNDLE_VARIANT)
112+
BUNDLE_BUILD_GEN_FLAGS ?= $(BUNDLE_GEN_FLAGS) --output-dir . --kustomize-dir ../../$(MANIFESTS_DIR)
113+
114+
MIN_KUBERNETES_VERSION ?= 1.23.0
115+
MIN_OPENSHIFT_VERSION ?= 4.12
116+
87117
## On MacOS, use gsed instead of sed, to make sed behavior
88118
## consistent with Linux.
89119
SED ?= $(shell which gsed 2>/dev/null || which sed)
@@ -96,7 +126,6 @@ ensure-generate-is-noop: set-image-controller generate bundle
96126
@git restore config/manager/kustomization.yaml
97127
@git diff -s --exit-code apis/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
98128
@git diff -s --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make bundle' and update your PR." && git diff && exit 1)
99-
@git diff -s --exit-code bundle.Dockerfile || (echo "Build failed: the bundle.Dockerfile file has been changed. The file should be the same as generated one. Run 'make bundle' and update your PR." && git diff && exit 1)
100129
@git diff -s --exit-code docs/api.md || (echo "Build failed: the api.md file has been changed but the generated api.md file isn't up to date. Run 'make api-docs' and update your PR." && git diff && exit 1)
101130

102131
.PHONY: all
@@ -188,6 +217,7 @@ undeploy: set-image-controller
188217
release-artifacts: set-image-controller
189218
mkdir -p dist
190219
$(KUSTOMIZE) build config/default -o dist/opentelemetry-operator.yaml
220+
$(KUSTOMIZE) build config/overlays/openshift -o dist/opentelemetry-operator-openshift.yaml
191221

192222
# Generate manifests e.g. CRD, RBAC etc.
193223
.PHONY: manifests
@@ -290,7 +320,8 @@ prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-o
290320

291321
.PHONY: scorecard-tests
292322
scorecard-tests: operator-sdk
293-
$(OPERATOR_SDK) scorecard -w=5m bundle || (echo "scorecard test failed" && exit 1)
323+
$(OPERATOR_SDK) scorecard -w=5m bundle/community || (echo "scorecard test for community bundle failed" && exit 1)
324+
$(OPERATOR_SDK) scorecard -w=5m bundle/openshift || (echo "scorecard test for openshift bundle failed" && exit 1)
294325

295326

296327
# Build the container image, used only for local dev purposes
@@ -463,28 +494,53 @@ operator-sdk: $(LOCALBIN)
463494
}
464495

465496
# Generate bundle manifests and metadata, then validate generated files.
466-
.PHONY: bundle
467-
bundle: kustomize operator-sdk manifests set-image-controller api-docs
468-
$(OPERATOR_SDK) generate kustomize manifests -q
469-
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
497+
.PHONY: generate-bundle
498+
generate-bundle: kustomize operator-sdk manifests set-image-controller api-docs
499+
sed -i 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
500+
501+
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir $(MANIFESTS_DIR) --output-dir $(MANIFESTS_DIR)
502+
cd $(BUNDLE_DIR) && cp ../../PROJECT . && $(KUSTOMIZE) build ../../$(MANIFESTS_DIR) | $(OPERATOR_SDK) generate bundle $(BUNDLE_BUILD_GEN_FLAGS) && rm PROJECT
503+
504+
# Workaround for https://github.com/operator-framework/operator-sdk/issues/4992
505+
echo "" >> bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile
506+
echo "LABEL com.redhat.openshift.versions=v$(MIN_OPENSHIFT_VERSION)" >> bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile
507+
echo "" >> bundle/$(BUNDLE_VARIANT)/metadata/annotations.yaml
508+
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/$(BUNDLE_VARIANT)/metadata/annotations.yaml
509+
510+
$(OPERATOR_SDK) bundle validate $(BUNDLE_DIR)
470511
./hack/ignore-createdAt-bundle.sh
471-
./hack/add-openshift-annotations.sh
472-
$(OPERATOR_SDK) bundle validate ./bundle
512+
513+
.PHONY: bundle
514+
bundle:
515+
BUNDLE_VARIANT=community VERSION=$(VERSION) $(MAKE) generate-bundle
516+
BUNDLE_VARIANT=openshift VERSION=$(VERSION) $(MAKE) generate-bundle
517+
473518

474519
.PHONY: reset
475520
reset: kustomize operator-sdk manifests
476521
$(MAKE) VERSION=${OPERATOR_VERSION} set-image-controller
477-
$(OPERATOR_SDK) generate kustomize manifests -q
478-
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version ${OPERATOR_VERSION} $(BUNDLE_METADATA_OPTS)
479-
$(OPERATOR_SDK) bundle validate ./bundle
480-
./hack/ignore-createdAt-bundle.sh
481-
./hack/add-openshift-annotations.sh
522+
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir config/manifests/community --output-dir config/manifests/community
523+
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir config/manifests/openshift --output-dir config/manifests/openshift
524+
525+
$(KUSTOMIZE) build config/manifests/community | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --kustomize-dir config/manifests/community --output-dir bundle/community
526+
$(KUSTOMIZE) build config/manifests/openshift |$(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --kustomize-dir config/manifests/openshift --output-dir bundle/openshift
527+
528+
# Workaround for https://github.com/operator-framework/operator-sdk/issues/4992
529+
echo "" >> bundle/community/metadata/annotations.yaml
530+
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/community/metadata/annotations.yaml
531+
echo "" >> bundle/openshift/metadata/annotations.yaml
532+
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/openshift/metadata/annotations.yaml
533+
534+
$(OPERATOR_SDK) bundle validate ./bundle/community
535+
$(OPERATOR_SDK) bundle validate ./bundle/openshift
536+
rm bundle.Dockerfile
482537
git checkout config/manager/kustomization.yaml
538+
./hack/ignore-createdAt-bundle.sh
483539

484540
# Build the bundle image, used only for local dev purposes
485541
.PHONY: bundle-build
486542
bundle-build:
487-
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
543+
docker build -f ./bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile -t $(BUNDLE_IMG) ./bundle/$(BUNDLE_VARIANT)
488544

489545
.PHONY: bundle-push
490546
bundle-push:

RELEASE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Steps to release a new version of the OpenTelemetry Operator:
1010
- The `autoinstrumentation-*` versions should match the latest supported versions in `autoinstrumentation/`.
1111
> [!WARNING]
1212
> DO NOT BUMP JAVA PAST `1.32.X` AND DO NOT BUMP .NET PAST `1.2.0`. Upgrades past these versions will introduce breaking HTTP semantic convention changes.
13-
1. Check if the compatible OpenShift versions are updated in the `hack/add-openshift-annotations.sh` script.
13+
1. Check if the compatible OpenShift versions are updated in the `Makefile`.
1414
1. Update the bundle by running `make bundle VERSION=$VERSION`.
1515
1. Change the compatibility matrix in the [readme](./README.md) file, using the OpenTelemetry Operator version to be released and the current latest Kubernetes version as the latest supported version. Remove the oldest entry.
1616
1. Update release schedule table, by moving the current release manager to the end of the table with updated release version.

bundle.Dockerfile bundle/community/bundle.Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
1515
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
1616

1717
# Copy files to locations specified by labels.
18-
COPY bundle/manifests /manifests/
19-
COPY bundle/metadata /metadata/
20-
COPY bundle/tests/scorecard /tests/scorecard/
21-
LABEL com.redhat.openshift.versions="v4.12-v4.15"
18+
COPY ./manifests /manifests/
19+
COPY ./metadata /metadata/
20+
COPY ./tests/scorecard /tests/scorecard/
21+
22+
LABEL com.redhat.openshift.versions=v4.12

bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ metadata:
9999
categories: Logging & Tracing,Monitoring
100100
certified: "false"
101101
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
102-
createdAt: "2024-07-10T09:05:22Z"
102+
createdAt: "2024-07-18T14:09:46Z"
103103
description: Provides the OpenTelemetry components, including the Collector
104104
operators.operatorframework.io/builder: operator-sdk-v1.29.0
105105
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

bundle/metadata/annotations.yaml bundle/community/metadata/annotations.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ annotations:
1313
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
1414
operators.operatorframework.io.test.config.v1: tests/scorecard/
1515

16-
# OpenShift specific annotations
17-
com.redhat.openshift.versions: "v4.12-v4.15"
16+
com.redhat.openshift.versions: v4.12

bundle/openshift/bundle.Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM scratch
2+
3+
# Core bundle labels.
4+
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
5+
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
6+
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
7+
LABEL operators.operatorframework.io.bundle.package.v1=opentelemetry-operator
8+
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.29.0
10+
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
11+
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
12+
13+
# Labels for testing.
14+
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
15+
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
16+
17+
# Copy files to locations specified by labels.
18+
COPY ./manifests /manifests/
19+
COPY ./metadata /metadata/
20+
COPY ./tests/scorecard /tests/scorecard/
21+
22+
LABEL com.redhat.openshift.versions=v4.12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
app.kubernetes.io/name: opentelemetry-operator
7+
control-plane: controller-manager
8+
name: opentelemetry-operator-controller-manager-metrics-service
9+
spec:
10+
ports:
11+
- name: https
12+
port: 8443
13+
protocol: TCP
14+
targetPort: https
15+
selector:
16+
app.kubernetes.io/name: opentelemetry-operator
17+
control-plane: controller-manager
18+
status:
19+
loadBalancer: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
app.kubernetes.io/name: opentelemetry-operator
7+
name: opentelemetry-operator-metrics-reader
8+
rules:
9+
- nonResourceURLs:
10+
- /metrics
11+
verbs:
12+
- get
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
app.kubernetes.io/name: opentelemetry-operator
7+
name: opentelemetry-operator-webhook-service
8+
spec:
9+
ports:
10+
- port: 443
11+
protocol: TCP
12+
targetPort: 9443
13+
selector:
14+
app.kubernetes.io/name: opentelemetry-operator
15+
control-plane: controller-manager
16+
status:
17+
loadBalancer: {}

0 commit comments

Comments
 (0)