Skip to content

Commit

Permalink
Add dev overlay to operator kustomize (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura authored Feb 27, 2024
1 parent 8f6b33f commit 88a37dd
Show file tree
Hide file tree
Showing 24 changed files with 50 additions and 28 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 24 additions & 12 deletions components/operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/operator/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions config/operator/base/deployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ commonLabels:


resources:
- ../crd
- ../rbac
- ../operator
- ../ui-extensions
- ./crd
- ./deployment
- ./rbac
- ./ui-extensions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions config/operator/dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kustomization.yaml
9 changes: 9 additions & 0 deletions config/operator/dev/kustomization.yaml.tpl
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions config/operator/operator/kustomization.yaml

This file was deleted.

0 comments on commit 88a37dd

Please sign in to comment.