diff --git a/Makefile b/Makefile index dab69a58a..f5b328ecf 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,7 @@ install-serverless-latest-release: ## Install serverless from latest release remove-serverless: ## Remove serverless-cr and serverless operator make -C ${OPERATOR_ROOT} remove-serverless undeploy -.PHONY: run -run: create-k3d install-serverless-main ## Create k3d cluster and install serverless from main +.PHONY: run-main +run-main: create-k3d install-serverless-main ## Create k3d cluster and install serverless from main check-var = $(if $(strip $($1)),,$(error "$1" is not defined)) - diff --git a/README.md b/README.md index 08003a5f7..934b57ca5 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,12 @@ kubectl apply -f https://github.com/kyma-project/serverless-manager/releases/lat 2. Build Serverless Operator locally and run it in the k3d cluster. ```bash - make run + make run-main ``` > **NOTE:** To clean up the k3d cluster, use the `make delete-k3d` make target. +> **NOTE:** If you have k3d already running you can use `install-*` target to install serverless in different flavours. ## Using Serverless Operator diff --git a/components/operator/README.md b/components/operator/README.md index d12435928..a96617634 100644 --- a/components/operator/README.md +++ b/components/operator/README.md @@ -8,7 +8,21 @@ The Function Operator requires the following components to be installed: ## Development -### Run/Debug local sources locally +### Installing locally build serverless operator image on k3d with serverless + +To install serverless-manager from local sources on k3d cluster run: +```bash +make install-operator-k3d +``` + +This target does: +- build local image with serverless-operator +- tag local serverless-operator image with its hash to be sure to deployment be updated +- upload local image to k3d +- update image in serverless-operator deployment + +### Running/Debugging serverless-operator locally +To develop the component as normal binary, set up environment variables. ### Environment Variables @@ -16,4 +30,4 @@ The Function Operator requires the following components to be installed: | Variable | Description | Default value | |----------------------------------|------------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **CHART_PATH** | Location of serverless chart | `/module-chart` | +| **CHART_PATH** | Location of serverless chart | `/module-chart` | diff --git a/components/serverless/Makefile b/components/serverless/Makefile index 8543bcdc5..ae0ba44bf 100644 --- a/components/serverless/Makefile +++ b/components/serverless/Makefile @@ -36,19 +36,19 @@ manifests: kustomize controller-gen ## Render CRDs install: manifests ## Install CRDS into the k8s cluster specified in ~/.kube/config kubectl apply -f ../../config/serverless/templates/crds.yaml -######## function manager -MANAGER_NAME = function-controller +######## function controller +CONTROLLER_NAME = function-controller .PHONY: build-image-function-controller build-image-function-controller: - docker build -t $(MANAGER_NAME) -f $(COMPONENT_ROOT)/deploy/manager/Dockerfile $(PROJECT_ROOT) + docker build -t $(CONTROLLER_NAME) -f $(COMPONENT_ROOT)/deploy/manager/Dockerfile $(PROJECT_ROOT) -install-manager-k3d: build-image-function-controller disable-operator ## Build and install serverless manager from local sources on k3d - $(eval HASH_TAG=$(shell docker images $(MANAGER_NAME):latest --quiet)) - docker tag $(MANAGER_NAME) $(MANAGER_NAME):$(HASH_TAG) +install-controller-k3d: build-image-function-controller disable-operator ## Build and install serverless manager from local sources on k3d + $(eval HASH_TAG=$(shell docker images $(CONTROLLER_NAME):latest --quiet)) + docker tag $(CONTROLLER_NAME) $(CONTROLLER_NAME):$(HASH_TAG) - k3d image import $(MANAGER_NAME):$(HASH_TAG) -c kyma - kubectl set image deployment serverless-ctrl-mngr -n kyma-system manager=$(MANAGER_NAME):$(HASH_TAG) + k3d image import $(CONTROLLER_NAME):$(HASH_TAG) -c kyma + kubectl set image deployment serverless-ctrl-mngr -n kyma-system manager=$(CONTROLLER_NAME):$(HASH_TAG) ######## function webhook WEBHOOK_NAME = function-webhook diff --git a/components/serverless/README.md b/components/serverless/README.md index b34dc33b4..111033faf 100644 --- a/components/serverless/README.md +++ b/components/serverless/README.md @@ -5,9 +5,7 @@ The Function Controller is a Kubernetes controller that enables Kyma to manage F ## Prerequisites The Function Controller requires the following components to be installed: - -- [Istio](https://github.com/istio/istio/releases) (v1.4.3) -- [Docker registry](https://github.com/docker/distribution) (v2.7.1) +- [Go](https://go.dev/) ## Development @@ -16,11 +14,23 @@ To develop the Function Controller, you need: - [controller-gen](https://github.com/kubernetes-sigs/controller-tools/releases/tag/v0.6.2) (v0.6.2) - [kustomize](https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize%2Fv4.5.7) (v4.5.7) -To develop the component, use the formulae declared in the [Makefile](./Makefile). +### Installing locally build serverless controller image on k3d with serverless + +To install serverless-manager from local sources on k3d cluster run: +```bash +make install-controller-k3d +``` -To run the manager and set up envs correctly, source [controller.env](./hack/controller.env). -You can customize the configuration by editing files in [hack](./hack) dir. +This target does: +- scale down serverless operator to prevent reverting further changes made to serverless-controller deployment +- build local image with serverless-controller image +- tag local serverless-controller image with its hash to be sure to deployment be updated +- upload local image to k3d +- update image in serverless-ctrl-mngr deployment +### Running/Debugging serverless-manager locally +To develop the component as normal binary, set up envs correctly, example envs to use [controller.env](./hack/controller.env). +You can customize the configuration by editing files in [hack](./hack) dir. ### Environment Variables diff --git a/hack/makefile-strategy.md b/hack/makefile-strategy.md index 4560b4d02..943f3343b 100644 --- a/hack/makefile-strategy.md +++ b/hack/makefile-strategy.md @@ -9,7 +9,7 @@ Pros of the architecture: * extensibility ## Dependencies description -* `Makefile` - The main makefile that allows for installing and running the Serverless Operator. It's a high-level target to run the module without knowing its internals. It's the first contact point for the Serverless module users. +* `Makefile` - The main makefile that allows for installing and running the Serverless. It's a high-level target to run the module without knowing its internals. It's the first contact point for the Serverless module users. * `hack/Makefile` - High-level API that contains all targets that may be used by any CI/CD system. It has dependencies on the `hack/*.mk` makefiles. * `hack/*.mk` - Contains common targets that may be used by other makefiles (they are included and shouldn't be run directly). Targets are grouped by functionality. They should contain helpers' targets. * `components/operator/Makefile` - Contains all basic operations on Serverless Operator like builds, tests, etc., used during development. It's also used by `Makefile`. @@ -37,4 +37,4 @@ include ${PROJECT_ROOT}/hack/help.mk .PHONY: run run: create-k3d install-serverless-main ## Create k3d cluster and install serverless from main -``` \ No newline at end of file +```