Skip to content

Commit

Permalink
Upgrade operator sdk (#231)
Browse files Browse the repository at this point in the history
* upgrade operator sdk to 1.3.0

* upgrade operator sdk to 1.4.0

* upgrade operator sdk to 1.5.0

* update skaffold config

* nit

* Update to 1.6.x

* Add leases.coordination.k8s.io role for leaderelection. Part of operatorsdk upgrade to 1.7.x

* Upgrade dependencies.

* Fix broken leaderelection.

* Add missing newlines.

* Add better debugging info for flaky test.

Co-authored-by: Tomash Sidei <[email protected]>
  • Loading branch information
antonioua and tomashibm authored Dec 13, 2021
1 parent a266939 commit 85a2b22
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 103 deletions.
36 changes: 32 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
-include vars.mk

OS = $(shell go env GOOS)
ARCH = $(shell go env GOARCH)
SHELL ?= bash
# Current Operator version
VERSION ?= 0.0.1
# Default bundle image tag
BUNDLE_IMG ?= controller-bundle:$(VERSION)
IMAGE_TAG_BASE ?= ibmcom/cassandra-operator
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
# Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
Expand Down Expand Up @@ -99,7 +102,7 @@ generate: controller-gen

# Build the docker image
docker-build:
docker build . -t ${IMG}
docker build -t ${IMG}

# Push the docker image
docker-push:
Expand All @@ -114,7 +117,7 @@ ifeq (, $(shell which controller-gen))
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0 ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION) ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand All @@ -138,11 +141,36 @@ KUSTOMIZE=$(shell which kustomize)
endif

# Generate bundle manifests and metadata, then validate generated files.
bundle: manifests
bundle: manifests kustomize
operator-sdk generate kustomize manifests -q
kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
operator-sdk bundle validate ./bundle

# Build the bundle image.
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: opm
OPM = ./bin/opm
opm:
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPM)) ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$(OS)-$(ARCH)-opm ;\
chmod +x $(OPM) ;\
}
else
OPM = $(shell which opm)
endif
endif
BUNDLE_IMGS ?= $(BUNDLE_IMG)
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION) ifneq ($(origin CATALOG_BASE_IMG), undefined) FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) endif
.PHONY: catalog-build
catalog-build: opm
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)

.PHONY: catalog-push
catalog-push: ## Push the catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)
11 changes: 8 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
domain: ibm.com
layout: go.kubebuilder.io/v3-alpha
layout: go.kubebuilder.io/v3
repo: github.com/ibm/cassandra-operator
resources:
- group: db
- domain: ibm.com
controller: true
group: db
kind: CassandraCluster
path: github.com/ibm/cassandra-operator/api/v1alpha1
version: v1alpha1
plugins:
go.operator-sdk.io/v2-alpha: {}
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
version: "3"
12 changes: 12 additions & 0 deletions cassandra-operator/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- db.ibm.com
resources:
Expand Down
1 change: 1 addition & 0 deletions controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type CassandraClusterReconciler struct {
// +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;watch
// +kubebuilder:rbac:groups="batch",resources=jobs,verbs=get;list;watch;create;update;delete;patch
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles;clusterrolebindings;roles;rolebindings,verbs=list;watch;get;create;update;delete
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=list;watch;get;create;update;delete;patch
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors,verbs=list;watch;get;create;update;delete

func (r *CassandraClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ slug: /development

* Kubernetes 1.16 or newer. You can use [minikube](https://kubernetes.io/docs/setup/minikube/) or [kind](https://github.com/kubernetes-sigs/kind) for local development.
* Go 1.12+ with enabled go modules
* [OperatorSDK](https://github.com/operator-framework/operator-sdk) 1.0.0+
* [OperatorSDK](https://github.com/operator-framework/operator-sdk) v1.5.0+
* [kustomize](https://github.com/kubernetes-sigs/kustomize) 3.1.0+
* [helm](https://helm.sh/) v2.14.3+
* [docker](https://docs.docker.com/install/)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ require (
github.com/google/go-cmp v0.5.6
github.com/google/go-querystring v1.0.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.14.0
github.com/onsi/gomega v1.15.0
github.com/pkg/errors v0.9.1
go.uber.org/zap v1.17.0
go.uber.org/zap v1.19.0
k8s.io/api v0.22.2
k8s.io/apiextensions-apiserver v0.22.2
k8s.io/apimachinery v0.22.2
k8s.io/client-go v0.22.2
sigs.k8s.io/controller-runtime v0.9.2
sigs.k8s.io/controller-runtime v0.10.3
sigs.k8s.io/yaml v1.2.0
)
Loading

0 comments on commit 85a2b22

Please sign in to comment.