Skip to content

Commit

Permalink
chore(build): upgrade Operator SDK to v1.31.0 (#629)
Browse files Browse the repository at this point in the history
* upgrade Operator SDK to v1.31.0

* updated createdAt

* removed createdAt on config/manifests/bases/cryostat-operator.clusterserviceversion.yaml

* rebase

* add operator-sdk as prerequisite for scorecard

* remove the setup-operator-sdk

* resolved issues

* clean-scorecard to use operator-sdk as well

* clean extra spaces

* clean indentation

* add trailing slash on then
  • Loading branch information
aali309 authored Sep 27, 2023
1 parent 7aac9e0 commit a85a750
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 64 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test-ci-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ jobs:
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
- uses: jpkrohling/[email protected]
with:
operator-sdk-version: v1.28.0
- name: Install podman v4
run: |
echo "deb $OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list
Expand Down
64 changes: 41 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ BUNDLE_VERSION ?= $(IMAGE_VERSION)
DEFAULT_NAMESPACE ?= quay.io/cryostat
IMAGE_NAMESPACE ?= $(DEFAULT_NAMESPACE)
OPERATOR_NAME ?= cryostat-operator
OPERATOR_SDK_VERSION ?= v1.31.0
CLUSTER_CLIENT ?= kubectl
IMAGE_TAG_BASE ?= $(IMAGE_NAMESPACE)/$(OPERATOR_NAME)

Expand All @@ -21,10 +22,10 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(BUNDLE_VERSION)
BUNDLE_IMGS ?= $(BUNDLE_IMG)

# Default catalog image tag
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(BUNDLE_VERSION)
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(BUNDLE_VERSION)
ifneq ($(origin CATALOG_BASE_IMG), undefined)
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
endif
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
endif

# Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined)
Expand Down Expand Up @@ -133,16 +134,16 @@ ifneq ($(SKIP_TESTS), true)
endif

.PHONY: test-scorecard
test-scorecard: check_cert_manager kustomize
test-scorecard: check_cert_manager kustomize operator-sdk
ifneq ($(SKIP_TESTS), true)
$(call scorecard-setup)
$(call scorecard-cleanup); \
trap cleanup EXIT; \
operator-sdk scorecard -n $(SCORECARD_NAMESPACE) -s cryostat-scorecard -w 20m $(BUNDLE_IMG) --pod-security=restricted
$(OPERATOR_SDK) scorecard -n $(SCORECARD_NAMESPACE) -s cryostat-scorecard -w 20m $(BUNDLE_IMG) --pod-security=restricted
endif

.PHONY: clean-scorecard
clean-scorecard:
clean-scorecard: operator-sdk
- $(call scorecard-cleanup); cleanup

ifneq ($(and $(SCORECARD_REGISTRY_SERVER),$(SCORECARD_REGISTRY_USERNAME),$(SCORECARD_REGISTRY_PASSWORD)),)
Expand All @@ -161,14 +162,14 @@ $(KUSTOMIZE) build internal/images/custom-scorecard-tests/rbac/ | $(CLUSTER_CLIE
--docker-username="$(SCORECARD_REGISTRY_USERNAME)" --docker-password="$(SCORECARD_REGISTRY_PASSWORD)"; \
$(CLUSTER_CLIENT) patch sa cryostat-scorecard -n $(SCORECARD_NAMESPACE) -p '{"imagePullSecrets": [{"name": "registry-key"}]}'; \
fi
operator-sdk run bundle -n $(SCORECARD_NAMESPACE) --timeout 20m $(BUNDLE_IMG) --security-context-config=restricted $(SCORECARD_ARGS)
$(OPERATOR_SDK) run bundle -n $(SCORECARD_NAMESPACE) --timeout 20m $(BUNDLE_IMG) --security-context-config=restricted $(SCORECARD_ARGS)
endef

define scorecard-cleanup
function cleanup { \
(\
set +e; \
operator-sdk cleanup -n $(SCORECARD_NAMESPACE) $(OPERATOR_NAME); \
$(OPERATOR_SDK) cleanup -n $(SCORECARD_NAMESPACE) $(OPERATOR_NAME); \
$(KUSTOMIZE) build internal/images/custom-scorecard-tests/rbac/ | $(CLUSTER_CLIENT) delete --ignore-not-found=$(ignore-not-found) -f -; \
$(CLUSTER_CLIENT) delete --ignore-not-found=$(ignore-not-found) -n $(SCORECARD_NAMESPACE) secret registry-key; \
$(CLUSTER_CLIENT) delete --ignore-not-found=$(ignore-not-found) namespace $(SCORECARD_NAMESPACE); \
Expand All @@ -187,7 +188,7 @@ run: manifests generate fmt vet
go run ./internal/main.go

ifndef ignore-not-found
ignore-not-found = false
ignore-not-found = false
endif

# Install CRDs into a cluster
Expand Down Expand Up @@ -256,7 +257,7 @@ check-license: golicense
@echo "Checking license..."
$(GOLICENSE) --config=go-license.yml --verify $(shell find ${GO_PACKAGES} -name "*.go")

.PHONY: add-license
.PHONY: add-license
add-license: golicense
@echo "Adding license..."
$(GOLICENSE) --config=go-license.yml $(shell find ${GO_PACKAGES} -name "*.go")
Expand Down Expand Up @@ -306,11 +307,11 @@ remove_cert_manager:
.PHONY: check_cert_manager
check_cert_manager:
@api_versions=$$($(CLUSTER_CLIENT) api-versions) &&\
if [ $$(echo "$${api_versions}" | grep -c '^cert-manager.io/v1$$') -eq 0 ]; then if [ "$${DISABLE_SERVICE_TLS}" != "true" ]; then\
echo 'cert-manager is not installed, install using "make cert_manager" or disable TLS for services by setting DISABLE_SERVICE_TLS to true' >&2\
&& exit 1;\
fi;\
fi
if [ $$(echo "$${api_versions}" | grep -c '^cert-manager.io/v1$$') -eq 0 ]; then\
if [ "$${DISABLE_SERVICE_TLS}" != "true" ]; then\
echo 'cert-manager is not installed, install using "make cert_manager" or disable TLS for services by setting DISABLE_SERVICE_TLS to true' >&2 && exit 1;\
fi;\
fi

# Location to install dependencies
LOCALBIN ?= $(shell pwd)/bin
Expand Down Expand Up @@ -368,13 +369,30 @@ $(OPM): local-bin
catalog-build: opm
$(OPM) index add --container-tool $(IMAGE_BUILDER) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)

.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

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

# Build the bundle image.
.PHONY: bundle-build
Expand All @@ -383,7 +401,7 @@ bundle-build:

.PHONY: deploy_bundle
deploy_bundle: check_cert_manager undeploy_bundle
operator-sdk run bundle --install-mode $(BUNDLE_INSTALL_MODE) $(BUNDLE_IMG)
$(OPERATOR_SDK) run bundle --install-mode $(BUNDLE_INSTALL_MODE) $(BUNDLE_IMG)
ifeq ($(DISABLE_SERVICE_TLS), true)
@echo "Disabling TLS for in-cluster communication between Services"
@current_ns=`$(CLUSTER_CLIENT) config view --minify -o 'jsonpath={.contexts[0].context.namespace}'` && \
Expand All @@ -400,8 +418,8 @@ ifeq ($(DISABLE_SERVICE_TLS), true)
endif

.PHONY: undeploy_bundle
undeploy_bundle:
- operator-sdk cleanup $(OPERATOR_NAME)
undeploy_bundle: operator-sdk
- $(OPERATOR_SDK) cleanup $(OPERATOR_NAME)

# Deploy a Cryostat instance
.PHONY: create_cryostat_cr
Expand Down Expand Up @@ -459,7 +477,7 @@ endif

.PHONY: sample_app
sample_app:
$(CLUSTER_CLIENT) apply $(SAMPLE_APP_FLAGS) -f config/samples/sample-app.yaml
$(CLUSTER_CLIENT) apply $(SAMPLE_APP_FLAGS) -f config/samples/sample-app.yaml

.PHONY: undeploy_sample_app
undeploy_sample_app:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ kubectl get secret ${CRYOSTAT_NAME}-jmx-auth -o jsonpath='{$.data.CRYOSTAT_RJMX_
# Building
## Requirements
- `go` v1.20
- [`operator-sdk`](https://github.com/operator-framework/operator-sdk) v1.28.0
- [`operator-sdk`](https://github.com/operator-framework/operator-sdk) v1.31.0
- [`cert-manager`](https://github.com/cert-manager/cert-manager) v1.11.5+ (Recommended)
- `podman` or `docker`
- [`jq`](https://stedolan.github.io/jq/) v1.6+
Expand Down
2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=cryostat-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.28.0
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.31.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
4 changes: 2 additions & 2 deletions bundle/manifests/cryostat-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ metadata:
capabilities: Seamless Upgrades
categories: Monitoring, Developer Tools
containerImage: quay.io/cryostat/cryostat-operator:2.4.0-dev
createdAt: "2023-08-24T00:50:46Z"
createdAt: "2023-09-18T15:10:18Z"
description: JVM monitoring and profiling tool
operatorframework.io/initialization-resource: |-
{
Expand All @@ -71,7 +71,7 @@ metadata:
}
}
}
operators.operatorframework.io/builder: operator-sdk-v1.28.0
operators.operatorframework.io/builder: operator-sdk-v1.31.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: github.com/cryostatio/cryostat-operator
support: Cryostat Community
Expand Down
15 changes: 10 additions & 5 deletions bundle/manifests/operator.cryostat.io_clustercryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -2471,7 +2472,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -2518,7 +2520,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -2565,7 +2568,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -4451,7 +4455,8 @@ spec:
defined in spec.resourceClaims, that are used by
this container. \n This is an alpha field and requires
enabling the DynamicResourceAllocation feature gate.
\n This field is immutable."
\n This field is immutable. It can only be set for
containers."
items:
description: ResourceClaim references one entry
in PodSpec.ResourceClaims.
Expand Down
15 changes: 10 additions & 5 deletions bundle/manifests/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -2467,7 +2468,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -2514,7 +2516,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -2561,7 +2564,8 @@ spec:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
feature gate. \n This field is immutable. It can only be
set for containers."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
Expand Down Expand Up @@ -4447,7 +4451,8 @@ spec:
defined in spec.resourceClaims, that are used by
this container. \n This is an alpha field and requires
enabling the DynamicResourceAllocation feature gate.
\n This field is immutable."
\n This field is immutable. It can only be set for
containers."
items:
description: ResourceClaim references one entry
in PodSpec.ResourceClaims.
Expand Down
2 changes: 1 addition & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ annotations:
operators.operatorframework.io.bundle.metadata.v1: metadata/
operators.operatorframework.io.bundle.package.v1: cryostat-operator
operators.operatorframework.io.bundle.channels.v1: alpha
operators.operatorframework.io.metrics.builder: operator-sdk-v1.28.0
operators.operatorframework.io.metrics.builder: operator-sdk-v1.31.0
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3

Expand Down
12 changes: 6 additions & 6 deletions bundle/tests/scorecard/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ stages:
- entrypoint:
- scorecard-test
- basic-check-spec
image: quay.io/operator-framework/scorecard-test:v1.28.0
image: quay.io/operator-framework/scorecard-test:v1.31.0
labels:
suite: basic
test: basic-check-spec-test
Expand All @@ -19,7 +19,7 @@ stages:
- entrypoint:
- scorecard-test
- olm-bundle-validation
image: quay.io/operator-framework/scorecard-test:v1.28.0
image: quay.io/operator-framework/scorecard-test:v1.31.0
labels:
suite: olm
test: olm-bundle-validation-test
Expand All @@ -29,7 +29,7 @@ stages:
- entrypoint:
- scorecard-test
- olm-crds-have-validation
image: quay.io/operator-framework/scorecard-test:v1.28.0
image: quay.io/operator-framework/scorecard-test:v1.31.0
labels:
suite: olm
test: olm-crds-have-validation-test
Expand All @@ -39,7 +39,7 @@ stages:
- entrypoint:
- scorecard-test
- olm-crds-have-resources
image: quay.io/operator-framework/scorecard-test:v1.28.0
image: quay.io/operator-framework/scorecard-test:v1.31.0
labels:
suite: olm
test: olm-crds-have-resources-test
Expand All @@ -49,7 +49,7 @@ stages:
- entrypoint:
- scorecard-test
- olm-spec-descriptors
image: quay.io/operator-framework/scorecard-test:v1.28.0
image: quay.io/operator-framework/scorecard-test:v1.31.0
labels:
suite: olm
test: olm-spec-descriptors-test
Expand All @@ -59,7 +59,7 @@ stages:
- entrypoint:
- scorecard-test
- olm-status-descriptors
image: quay.io/operator-framework/scorecard-test:v1.28.0
image: quay.io/operator-framework/scorecard-test:v1.31.0
labels:
suite: olm
test: olm-status-descriptors-test
Expand Down
Loading

0 comments on commit a85a750

Please sign in to comment.