Skip to content

Commit

Permalink
Code cleanup (#399)
Browse files Browse the repository at this point in the history
* rename variables

* rename make target

The name `install-nats-module` is a little misleading, since this target does not work with modules, but with the CR and CRD of the NATS-manager.

* remove unused make targets

A lot of make targets have become obsolete since a release of eventing-manager or nats-manger does no longer generate a module-template. For that reason, all targets that work with modules can be removed.

* remove module specific secitons in the readme

* revert changes for make target name

* make  variables to consts
  • Loading branch information
friedrichwilken authored Jan 16, 2024
1 parent 44ff053 commit fe8baf4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 137 deletions.
1 change: 0 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ jobs:
run: |
make -C hack/ci/ install-k3d-tools
- name: Install Kyma CLI & setup k3d cluster using kyma CLI
run: |
make kyma
Expand Down
71 changes: 0 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,77 +168,6 @@ To delete the CRDs from the cluster:
make uninstall
```

### Deploy Eventing Manager Module With [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main)

1. Deploy the Lifecycle Manager to the Kubernetes cluster:

```shell
kyma alpha deploy
```

2. Apply the Eventing module template to the Kubernetes cluster:

> **NOTE:** You can get the latest released [module template](https://github.com/kyma-project/eventing-manager/releases/latest/download/module-template.yaml), or you can use the module template from the artifacts of `eventing-module-build` job either from the `main` branch or from your pull request.
```sh
kubectl apply -f module-template.yaml
```

3. Enable the Eventing module:

```sh
kyma alpha enable module eventing -c fast -n kyma-system
```

4. If you want to verify whether your Eventing module is deployed properly, perform the following checks:

- Check if the Eventing resource has the `ready` state:

```shell
kubectl get -n kyma-system eventing
```

- Check if the Kyma resource has the ready state:

```shell
kubectl get -n kyma-system kyma
```

### Uninstall Eventing Manager Module With [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main)

1. Delete Eventing custom resource (CR) from the Kubernetes cluster (if exists):

```sh
kubectl delete -n kyma-system eventing eventing
```

2. Disable the Eventing module:

```sh
kyma alpha disable module eventing
```

3. Delete the Eventing module template:

```sh
kubectl get moduletemplates -A
kubectl delete moduletemplate -n <NAMESPACE> <NAME>
```

4. Check whether your Eventing module is uninstalled properly:

- Make sure that the Eventing CR does not exist. If it exists, check its status:

```shell
kubectl get -n kyma-system eventing eventing -o yaml
```

- Check if the Kyma resource has the `ready` state:

```shell
kubectl get -n kyma-system kyma
```

## End-to-End Tests

See [hack/e2e/README.md](hack/e2e/README.md)
Expand Down
61 changes: 0 additions & 61 deletions hack/ci/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,14 @@ KYMA_CLI ?= "${PROJECT_ROOT}/${KYMA}"
CLUSTER_NAME ?= kyma
REGISTRY_PORT ?= 5001

ifndef MODULE_VERSION
include ${PROJECT_ROOT}/.version
endif

ifndef MODULE_SHA
MODULE_SHA = ${shell git rev-parse --short HEAD}
endif

.PHONY: module-build
module-build: ## Build the Module, push it to a registry and print it based on the commit hash.
@make -C ${PROJECT_ROOT} module-build \
IMG=${IMG} \
MODULE_REGISTRY=${MODULE_REGISTRY} \
MODULE_VERSION=${MODULE_VERSION}-${MODULE_SHA}
cp -f ${PROJECT_ROOT}/module-template.yaml ${ARTIFACTS}/module-template.yaml
@echo "Added template to job artifacts: ${ARTIFACTS}/module-template.yaml"
@echo "\n~~~~~~~~~~~~BEGINNING OF MODULE TEMPLATE~~~~~~~~~~~~~~"
@cat ${ARTIFACTS}/module-template.yaml
@echo "\n~~~~~~~~~~~~~~~END OF MODULE TEMPLATE~~~~~~~~~~~~~~~~"

.PHONY: download-module-template
download-module-template: ## Downloads the module-template from the module-build prow job.
export PROJECT_ROOT="${PROJECT_ROOT}" \
&& ../get_module_template_from_build_job.sh

.PHONY: install-latest-module-template-fast
install-latest-module-template-fast: ## Downloads and applies the latest released module-template from fast channel.
kubectl apply -f https://github.com/kyma-project/eventing-manager/releases/latest/download/module-template.yaml

.PHONY: create-kyma-system-ns
create-kyma-system-ns: ## Create kyma-system namespace.
kubectl create ns kyma-system

.PHONY: install-module-template
install-module-template: ## Apply Eventing moduletemplate.
kubectl apply -f ${PROJECT_ROOT}/module-template.yaml

.PHONY: enable-module-without-default-cr
enable-module-without-default-cr: ## Enable Eventing module without creating default Eventing CR.
"${KYMA_CLI}" alpha enable module eventing -c fast -n kyma-system -p Ignore

.PHONY: install-lifecycle-manager
install-lifecycle-manager: ## Deploys lifecycle-manager.
"${KYMA_CLI}" alpha deploy \
--ci \
--force-conflicts

.PHONY: create-k3d
create-k3d: ## Create k3d with kyma CRDs.
"${KYMA_CLI}" provision k3d -p 8081:80@loadbalancer -p 8443:443@loadbalancer --registry-port ${REGISTRY_PORT} --name ${CLUSTER_NAME} --ci

.PHONY: install-lifecycle-manager
install-lifecycle-manager: ## Deploys lifecycle-manager.
"${KYMA_CLI}" alpha deploy \
--ci \
--force-conflicts

.PHONY: install-latest-nats-module-template-fast
install-latest-nats-module-template-fast: ## Downloads and applies the latest nats-manager released module-template from fast channel.
kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/module-template.yaml

.PHONY: enable-nats-module
enable-nats-module:
"${KYMA_CLI}" alpha enable module nats -c fast -f --ci -n kyma-system

.PHONY: get-nats-via-lifecycle-manager
get-nats-via-lifecycle-manager: install-lifecycle-manager install-latest-nats-module-template-fast enable-nats-module
./check-k8s-resource-is-ready.sh 180 nats kyma-system

.PHONY: install-nats-module
install-nats-module:
$(eval LATEST_NATS_VERSION := $(shell curl -s https://api.github.com/repos/kyma-project/nats-manager/releases/latest | jq -r '.tag_name'))
Expand Down
9 changes: 5 additions & 4 deletions testing/eventmeshmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
const (
TokenURLPath = "/auth"
MessagingURLPath = "/messaging"

fewAttempts = 2
smallInterval = 3
)

// EventMeshMock implements a programmable mock for EventMesh.
Expand Down Expand Up @@ -210,10 +213,8 @@ func (m *EventMeshMock) handleMessaging() func(w http.ResponseWriter, r *http.Re
if err == nil {
break
}
two := 2
three := 3
if i < two { // Don't sleep after the last attempt
time.Sleep(time.Duration(three) * time.Second)
if i < fewAttempts { // Don't sleep after the last attempt.
time.Sleep(time.Duration(smallInterval) * time.Second)
} else {
m.log.Error(err, "failed to update state response")
w.WriteHeader(http.StatusBadRequest)
Expand Down

0 comments on commit fe8baf4

Please sign in to comment.