Skip to content

Commit

Permalink
Create a separate bundle for OpenShift installations
Browse files Browse the repository at this point in the history
Signed-off-by: Israel Blancas <iblancasa@gmail.com>
  • Loading branch information
iblancasa committed Jul 2, 2024
1 parent ea97b6a commit 9cdf0d2
Show file tree
Hide file tree
Showing 35 changed files with 13,286 additions and 56 deletions.
16 changes: 16 additions & 0 deletions .chloggen/3054-create-openshift-bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: bundle

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Create an specific bundle for OpenShift environments."

# One or more tracking issues related to the change
issues: [3054]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
3 changes: 2 additions & 1 deletion .ci/create-release-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ gh release create \
--notes-file ${NOTES_FILE} \
--draft \
"v${DESIRED_VERSION}" \
'dist/opentelemetry-operator.yaml#Installation manifest for Kubernetes'
'dist/opentelemetry-operator.yaml#Installation manifest for Kubernetes' \
'dist/opentelemetry-operator-openshift.yaml#Installation manifest for OpenShift'
3 changes: 1 addition & 2 deletions .github/workflows/publish-operator-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
paths:
- '.github/workflows/publish-operator-bundle.yaml'
- 'bundle.Dockerfile'
- 'bundle/**'
branches:
- main
Expand Down Expand Up @@ -70,7 +69,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ./bundle.Dockerfile
file: ./bundle/community/bundle.Dockerfile
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-operator-hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
with:
org: redhat-openshift-ecosystem
repo: community-operators-prod
folder: openshift
secrets:
OPENTELEMETRYBOT_GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}

