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

Improve developer experience by minimizing local changes #2421

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 21 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ git commit -sam "Add feature X"
gh pr create
```

#### Make changes to the project manifests

The following command should be run to make sure the project manifests are up-to-date:

```bash
make generate manifests bundle api-docs reset
```

The local changes after running the command should be added to the pull request:

The following `make` target is run on CI to verify the project structure:

```bash
make ensure-generate-is-noop
```

### Pre-requisites
* Install [Go](https://golang.org/doc/install).
* Install [Kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/).
Expand All @@ -37,7 +53,7 @@ Refer to the [Operator SDK documentation](https://sdk.operatorframework.io/docs/

Build the manifests, install the CRD and run the operator as a local process:
```bash
make bundle install run
make install run
```

### Deployment with webhooks
Expand All @@ -58,16 +74,16 @@ The environment variable `CERTMANAGER_VERSION` can be used to override the cert-
CERTMANAGER_VERSION=1.60 make cert-manager
```

When deploying the operator into the cluster using `make deploy`, an image in the format `ghcr.io/${USER}/opentelemetry-operator` is generated. If this format isn't suitable, it can be overridden by:
When deploying the operator into the cluster using `make deploy`, an image in the format `ghcr.io/${DOCKER_USER}/opentelemetry-operator` is generated. If this format isn't suitable, it can be overridden by:

* `IMG_PREFIX`, to override the registry, namespace and image name
* `USER`, to override the namespace
* `DOCKER_USER`, to override the namespace
* `IMG_REPO`, to override the repository (`opentelemetry-operator`)
* `VERSION`, to override only the version part
* `IMG`, to override the entire image specification

```bash
IMG=docker.io/${USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate bundle container container-push deploy
IMG=docker.io/${DOKCER_USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate container container-push deploy
pavolloffay marked this conversation as resolved.
Show resolved Hide resolved
```

Your operator will be available in the `opentelemetry-operator-system` namespace.
Expand Down Expand Up @@ -188,7 +204,7 @@ BUNDLE_IMG=docker.io/${USER}/opentelemetry-operator-bundle:latest IMG=docker.io/
### Install the operator

```bash
operator-sdk run bundle docker.io/${USER}/opentelemetry-operator-bundle:latest
operator-sdk run bundle docker.io/${DOCKER_USER}/opentelemetry-operator-bundle:latest
```

### Uninstall the operator
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ OPERATOR_LDFLAGS ?= -X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.build
ARCH ?= $(shell go env GOARCH)

# Image URL to use all building/pushing image targets
IMG_PREFIX ?= ghcr.io/${USER}/opentelemetry-operator
DOCKER_USER ?= open-telemetry
IMG_PREFIX ?= ghcr.io/${DOCKER_USER}/opentelemetry-operator
IMG_REPO ?= opentelemetry-operator
IMG ?= ${IMG_PREFIX}/${IMG_REPO}:${VERSION}
BUNDLE_IMG ?= ${IMG_PREFIX}/${IMG_REPO}-bundle:${VERSION}
Expand Down Expand Up @@ -82,7 +83,7 @@ SED ?= $(shell which gsed 2>/dev/null || which sed)

.PHONY: ensure-generate-is-noop
ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION)
ensure-generate-is-noop: USER=open-telemetry
ensure-generate-is-noop: DOCKER_USER=open-telemetry
ensure-generate-is-noop: set-image-controller generate bundle
@# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check
@git restore config/manager/kustomization.yaml
Expand Down Expand Up @@ -178,7 +179,7 @@ lint: golangci-lint

# Generate code
.PHONY: generate
generate: controller-gen api-docs
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# end-to-tests
Expand Down Expand Up @@ -442,6 +443,15 @@ bundle: kustomize operator-sdk manifests set-image-controller
$(OPERATOR_SDK) bundle validate ./bundle
./hack/ignore-createdAt-bundle.sh

.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
git checkout config/manager/kustomization.yaml

# Build the bundle image, used only for local dev purposes
.PHONY: bundle-build
bundle-build:
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Steps to release a new version of the OpenTelemetry Operator:

1. Change the `versions.txt`, so that it lists the target version of the OpenTelemetry Collector (operand), and the desired version for the target allocator and the operator. The `major.minor` should typically match, with the patch portion being possibly different.
2. Change the `autoinstrumentation-*` versions in `versions.txt` as per the latest supported versions in `autoinstrumentation/`.
3. Run `make bundle USER=open-telemetry VERSION=0.38.0`, using the version that will be released.
3. Run `make bundle DOCKER_USER=open-telemetry VERSION=0.38.0`, using the version that will be released.
4. 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.
5. Add the changes to the changelog. Manually add versions of all operator components.
6. Check the OpenTelemetry Collector's changelog and ensure migration steps are present in `pkg/collector/upgrade`
Expand Down
10 changes: 6 additions & 4 deletions hack/ignore-createdAt-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# This code checks if only the createdAt field. If is the only change, it is ignored.
# Else, it will do nothing.
# https://github.com/operator-framework/operator-sdk/issues/6285#issuecomment-1415350333
git diff --quiet -I'^ createdAt: ' bundle
if ((! $?)) ; then
git checkout bundle
fi
git diff --quiet -I'^ createdAt: ' bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml
ret=$?
changes=$(git diff --numstat bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml)
if [ $ret = 0 ] && [ "$changes" = '1 1 bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml' ] ; then
git checkout bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml
fi
Loading