From 88a37dd7d4987d8fc26dbcb00f4b7dafe7be072d Mon Sep 17 00:00:00 2001 From: Damian Badura <45110612+dbadura@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:59:22 +0100 Subject: [PATCH] Add dev overlay to operator kustomize (#764) --- Makefile | 6 ++-- components/operator/Makefile | 36 ++++++++++++------- components/operator/controllers/suite_test.go | 2 +- ...operator.kyma-project.io_serverlesses.yaml | 0 .../{ => base}/crd/kustomization.yaml | 0 .../{ => base}/crd/kustomizeconfig.yaml | 0 .../deployment/deployment.yaml} | 0 .../base/deployment/kustomization.yaml | 8 +++++ .../{default => base}/kustomization.yaml | 8 ++--- .../{ => base}/rbac/kustomization.yaml | 0 config/operator/{ => base}/rbac/role.yaml | 0 .../{ => base}/rbac/role_binding.yaml | 0 .../rbac/serverless_editor_role.yaml | 0 .../rbac/serverless_viewer_role.yaml | 0 .../{ => base}/rbac/service_account.yaml | 0 .../ui-extensions/kustomization.yaml | 0 .../ui-extensions/serverless/details | 0 .../{ => base}/ui-extensions/serverless/form | 0 .../ui-extensions/serverless/general | 0 .../serverless/kustomization.yaml | 0 .../{ => base}/ui-extensions/serverless/list | 0 config/operator/dev/.gitignore | 1 + config/operator/dev/kustomization.yaml.tpl | 9 +++++ config/operator/operator/kustomization.yaml | 8 ----- 24 files changed, 50 insertions(+), 28 deletions(-) rename config/operator/{ => base}/crd/bases/operator.kyma-project.io_serverlesses.yaml (100%) rename config/operator/{ => base}/crd/kustomization.yaml (100%) rename config/operator/{ => base}/crd/kustomizeconfig.yaml (100%) rename config/operator/{operator/operator.yaml => base/deployment/deployment.yaml} (100%) create mode 100644 config/operator/base/deployment/kustomization.yaml rename config/operator/{default => base}/kustomization.yaml (90%) rename config/operator/{ => base}/rbac/kustomization.yaml (100%) rename config/operator/{ => base}/rbac/role.yaml (100%) rename config/operator/{ => base}/rbac/role_binding.yaml (100%) rename config/operator/{ => base}/rbac/serverless_editor_role.yaml (100%) rename config/operator/{ => base}/rbac/serverless_viewer_role.yaml (100%) rename config/operator/{ => base}/rbac/service_account.yaml (100%) rename config/operator/{ => base}/ui-extensions/kustomization.yaml (100%) rename config/operator/{ => base}/ui-extensions/serverless/details (100%) rename config/operator/{ => base}/ui-extensions/serverless/form (100%) rename config/operator/{ => base}/ui-extensions/serverless/general (100%) rename config/operator/{ => base}/ui-extensions/serverless/kustomization.yaml (100%) rename config/operator/{ => base}/ui-extensions/serverless/list (100%) create mode 100644 config/operator/dev/.gitignore create mode 100644 config/operator/dev/kustomization.yaml.tpl delete mode 100644 config/operator/operator/kustomization.yaml diff --git a/Makefile b/Makefile index b32d587cb..028fb88e9 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,15 @@ include ${PROJECT_ROOT}/hack/tools/help.Makefile ##@ Installation .PHONY: install-serverless-main install-serverless-main: ## Install serverless with operator using default serverless cr - make -C ${OPERATOR_ROOT} deploy apply-default-serverless-cr check-serverless-installation + make -C ${OPERATOR_ROOT} deploy-main apply-default-serverless-cr check-serverless-installation .PHONY: install-serverless-latest-release -install-serverless-latest-release: +install-serverless-latest-release: ## Install serverless from latest release kubectl create namespace kyma-system || true kubectl apply -f https://github.com/kyma-project/serverless-manager/releases/latest/download/serverless-operator.yaml kubectl apply -f https://github.com/kyma-project/serverless-manager/releases/latest/download/default-serverless-cr.yaml -n kyma-system make -C ${OPERATOR_ROOT} check-serverless-installation .PHONY: remove-serverless -remove-serverless: +remove-serverless: ## Remove serverless-cr and serverless operator make -C ${OPERATOR_ROOT} remove-serverless undeploy diff --git a/components/operator/Makefile b/components/operator/Makefile index d4038e72a..7987f7835 100644 --- a/components/operator/Makefile +++ b/components/operator/Makefile @@ -15,11 +15,12 @@ SHELL = /usr/bin/env bash -o pipefail .SHELLFLAGS = -ec ##@ Development -CONFIGOPERATOR = $(PROJECT_ROOT)/config/operator +CONFIG_OPERATOR = $(PROJECT_ROOT)/config/operator/base +CONFIG_OPERATOR_DEV = $(PROJECT_ROOT)/config/operator/dev .PHONY: manifests manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) rbac:roleName=operator-role crd webhook paths="./..." output:crd:artifacts:config=$(CONFIGOPERATOR)/crd/bases output:rbac:artifacts:config=$(CONFIGOPERATOR)/rbac + $(CONTROLLER_GEN) rbac:roleName=operator-role crd webhook paths="./..." output:crd:artifacts:config=$(CONFIG_OPERATOR)/crd/bases output:rbac:artifacts:config=$(CONFIG_OPERATOR)/rbac .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. @@ -64,26 +65,37 @@ IGNORE_NOT_FOUND = false .PHONY: install install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build $(CONFIGOPERATOR)/crd | kubectl apply -f - + $(KUSTOMIZE) build $(CONFIG_OPERATOR)/crd | kubectl apply -f - .PHONY: uninstall uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with IGNORE_NOT_FOUND=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build $(CONFIGOPERATOR)/crd | kubectl delete --ignore-not-found=$(IGNORE_NOT_FOUND) -f - + $(KUSTOMIZE) build $(CONFIG_OPERATOR)/crd | kubectl delete --ignore-not-found=$(IGNORE_NOT_FOUND) -f - + +.PHONY: deploy-main +deploy-main: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. + kubectl create namespace kyma-system || true + $(KUSTOMIZE) build $(CONFIG_OPERATOR) | kubectl apply -f - + + +.PHONY: generate-kustomization-dev +generate-kustomization-dev: + cp $(CONFIG_OPERATOR_DEV)/kustomization.yaml.tpl $(CONFIG_OPERATOR_DEV)/kustomization.yaml .PHONY: deploy -deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. +deploy: manifests kustomize generate-kustomization-dev ## Deploy controller to the K8s cluster specified in ~/.kube/config with image from IMG env. kubectl create namespace kyma-system || true - cd $(CONFIGOPERATOR)/operator && $(KUSTOMIZE) edit set image controller=${IMG} - $(KUSTOMIZE) build $(CONFIGOPERATOR)/default | kubectl apply -f - + cd $(CONFIG_OPERATOR_DEV) && $(KUSTOMIZE) edit set image europe-docker.pkg.dev/kyma-project/prod/serverless-operator=${IMG} + $(KUSTOMIZE) build $(CONFIG_OPERATOR_DEV) | kubectl apply -f - -.PHONY: render-manifest -render-manifest: manifests kustomize ## Render serverless-operator.yaml manifest. - cd $(CONFIGOPERATOR)/operator && $(KUSTOMIZE) edit set image controller=${IMG} - $(KUSTOMIZE) build $(CONFIGOPERATOR)/default > $(PROJECT_ROOT)/serverless-operator.yaml .PHONY: undeploy undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with IGNORE_NOT_FOUND=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build $(CONFIGOPERATOR)/default | kubectl delete --ignore-not-found=$(IGNORE_NOT_FOUND) -f - + $(KUSTOMIZE) build $(CONFIG_OPERATOR) | kubectl delete --ignore-not-found=$(IGNORE_NOT_FOUND) -f - + +.PHONY: render-manifest +render-manifest: manifests kustomize ## Render serverless-operator.yaml manifest with image from IMG env. + cd $(CONFIG_OPERATOR)/deployment && $(KUSTOMIZE) edit set image controller=${IMG} + $(KUSTOMIZE) build $(CONFIG_OPERATOR) > $(PROJECT_ROOT)/serverless-operator.yaml .PHONY: apply-default-serverless-cr diff --git a/components/operator/controllers/suite_test.go b/components/operator/controllers/suite_test.go index 170abb969..cc9a01c31 100644 --- a/components/operator/controllers/suite_test.go +++ b/components/operator/controllers/suite_test.go @@ -61,7 +61,7 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{ - filepath.Join("..", "..", "..", "config", "operator", "crd", "bases"), + filepath.Join("..", "..", "..", "config", "operator", "base", "crd", "bases"), }, ErrorIfCRDPathMissing: true, } diff --git a/config/operator/crd/bases/operator.kyma-project.io_serverlesses.yaml b/config/operator/base/crd/bases/operator.kyma-project.io_serverlesses.yaml similarity index 100% rename from config/operator/crd/bases/operator.kyma-project.io_serverlesses.yaml rename to config/operator/base/crd/bases/operator.kyma-project.io_serverlesses.yaml diff --git a/config/operator/crd/kustomization.yaml b/config/operator/base/crd/kustomization.yaml similarity index 100% rename from config/operator/crd/kustomization.yaml rename to config/operator/base/crd/kustomization.yaml diff --git a/config/operator/crd/kustomizeconfig.yaml b/config/operator/base/crd/kustomizeconfig.yaml similarity index 100% rename from config/operator/crd/kustomizeconfig.yaml rename to config/operator/base/crd/kustomizeconfig.yaml diff --git a/config/operator/operator/operator.yaml b/config/operator/base/deployment/deployment.yaml similarity index 100% rename from config/operator/operator/operator.yaml rename to config/operator/base/deployment/deployment.yaml diff --git a/config/operator/base/deployment/kustomization.yaml b/config/operator/base/deployment/kustomization.yaml new file mode 100644 index 000000000..479613aaf --- /dev/null +++ b/config/operator/base/deployment/kustomization.yaml @@ -0,0 +1,8 @@ +resources: +- deployment.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: controller + newName: europe-docker.pkg.dev/kyma-project/prod/serverless-operator + newTag: main diff --git a/config/operator/default/kustomization.yaml b/config/operator/base/kustomization.yaml similarity index 90% rename from config/operator/default/kustomization.yaml rename to config/operator/base/kustomization.yaml index 353291601..ed38c42f5 100644 --- a/config/operator/default/kustomization.yaml +++ b/config/operator/base/kustomization.yaml @@ -14,7 +14,7 @@ commonLabels: resources: -- ../crd -- ../rbac -- ../operator -- ../ui-extensions \ No newline at end of file +- ./crd +- ./deployment +- ./rbac +- ./ui-extensions diff --git a/config/operator/rbac/kustomization.yaml b/config/operator/base/rbac/kustomization.yaml similarity index 100% rename from config/operator/rbac/kustomization.yaml rename to config/operator/base/rbac/kustomization.yaml diff --git a/config/operator/rbac/role.yaml b/config/operator/base/rbac/role.yaml similarity index 100% rename from config/operator/rbac/role.yaml rename to config/operator/base/rbac/role.yaml diff --git a/config/operator/rbac/role_binding.yaml b/config/operator/base/rbac/role_binding.yaml similarity index 100% rename from config/operator/rbac/role_binding.yaml rename to config/operator/base/rbac/role_binding.yaml diff --git a/config/operator/rbac/serverless_editor_role.yaml b/config/operator/base/rbac/serverless_editor_role.yaml similarity index 100% rename from config/operator/rbac/serverless_editor_role.yaml rename to config/operator/base/rbac/serverless_editor_role.yaml diff --git a/config/operator/rbac/serverless_viewer_role.yaml b/config/operator/base/rbac/serverless_viewer_role.yaml similarity index 100% rename from config/operator/rbac/serverless_viewer_role.yaml rename to config/operator/base/rbac/serverless_viewer_role.yaml diff --git a/config/operator/rbac/service_account.yaml b/config/operator/base/rbac/service_account.yaml similarity index 100% rename from config/operator/rbac/service_account.yaml rename to config/operator/base/rbac/service_account.yaml diff --git a/config/operator/ui-extensions/kustomization.yaml b/config/operator/base/ui-extensions/kustomization.yaml similarity index 100% rename from config/operator/ui-extensions/kustomization.yaml rename to config/operator/base/ui-extensions/kustomization.yaml diff --git a/config/operator/ui-extensions/serverless/details b/config/operator/base/ui-extensions/serverless/details similarity index 100% rename from config/operator/ui-extensions/serverless/details rename to config/operator/base/ui-extensions/serverless/details diff --git a/config/operator/ui-extensions/serverless/form b/config/operator/base/ui-extensions/serverless/form similarity index 100% rename from config/operator/ui-extensions/serverless/form rename to config/operator/base/ui-extensions/serverless/form diff --git a/config/operator/ui-extensions/serverless/general b/config/operator/base/ui-extensions/serverless/general similarity index 100% rename from config/operator/ui-extensions/serverless/general rename to config/operator/base/ui-extensions/serverless/general diff --git a/config/operator/ui-extensions/serverless/kustomization.yaml b/config/operator/base/ui-extensions/serverless/kustomization.yaml similarity index 100% rename from config/operator/ui-extensions/serverless/kustomization.yaml rename to config/operator/base/ui-extensions/serverless/kustomization.yaml diff --git a/config/operator/ui-extensions/serverless/list b/config/operator/base/ui-extensions/serverless/list similarity index 100% rename from config/operator/ui-extensions/serverless/list rename to config/operator/base/ui-extensions/serverless/list diff --git a/config/operator/dev/.gitignore b/config/operator/dev/.gitignore new file mode 100644 index 000000000..738a410dc --- /dev/null +++ b/config/operator/dev/.gitignore @@ -0,0 +1 @@ +kustomization.yaml \ No newline at end of file diff --git a/config/operator/dev/kustomization.yaml.tpl b/config/operator/dev/kustomization.yaml.tpl new file mode 100644 index 000000000..f84a747fe --- /dev/null +++ b/config/operator/dev/kustomization.yaml.tpl @@ -0,0 +1,9 @@ +resources: +- ../base +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +# To overwrite image in base it has to point to the image in base kustomization.yaml +images: +- name: europe-docker.pkg.dev/kyma-project/prod/serverless-operator + newName: local-registry + newTag: local diff --git a/config/operator/operator/kustomization.yaml b/config/operator/operator/kustomization.yaml deleted file mode 100644 index c0810f158..000000000 --- a/config/operator/operator/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -resources: -- operator.yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: controller - newName: k3d-kyma-registry:5001/serverless-operator-dev-local - newTag: 0.0.0