Skip to content

Commit

Permalink
updates to Makefile to enable image digests
Browse files Browse the repository at this point in the history
Use Digest for Grafana Instance Image

Add grafana image to CSV; update release guidelines
  • Loading branch information
Fabian Mueller committed Sep 12, 2023
1 parent 22ee245 commit 0c826f5
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 256 deletions.
40 changes: 35 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
# Current Operator version
VERSION ?= 5.4.1

# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(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 ?= true
ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif

# Set the Operator SDK version to use. By default, what is installed on the system is used.
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
OPERATOR_SDK_VERSION ?= v1.31.0
# Image URL to use all building/pushing image targets
REGISTRY ?= ghcr.io
REPO ?= grafana-operator
Expand Down Expand Up @@ -155,6 +169,23 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: operator-sdk
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
operator-sdk: ## Download operator-sdk locally if necessary.
ifeq (,$(wildcard $(OPERATOR_SDK)))
ifeq (, $(shell which operator-sdk 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPERATOR_SDK)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH} ;\
chmod +x $(OPERATOR_SDK) ;\
}
else
OPERATOR_SDK = $(shell which operator-sdk)
endif
endif

###
# END OF kubebuilder SECTION
###
Expand All @@ -179,12 +210,11 @@ endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

.PHONY: bundle
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
operator-sdk generate kustomize manifests -q
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
operator-sdk bundle validate ./bundle

$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./bundle
# e2e

.PHONY: e2e
Expand Down
27 changes: 15 additions & 12 deletions PREPARE_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ After that you need to run `make helm/docs` which will generate the changes to b
There is a lot of information on what is needed to manage OLM [compatible operators](https://redhat-connect.gitbook.io/certified-operator-guide/ocp-deployment/operator-metadata/creating-the-csv).

- Update the `Makefile` version
- `make generate`, `make manifests` & `make bundle`
- Update `containerImage` field in `config/manifests/bases/grafana-operator.clusterserviceversion.yaml`
- Update `replaces` field in `config/manifests/bases/grafana-operator.clusterserviceversion.yaml`
- Update `CreatedAt` field in `config/manifests/bases/grafana-operator.clusterserviceversion.yaml`
You will have to asses when it's going to get merged and you will be able to do a release.
You should make sure it's the same date. If not you will have to change it
manually when creating PR:s to OLM.

# This is how the time syntax should look.
$ docker inspect ghcr.io/grafana-operator/grafana-operator:v5.0.0 |jq '.[0].Created'
"2023-11-22T10:34:12.173861869Z"
# 2023-11-22T10:34:12Z is enough
- Run `make generate` & `make manifests`
- Update the following fields under `metadata.annotations` in `config/manifests/bases/grafana-operator.clusterserviceversion.yaml`:
- `containerImage`
- `replaces`
- `createdAt`: You will have to asses when it's going to get merged and you will be able to do a release. You should make sure it's the same date. If not you will have to change it manually when creating PR:s to OLM.
```
# This is how the time syntax should look.
$ docker inspect ghcr.io/grafana-operator/grafana-operator:v5.0.0 |jq '.[0].Created'
"2023-11-22T10:34:12.173861869Z"
# 2023-11-22T10:34:12Z is enough
```
- Run `make bundle`
- Add the grafana image specified by digest to `spec.relatedImages` to `bundle/manifests/grafana-operator.clusterserviceversion.yaml` by running
```
GRAFANA_IMAGE="$(grep 'GrafanaImage =' controllers/config/operator_constants.go| awk -F '"' '{print $2}')@$(grep 'GrafanaDigest =' controllers/config/operator_constants.go| awk -F '"' '{print $2}')" yq -i '.spec.relatedImages += {"image": strenv(GRAFANA_IMAGE), "name": "grafana"}' bundle/manifests/grafana-operator.clusterserviceversion.yaml
```
- `Helm` look if any rbac rules have been changed in the last release, if so verify that the rbac rules for the helm chart is correct. This should be done in those PRs but it don't hurt take an extra look.
- Create a PR and get it merged
- Create a new release with the new tag, make sure to compile release notes (github has an option to do this for you)
Expand Down
Loading

0 comments on commit 0c826f5

Please sign in to comment.