Skip to content

Commit

Permalink
CLOUDP-226589: Upgrade to controller-runtime 0.16 and K8s API 0.28 (#…
Browse files Browse the repository at this point in the history
…1391)

* Upgrade controller.runtime (and K8s API)

Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>

* Fix OIDC test with explicit ns

Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>

* Fix deployment-ns with explicit ns

Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>

---------

Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
  • Loading branch information
josvazg authored Mar 6, 2024
1 parent 8dc6913 commit efbdc72
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 119 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ jobs:
"cloud-access-role",
"deployment-annotations-ns",
"deployment-ns",
"users",
"users-oidc",
"deployment-wide",
"encryption-at-rest",
Expand Down
2 changes: 1 addition & 1 deletion .licenses-gomod.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
100644 64809ef80692f1ff1c968700682c6c008068377f go.mod
100644 a8256bc72dd8a3aa4584586e09f421d9dcd79f4a go.mod
28 changes: 11 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ REGISTRY ?= quay.io/mongodb
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
BUNDLE_IMG ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease-bundle:$(VERSION)

#IMG ?= mongodb-atlas-kubernetes-operator:latest
#BUNDLE_REGISTRY ?= $(REGISTRY)/mongodb-atlas-operator-bundle
OPERATOR_REGISTRY ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease
CATALOG_REGISTRY ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease-catalog
Expand Down Expand Up @@ -199,15 +198,13 @@ uninstall: manifests kustomize ## Uninstall CRDs from a cluster
deploy: generate manifests run-kind ## Deploy controller in the configured Kubernetes cluster in ~/.kube/config
@./scripts/deploy.sh

$(TIMESTAMPS_DIR)/manifests: $(GO_SOURCES)
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./pkg/api/..." output:crd:artifacts:config=config/crd/bases
@./scripts/split_roles_yaml.sh
@mkdir -p $(TIMESTAMPS_DIR) && touch $@

.PHONY: manifests
# Produce CRDs that work back to Kubernetes 1.16 (so 'apiVersion: apiextensions.k8s.io/v1')
manifests: CRD_OPTIONS ?= "crd:crdVersions=v1,ignoreUnexportedFields=true"
manifests: fmt controller-gen $(TIMESTAMPS_DIR)/manifests ## Generate manifests e.g. CRD, RBAC etc.
manifests: fmt controller-gen ## Generate manifests e.g. CRD, RBAC etc.
controller-gen $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./pkg/api/..." output:crd:artifacts:config=config/crd/bases
@./scripts/split_roles_yaml.sh
@mkdir -p $(TIMESTAMPS_DIR) && touch $@

$(TIMESTAMPS_DIR)/golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
Expand Down Expand Up @@ -240,19 +237,15 @@ $(TIMESTAMPS_DIR)/vet: $(GO_SOURCES)
.PHONY: vet
vet: $(TIMESTAMPS_DIR)/vet ## Run go vet against code

$(TIMESTAMPS_DIR)/generate: ${GO_SOURCES}
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/api/..."
@mkdir -p $(TIMESTAMPS_DIR) && touch $@

.PHONY: generate
generate: controller-gen $(TIMESTAMPS_DIR)/generate fmt ## Generate code

.PHONY: controller-gen
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2)
@which controller-gen || go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2

.PHONY: generate
generate: controller-gen ${GO_SOURCES} ## Generate code
controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./pkg/api/..."
$(MAKE) fmt

.PHONY: validate-manifests
FILES = $(shell git ls-files -o -m --directory --exclude-standard --no-empty-directory)
TEMP := $(shell echo "$(FILES)" | awk 'NF')
LINES := $(shell echo "$(FILES)" | awk -F=' ' "{ print NF }")
Expand All @@ -269,6 +262,7 @@ endif
@echo "--------------------"
@echo "Check: PASS"

.PHONY: validate-manifests
validate-manifests: generate manifests check-missing-files

.PHONY: kustomize
Expand Down
17 changes: 12 additions & 5 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"go.uber.org/zap/zapcore"
ctrzap "sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/webhook"

"github.com/go-logr/zapr"
"go.uber.org/zap"
Expand All @@ -45,6 +46,8 @@ import (
mdbv1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/controller"

metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/featureflags"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/kube"
"github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/controller/atlas"
Expand Down Expand Up @@ -114,14 +117,18 @@ func main() {
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: config.MetricsAddr,
Port: 9443,
Namespace: config.Namespace,
Scheme: scheme,
Metrics: metricsserver.Options{BindAddress: config.MetricsAddr},
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
}),
Cache: cache.Options{
DefaultNamespaces: map[string]cache.Config{config.Namespace: {}},
SyncPeriod: &syncPeriod,
},
HealthProbeBindAddress: config.ProbeAddr,
LeaderElection: config.EnableLeaderElection,
LeaderElectionID: "06d035fb.mongodb.com",
SyncPeriod: &syncPeriod,
NewCache: cacheFunc,
})
if err != nil {
Expand Down
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ require (
google.golang.org/api v0.168.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.27.8
k8s.io/apimachinery v0.27.8
k8s.io/client-go v0.27.8
sigs.k8s.io/controller-runtime v0.15.3
k8s.io/api v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
sigs.k8s.io/controller-runtime v0.16.5
)

require (
Expand All @@ -45,6 +45,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
Expand Down Expand Up @@ -74,20 +75,19 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
Expand All @@ -106,17 +106,17 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
golang.org/x/net v0.21.0 // indirect
Expand All @@ -125,17 +125,17 @@ require (
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/apiextensions-apiserver v0.27.7 // indirect
k8s.io/component-base v0.27.7 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
Expand Down
Loading

0 comments on commit efbdc72

Please sign in to comment.