Skip to content

Commit

Permalink
Fix remaining Makefile issues + annoying bundle date (#291)
Browse files Browse the repository at this point in the history
* Fix remaining Makefile issues + annoying bundle date

After the recent reworking on the Makefile, there were still some
pending issues. E.g. we introduced a "deploy-latest" target but it did
not allow to override the operator image.

This is rollbacking part of the last changes:
- deploy-latest is removed, we can run "make deploy" as we used to do
  before
- make deploy now uses again "main" images by default, as before
- keeping the behaviour that Mohamed introduced, "make bundle" keeps
  using the provided IMG
- UNLIKE before: running "make bundle" alone will NOT update the bundle
  so it is ready for commit; For that, a new target "make update-bundle"
is introduced
- "make bundle" does not generate the creation date as it used to do.
  This is now done via "make bundle-build". It means that RELEASE
SCRIPTS HAVE TO BE UPDATED so they generate the creation date.

* better handle bundle build error; add doc
  • Loading branch information
jotak authored Mar 13, 2023
1 parent 8a4db3c commit 84c7fe8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ jobs:
- name: checkout
uses: actions/checkout@v3
- name: generate bundle
run: make generate bundle
run: make update-bundle
- name: check bundle clean state
run: git diff HEAD -I "createdAt" -I "operator-sdk-v" --exit-code
run: git diff HEAD -I "operator-sdk-v" --exit-code
29 changes: 21 additions & 8 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@ You can refer to existing commits using their short-SHA as the image tag, or ref

```bash
# By commit SHA
OPERATOR_VERSION="960766c" make deploy
VERSION="960766c" make deploy
# By release
OPERATOR_VERSION="0.1.2" make deploy
VERSION="0.1.2" make deploy
```

It is recommended to switch to the corresponding release Git tag before deploying an old version to make sure the underlying components refer to the correct versions.

When `OPERATOR_VERSION` is not provided, it defaults to the latest released version.
When `VERSION` is not provided, it defaults to the latest build on `main` branch.

To deploy all components on their `main` image tag (which correspond to their `main` branches, ie. their latest builds), you can simply run:
You can also provide any custom `IMG` to `make deploy`.

## Before commiting, make sure bundle is correct

The github CI will fail if it finds the bundle isn't in a clean state. To update the bundle, simply run:

```bash
make deploy-latest
make update-bundle
```

This is necessary when the changes you did end up affecting the bundle manifests or metadata (e.g. adding new fields in the CRD, updating some documentation, etc.). When unsure, just run the command mentioned above.

## Installing Kafka

Kafka can be used to separate flow ingestion from flow transformation. The operator does not manage kafka deployment and topic creation. We provide a quick setup for Kafka using the [strimzi operator](https://strimzi.io/).
Expand Down Expand Up @@ -100,9 +106,8 @@ bundle for local testing, you should execute the following commands:

```bash
export USER=<container-registry-username>
export VERSION=0.0.1
export IMG=quay.io/$USER/network-observability-operator:v$VERSION
export BUNDLE_IMG=quay.io/$USER/network-observability-operator-bundle:v$VERSION
export IMG=quay.io/$USER/network-observability-operator:v0.0.1
export BUNDLE_IMG=quay.io/$USER/network-observability-operator-bundle:v0.0.1
make image-build image-push
make bundle bundle-build bundle-push
```
Expand All @@ -111,6 +116,8 @@ Optionally, you might validate the bundle:

```bash
bin/operator-sdk bundle validate $BUNDLE_IMG
# or for podman
bin/operator-sdk bundle validate -b podman $BUNDLE_IMG
```

> Note: the base64 logo can be generated with: `base64 -w 0 <image file>`, then manually pasted in the [CSV manifest file](./config/manifests/bases/netobserv-operator.clusterserviceversion.yaml) under `spec.icon`.
Expand All @@ -123,6 +130,12 @@ This mode is recommended to quickly test the operator during its development:
bin/operator-sdk run bundle $BUNDLE_IMG
```

To cleanup:

```bash
bin/operator-sdk cleanup netobserv-operator
```

### Deploy as bundle from the Console's OperatorHub page

This mode is recommended when you want to test the customer experience of navigating through the
Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ IMAGE_TAG_BASE ?= $(REPO)/network-observability-operator
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(BUNDLE_VERSION)

# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE):$(OPERATOR_VERSION)
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
IMG_SHA = $(IMAGE_TAG_BASE):$(BUILD_SHA)
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
Expand Down Expand Up @@ -281,10 +281,6 @@ uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube

deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/openshift | kubectl apply -f -

deploy-latest: kustomize ## Deploy latest controller, configured with all latest related images using "main" tag
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE_TAG_BASE):main
$(SED) -i -r 's~ebpf-agent:.+~ebpf-agent:main~' ./config/manager/manager.yaml
$(SED) -i -r 's~flowlogs-pipeline:.+~flowlogs-pipeline:main~' ./config/manager/manager.yaml
$(SED) -i -r 's~console-plugin:.+~console-plugin:main~' ./config/manager/manager.yaml
Expand Down Expand Up @@ -315,8 +311,7 @@ bundle-prepare: OPSDK generate kustomize ## Generate bundle manifests and metada
bundle: bundle-prepare ## Generate final bundle files.
$(SED) -e 's/^/ /' config/manifests/bases/description-upstream.md > tmp-desc
$(KUSTOMIZE) build config/manifests \
| $(SED) -e 's~:container-image:~$(IMAGE_TAG_BASE):$(OPERATOR_VERSION)~' \
| $(SED) -e 's~:created-at:~$(DATE)~' \
| $(SED) -e 's~:container-image:~$(IMG)~' \
| $(SED) -e "/':full-description:'/r tmp-desc" \
| $(SED) -e "s/':full-description:'/|\-/" \
| $(OPSDK) generate bundle -q --overwrite --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS)
Expand All @@ -327,9 +322,16 @@ bundle: bundle-prepare ## Generate final bundle files.
if [ $$(echo $${VALIDATION_OUTPUT} | grep -i 'warning' | wc -c) -gt 0 ]; then echo "please correct warnings and errors first"; exit -1 ; fi \
'

.PHONY: update-bundle
update-bundle: IMG=$(IMAGE_TAG_BASE):$(OPERATOR_VERSION)
update-bundle: bundle ## Prepare a clean bundle to be commited

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
$(OCI_BIN) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
cp ./bundle/manifests/netobserv-operator.clusterserviceversion.yaml tmp-bundle
$(SED) -i -r 's~:created-at:~$(DATE)~' ./bundle/manifests/netobserv-operator.clusterserviceversion.yaml
-$(OCI_BIN) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
mv tmp-bundle ./bundle/manifests/netobserv-operator.clusterserviceversion.yaml

shortlived-bundle-build: ## Build a temporary bundle image, expiring after 2 weeks on quay
$(MAKE) bundle-build BUNDLE_IMG=$(IMAGE_TAG_BASE)-bundle:tmp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ metadata:
categories: Monitoring
console.openshift.io/plugins: '["netobserv-plugin"]'
containerImage: quay.io/netobserv/network-observability-operator:1.0.2
createdAt: "2023-02-28T08:36:03Z"
createdAt: ':created-at:'
description: Network flows collector and monitoring solution
operators.operatorframework.io/builder: operator-sdk-v1.25.3
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down

0 comments on commit 84c7fe8

Please sign in to comment.