v1.21.0

(go/v3):For golang-language based operators, fix suite test using global cfg

In the suite test files, replace cfg, err := testEnv.Start() with:

  1. var err error
  2. // cfg is defined in this file globally.
  3. cfg, err = testEnv.Start()

Note: You can find suite test files scaffold for the APIs created for your project such as api/webhook_suitetest.go directory as for your controllers in controllers/suite_test.go.

See #4863 for more details.

For Golang-based operators, update Dockerfile if you are using the declarative/v1 plugin

If you are using the declarative/v1 plugin for your scaffolds, then following the steps to update the Dockerfile. a) After COPY controllers/ controllers/ add:

  1. # https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/blob/master/docs/addon/walkthrough/README.md#adding-a-manifest
  2. # Stage channels and make readable
  3. COPY channels/ /channels/
  4. RUN chmod -R a+rx /channels/

b) After the COPY --from=builder /workspace/manager .” add:

  1. # copy channels
  2. COPY --from=builder /channels /channels

See #4863 for more details.

(go/v3):For Golang-based operators, upgrade controller-runtime from v0.11.0 to v0.11.2 and Kubernetes deps from 1.23.0 to 1.23.5

Update your go.mod by replacing sigs.k8s.io/controller-runtime v0.11.0 with sigs.k8s.io/controller-runtime v0.11.2 and run go mod tidy to update the K8s dependencies.

See #4863 for more details.

For Golang/Helm/Ansible-based operators, upgrade kube-rbac-proxy image from v0.8.0 to v0.11.0. (For further information see the kube-rbac-proxy release notes)

Update the tag version used for the image gcr.io/kubebuilder/kube-rbac-proxy in the file config/default/manager_auth_proxy_patch.yaml. Replace gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0 with gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0

See #4863 for more details.

For Golang-based operators, change Makefile targets to replace go get with go install

The targets kustomize, controller-gen and envtest were changed. Update the Makefile replacing:

  1. CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
  2. .PHONY: controller-gen
  3. controller-gen: ## Download controller-gen locally if necessary.
  4. $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.8.0)
  5. KUSTOMIZE = $(shell pwd)/bin/kustomize
  6. .PHONY: kustomize
  7. kustomize: ## Download kustomize locally if necessary.
  8. $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
  9. ENVTEST = $(shell pwd)/bin/setup-envtest
  10. .PHONY: envtest
  11. envtest: ## Download envtest-setup locally if necessary.
  12. $(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
  13. # go-get-tool will 'go get' any package $2 and install it to $1.
  14. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
  15. define go-get-tool
  16. @[ -f $(1) ] || { \
  17. set -e ;\
  18. TMP_DIR=$$(mktemp -d) ;\
  19. cd $$TMP_DIR ;\
  20. go mod init tmp ;\
  21. echo "Downloading $(2)" ;\
  22. GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
  23. rm -rf $$TMP_DIR ;\
  24. }
  25. endef

With:

  1. ##@ Build Dependencies
  2. ## Location to install dependencies to
  3. LOCALBIN ?= $(shell pwd)/bin
  4. $(LOCALBIN):
  5. mkdir -p $(LOCALBIN)
  6. ## Tool Binaries
  7. KUSTOMIZE ?= $(LOCALBIN)/kustomize
  8. CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
  9. ENVTEST ?= $(LOCALBIN)/setup-envtest
  10. ## Tool Versions
  11. KUSTOMIZE_VERSION ?= v3.8.7
  12. CONTROLLER_TOOLS_VERSION ?= v0.8.0
  13. KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
  14. .PHONY: kustomize
  15. kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
  16. $(KUSTOMIZE): $(LOCALBIN)
  17. curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)
  18. .PHONY: controller-gen
  19. controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
  20. $(CONTROLLER_GEN): $(LOCALBIN)
  21. GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
  22. .PHONY: envtest
  23. envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
  24. $(ENVTEST): $(LOCALBIN)
  25. GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

See #4863 for more details.

Last modified May 24, 2022: Release v1.21.0 (#5799) (89d21a13)