Skip to content

Commit 3039640

Browse files
authored
Update operator-sdk to 1.2.0 (#154)
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
1 parent 0a17301 commit 3039640

16 files changed

+1664
-66
lines changed

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- uses: jpkrohling/[email protected]
2020
with:
21-
operator-sdk-version: v0.19.0
21+
operator-sdk-version: v1.2.0
2222

2323
- name: "generate release resources"
2424
run: make release-artifacts IMG_PREFIX="quay.io/opentelemetry"

.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ bin
1717
# Kubernetes Generated files - skip generated files, except for vendored files
1818
!vendor/**/zz_generated.*
1919

20-
# Operator SDK generated files
21-
bundle
22-
bundle.Dockerfile
23-
bundle.tar.gz
24-
2520
# Release artifacts
2621
dist
22+
bundle.tar.gz
2723

2824
# editor and IDE paraphernalia
2925
.idea

CONTRIBUTING.md

+63
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,66 @@ Every bug fix should be accompanied with a unit test, so that we can prevent reg
8888
### Documentation, typos, ...
8989

9090
They are mostly welcome!
91+
92+
## Operator Lifecycle Manager (OLM)
93+
94+
For production environments, it is recommended to use the [Operator Lifecycle Manager (OLM)](https://github.com/operator-framework/operator-lifecycle-manager) to provision and update the OpenTelemetry Operator. Our operator is available in the [Operator Hub](https://operatorhub.io/operator/opentelemetry-operator), and when making changes involving those manifests the following steps can be used for testing. Refer to the [OLM documentation](https://sdk.operatorframework.io/docs/olm-integration/quickstart-bundle/) for more complete information.
95+
96+
### Setup OLM
97+
98+
When using Kubernetes, install OLM following the [official instructions](https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/install/install.md). At the moment of this writing, it involves the following:
99+
100+
```
101+
kubectl create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/crds.yaml
102+
kubectl create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/upstream/quickstart/olm.yaml
103+
kubectl wait --for=condition=available deployment packageserver -n olm
104+
kubectl wait --for=condition=available deployment olm-operator -n olm
105+
kubectl wait --for=condition=available deployment catalog-operator -n olm
106+
```
107+
108+
When using OpenShift, OLM is already installed.
109+
110+
### Create the bundle and related images
111+
112+
The following commands will generate a bundle under `bundle/` and build an image with its contents. It will then generate and publish an index image with the [Operator Package Manager (OPM)](https://github.com/operator-framework/operator-registry/blob/master/docs/design/opm-tooling.md#opm)
113+
114+
```
115+
export VERSION=x.y.z
116+
make set-image-controller bundle bundle-build
117+
podman push quay.io/${USER}/opentelemetry-operator-bundle:${VERSION}
118+
opm index add --bundles quay.io/${USER}/opentelemetry-operator-bundle:${VERSION} --tag quay.io/${USER}/opentelemetry-operator-index:${VERSION}
119+
podman push quay.io/${USER}/opentelemetry-operator-index:${VERSION}
120+
```
121+
122+
### Install the operator
123+
124+
To install our operator, create a `CatalogSource` for our index image, wait for OLM to synchronize and finally create a `Subscription`. Make sure to replace `${USER}` with your username and `${VERSION}` with the version used in the previous step. The namespace for both should be `operators` on Kubernetes, while `openshift-operators` should be used for OpenShift.
125+
126+
```
127+
kubectl apply -f - <<EOF
128+
apiVersion: operators.coreos.com/v1alpha1
129+
kind: CatalogSource
130+
metadata:
131+
name: opentelemetry-operator-manifests
132+
namespace: operators
133+
spec:
134+
sourceType: grpc
135+
image: quay.io/${USER}/opentelemetry-operator-index:${VERSION}
136+
EOF
137+
kubectl wait --for=condition=ready pod -l olm.catalogSource=opentelemetry-operator-manifests -n operators
138+
139+
kubectl apply -f - <<EOF
140+
apiVersion: operators.coreos.com/v1alpha1
141+
kind: Subscription
142+
metadata:
143+
name: opentelemetry-operator-subscription
144+
namespace: operators
145+
spec:
146+
channel: "alpha"
147+
installPlanApproval: Automatic
148+
name: opentelemetry-operator
149+
source: opentelemetry-operator-manifests
150+
sourceNamespace: operators
151+
EOF
152+
kubectl wait --for=condition=available deployment opentelemetry-operator-controller-manager -n operators
153+
```

Makefile

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ VERSION_PKG ?= "github.com/open-telemetry/opentelemetry-operator/internal/versio
55
OTELCOL_VERSION ?= "$(shell grep -v '\#' versions.txt | grep opentelemetry-collector | awk -F= '{print $$2}')"
66
LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION}"
77

8-
# Default bundle image tag
9-
BUNDLE_IMG ?= controller-bundle:$(VERSION)
8+
# Image URL to use all building/pushing image targets
9+
IMG_PREFIX ?= quay.io/${USER}
10+
IMG_REPO ?= opentelemetry-operator
11+
IMG ?= ${IMG_PREFIX}/${IMG_REPO}:${VERSION}
12+
BUNDLE_IMG ?= ${IMG_PREFIX}/${IMG_REPO}-bundle:${VERSION}
13+
1014
# Options for 'bundle-build'
1115
ifneq ($(origin CHANNELS), undefined)
1216
BUNDLE_CHANNELS := --channels=$(CHANNELS)
@@ -16,11 +20,6 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
1620
endif
1721
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
1822

19-
# Image URL to use all building/pushing image targets
20-
IMG_PREFIX ?= quay.io/${USER}
21-
IMG_REPO ?= opentelemetry-operator
22-
IMG ?= ${IMG_PREFIX}/${IMG_REPO}:${VERSION}
23-
2423
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
2524
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
2625

@@ -154,9 +153,9 @@ OPERATOR_SDK=$(shell which operator-sdk)
154153
endif
155154

156155
# Generate bundle manifests and metadata, then validate generated files.
157-
bundle: operator-sdk manifests
156+
bundle: kustomize operator-sdk manifests
158157
$(OPERATOR_SDK) generate kustomize manifests -q
159-
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
158+
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --manifests --version $(VERSION) $(BUNDLE_METADATA_OPTS)
160159
$(OPERATOR_SDK) bundle validate ./bundle
161160

162161
# Build the bundle image, used only for local dev purposes

RELEASE.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Steps to release a new version of the OpenTelemetry Operator:
77
1. Check the OpenTelemetry Collector's changelog and ensure migration steps are present in `pkg/collector/upgrade`
88
1. Once the changes above are merged and available in `master`, tag it with the desired version, prefixed with `v`: `v0.3.0`
99
1. The GitHub Workflow will take it from here, creating a GitHub release with the generated artifacts (manifests) and publishing the images
10+
1. After the release, generate a new OLM bundle (`make bundle`) and create two PRs against the [Operator Hub Community Operators repository](https://github.com/operator-framework/community-operators):
11+
1. one for the `upstream-community-operators`, used by OLM on Kubernetes. Example: [`operator-framework/community-operators#2880`](operator-framework/community-operators/pull/2880)
12+
1. one for the `community-operators` directory, used by OpenShift. Example: [`operator-framework/community-operators#2878`](operator-framework/community-operators/pull/2878)
1013

1114
## Generating the changelog
1215

api/v1alpha1/opentelemetrycollector_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type OpenTelemetryCollectorStatus struct {
101101
// +kubebuilder:printcolumn:name="Mode",type="string",JSONPath=".spec.mode",description="Deployment Mode"
102102
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="OpenTelemetry Version"
103103
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
104+
// +operator-sdk:csv:customresourcedefinitions:displayName="OpenTelemetry Collector"
104105

105106
// OpenTelemetryCollector is the Schema for the opentelemetrycollectors API.
106107
type OpenTelemetryCollector struct {

bundle.Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM scratch
2+
3+
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
4+
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
5+
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
6+
LABEL operators.operatorframework.io.bundle.package.v1=opentelemetry-operator
7+
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
8+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.2.0
9+
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
10+
LABEL operators.operatorframework.io.metrics.project_layout=go
11+
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
12+
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
13+
COPY bundle/manifests /manifests/
14+
COPY bundle/metadata /metadata/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
control-plane: controller-manager
7+
name: opentelemetry-operator-controller-manager-metrics-service
8+
spec:
9+
ports:
10+
- name: https
11+
port: 8443
12+
targetPort: https
13+
selector:
14+
control-plane: controller-manager
15+
status:
16+
loadBalancer: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: rbac.authorization.k8s.io/v1beta1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
name: opentelemetry-operator-metrics-reader
6+
rules:
7+
- nonResourceURLs:
8+
- /metrics
9+
verbs:
10+
- get
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
creationTimestamp: null
5+
name: opentelemetry-operator-webhook-service
6+
spec:
7+
ports:
8+
- port: 443
9+
targetPort: 9443
10+
selector:
11+
control-plane: controller-manager
12+
status:
13+
loadBalancer: {}

0 commit comments

Comments
 (0)