Expand All @@ -17,5 +18,6 @@ jobs:
with:
org: k8s-operatorhub
repo: community-operators
folder: community
secrets:
OPENTELEMETRYBOT_GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/reusable-operator-hub-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
repo:
type: string
required: true
folder:
type: string
required: true
secrets:
OPENTELEMETRYBOT_GITHUB_TOKEN:
required: true
Expand Down Expand Up @@ -54,7 +57,7 @@ jobs:
VERSION: ${{ env.version }}
run: |
mkdir operators/opentelemetry-operator/${VERSION}
cp -R ./tmp/bundle/* operators/opentelemetry-operator/${VERSION}
cp -R ./tmp/bundle/${{ inputs.folder }}/* operators/opentelemetry-operator/${VERSION}
rm -rf ./tmp
- name: Use CLA approved github bot
Expand Down
109 changes: 83 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ TARGETALLOCATOR_IMG ?= ${IMG_PREFIX}/${TARGETALLOCATOR_IMG_REPO}:$(addprefix v,$
OPERATOROPAMPBRIDGE_IMG_REPO ?= operator-opamp-bridge
OPERATOROPAMPBRIDGE_IMG ?= ${IMG_PREFIX}/${OPERATOROPAMPBRIDGE_IMG_REPO}:$(addprefix v,${VERSION})

# Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
endif
ifneq ($(origin DEFAULT_CHANNEL), undefined)
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

MANIFEST_DIR ?= config/crd/bases
# kubectl apply does not work on large CRDs.
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=0"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -84,6 +71,49 @@ LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
endif

# DEFAULT_CHANNEL defines the default channel used in the bundle.
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
# To re-generate a bundle for any other default channel without changing the default setup, you can:
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
ifneq ($(origin DEFAULT_CHANNEL), undefined)
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(OPERATOR_VERSION) $(BUNDLE_METADATA_OPTS)

# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
# You can enable this value if you would like to use SHA Based Digests
# To enable set flag to true
USE_IMAGE_DIGESTS ?= false
ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif
MANIFEST_DIR ?= config/crd/bases

# kubectl apply does not work on large CRDs.
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=0"

# Choose wich version to generate
BUNDLE_VARIANT ?= community
BUNDLE_DIR = ./bundle/$(BUNDLE_VARIANT)
MANIFESTS_DIR = config/manifests/$(BUNDLE_VARIANT)
BUNDLE_BUILD_GEN_FLAGS ?= $(BUNDLE_GEN_FLAGS) --output-dir . --kustomize-dir ../../$(MANIFESTS_DIR)

MIN_KUBERNETES_VERSION ?= 1.23.0
MIN_OPENSHIFT_VERSION ?= 4.12

## On MacOS, use gsed instead of sed, to make sed behavior
## consistent with Linux.
SED ?= $(shell which gsed 2>/dev/null || which sed)
Expand All @@ -96,7 +126,6 @@ ensure-generate-is-noop: set-image-controller generate bundle
@git restore config/manager/kustomization.yaml
@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)
@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)
@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)
@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)

.PHONY: all
Expand Down Expand Up @@ -188,6 +217,7 @@ undeploy: set-image-controller
release-artifacts: set-image-controller
mkdir -p dist
$(KUSTOMIZE) build config/default -o dist/opentelemetry-operator.yaml
$(KUSTOMIZE) build config/overlays/openshift -o dist/opentelemetry-operator-openshift.yaml

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

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


# Build the container image, used only for local dev purposes
Expand Down Expand Up @@ -463,23 +494,49 @@ operator-sdk: $(LOCALBIN)
}

# Generate bundle manifests and metadata, then validate generated files.
.PHONY: bundle
bundle: kustomize operator-sdk manifests set-image-controller api-docs
$(OPERATOR_SDK) generate kustomize manifests -q
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
.PHONY: generate-bundle
generate-bundle: kustomize operator-sdk manifests set-image-controller api-docs
sed -i 's@containerImage: .*@containerImage: $(IMG)@' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
sed -i 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml

$(OPERATOR_SDK) generate kustomize manifests -q --input-dir $(MANIFESTS_DIR) --output-dir $(MANIFESTS_DIR)
cd $(BUNDLE_DIR) && cp ../../PROJECT . && $(KUSTOMIZE) build ../../$(MANIFESTS_DIR) | $(OPERATOR_SDK) generate bundle $(BUNDLE_BUILD_GEN_FLAGS) && rm PROJECT

# Workaround for https://github.com/operator-framework/operator-sdk/issues/4992
echo "" >> bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile
echo "LABEL com.redhat.openshift.versions=v$(MIN_OPENSHIFT_VERSION)" >> bundle/$(BUNDLE_VARIANT)/bundle.Dockerfile
echo "" >> bundle/$(BUNDLE_VARIANT)/metadata/annotations.yaml
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/$(BUNDLE_VARIANT)/metadata/annotations.yaml

$(OPERATOR_SDK) bundle validate $(BUNDLE_DIR)
./hack/ignore-createdAt-bundle.sh
./hack/add-openshift-annotations.sh
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: bundle
bundle:
BUNDLE_VARIANT=community VERSION=$(VERSION) $(MAKE) generate-bundle
BUNDLE_VARIANT=openshift VERSION=$(VERSION) $(MAKE) generate-bundle


.PHONY: reset
reset: kustomize operator-sdk manifests
$(MAKE) VERSION=${OPERATOR_VERSION} set-image-controller
$(OPERATOR_SDK) generate kustomize manifests -q
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version ${OPERATOR_VERSION} $(BUNDLE_METADATA_OPTS)
$(OPERATOR_SDK) bundle validate ./bundle
./hack/ignore-createdAt-bundle.sh
./hack/add-openshift-annotations.sh
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir config/manifests/community --output-dir config/manifests/community
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir config/manifests/openshift --output-dir config/manifests/openshift

$(KUSTOMIZE) build config/manifests/community | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --kustomize-dir config/manifests/community --output-dir bundle/community
$(KUSTOMIZE) build config/manifests/openshift |$(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --kustomize-dir config/manifests/openshift --output-dir bundle/openshift

# Workaround for https://github.com/operator-framework/operator-sdk/issues/4992
echo "" >> bundle/community/metadata/annotations.yaml
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/community/metadata/annotations.yaml
echo "" >> bundle/openshift/metadata/annotations.yaml
echo " com.redhat.openshift.versions: v$(MIN_OPENSHIFT_VERSION)" >> bundle/openshift/metadata/annotations.yaml

$(OPERATOR_SDK) bundle validate ./bundle/community
$(OPERATOR_SDK) bundle validate ./bundle/openshift
rm bundle.Dockerfile
git checkout config/manager/kustomization.yaml
./hack/ignore-createdAt-bundle.sh

# Build the bundle image, used only for local dev purposes
.PHONY: bundle-build
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Steps to release a new version of the OpenTelemetry Operator:
- The `autoinstrumentation-*` versions should match the latest supported versions in `autoinstrumentation/`.
> [!WARNING]
> 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.
1. Check if the compatible OpenShift versions are updated in the `hack/add-openshift-annotations.sh` script.
1. Check if the compatible OpenShift versions are updated in the `Makefile`.
1. Update the bundle by running `make bundle VERSION=$VERSION`.
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.
1. Update release schedule table, by moving the current release manager to the end of the table with updated release version.
Expand Down
9 changes: 5 additions & 4 deletions bundle.Dockerfile → bundle/community/bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/

# Copy files to locations specified by labels.
COPY bundle/manifests /manifests/
COPY bundle/metadata /metadata/
COPY bundle/tests/scorecard /tests/scorecard/
LABEL com.redhat.openshift.versions="v4.12-v4.15"
COPY ./manifests /manifests/
COPY ./metadata /metadata/
COPY ./tests/scorecard /tests/scorecard/

LABEL com.redhat.openshift.versions=v4.12
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ metadata:
capabilities: Deep Insights
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-06-25T12:03:57Z"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.103.0
createdAt: "2024-07-02T14:57:39Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ annotations:
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
operators.operatorframework.io.test.config.v1: tests/scorecard/

# OpenShift specific annotations
com.redhat.openshift.versions: "v4.12-v4.15"
com.redhat.openshift.versions: v4.12
File renamed without changes.
22 changes: 22 additions & 0 deletions bundle/openshift/bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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=opentelemetry-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.29.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/

# Copy files to locations specified by labels.
COPY ./manifests /manifests/
COPY ./metadata /metadata/
COPY ./tests/scorecard /tests/scorecard/

LABEL com.redhat.openshift.versions=v4.12
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
control-plane: controller-manager
name: opentelemetry-operator-controller-manager-metrics-service
spec:
ports:
- name: https
port: 8443
protocol: TCP
targetPort: https
selector:
app.kubernetes.io/name: opentelemetry-operator
control-plane: controller-manager
status:
loadBalancer: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
name: opentelemetry-operator-metrics-reader
rules:
- nonResourceURLs:
- /metrics
verbs:
- get
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
name: opentelemetry-operator-webhook-service
spec:
ports:
- port: 443
protocol: TCP
targetPort: 9443
selector:
app.kubernetes.io/name: opentelemetry-operator
control-plane: controller-manager
status:
loadBalancer: {}
Loading

0 comments on commit 9cdf0d2

Please sign in to comment.