From ceceb92400ca392137e74ea22c2d90539f571c22 Mon Sep 17 00:00:00 2001 From: Mikhail Klimko Date: Thu, 17 Jul 2025 13:57:40 +0300 Subject: [PATCH 1/2] feat: jetstream eventbus --- .../templates/eventbus/codefresh-eventbus.yaml | 15 +++++++++++++-- charts/gitops-runtime/values.yaml | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml b/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml index 571e578e..d9957b19 100644 --- a/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml +++ b/charts/gitops-runtime/templates/eventbus/codefresh-eventbus.yaml @@ -1,5 +1,6 @@ {{- $eventBusName := default "codefresh-eventbus" .Values.global.runtime.eventBus.name }} {{- $eventBusSpec := .Values.global.runtime.eventBus }} +{{- $eventBusType := .Values.global.runtime.eventBus.type }} {{/* Remove name from eventbus spec */}} {{- if hasKey $eventBusSpec "name" }} {{- $eventBusSpec = unset $eventBusSpec "name" }} @@ -8,12 +9,22 @@ {{- if hasKey $eventBusSpec "pdb" }} {{- $eventBusSpec = unset $eventBusSpec "pdb" }} {{- end }} +{{/* Remove annotations from eventbus spec */}} {{- if hasKey $eventBusSpec "annotations" }} {{- $eventBusSpec = unset $eventBusSpec "annotations" }} {{- end }} -{{- $_ := set $eventBusSpec.nats.native "nodeSelector" ($eventBusSpec.nats.native.nodeSelector | default .Values.global.nodeSelector) }} -{{- $_ := set $eventBusSpec.nats.native "tolerations" ($eventBusSpec.nats.native.tolerations | default .Values.global.tolerations) }} +{{- if eq $eventBusType "nats" }} + {{- $eventBusSpec = unset $eventBusSpec "jetstream" }} + {{- $_ := set $eventBusSpec.nats.native "nodeSelector" ($eventBusSpec.nats.native.nodeSelector | default .Values.global.nodeSelector) }} + {{- $_ := set $eventBusSpec.nats.native "tolerations" ($eventBusSpec.nats.native.tolerations | default .Values.global.tolerations) }} +{{- end }} + +{{- if eq $eventBusType "jetstream" }} + {{- $eventBusSpec = unset $eventBusSpec "nats" }} + {{- $_ := set $eventBusSpec.jetstream "nodeSelector" ($eventBusSpec.jetstream.nodeSelector | default .Values.global.nodeSelector) }} + {{- $_ := set $eventBusSpec.jetstream "tolerations" ($eventBusSpec.jetstream.tolerations | default .Values.global.tolerations) }} +{{- end }} apiVersion: argoproj.io/v1alpha1 kind: EventBus diff --git a/charts/gitops-runtime/values.yaml b/charts/gitops-runtime/values.yaml index 7e709660..68a9984c 100644 --- a/charts/gitops-runtime/values.yaml +++ b/charts/gitops-runtime/values.yaml @@ -93,6 +93,7 @@ global: enabled: true # -- Minimum number of available eventbus pods. For eventbus to stay functional the majority of its replicas should always be available. minAvailable: 2 + type: nats # -- Eventbus type. Can be nats or jetstream. nats: native: nodeSelector: {} @@ -111,6 +112,23 @@ global: cpu: 200m memory: 1Gi ephemeral-storage: 2Gi + jetstream: + version: latest + nodeSelector: {} + tolerations: [] + affinity: {} + replicas: 3 + maxPayload: "4MB" + containerTemplate: + resources: + limits: + cpu: 500m + memory: 4Gi + ephemeral-storage: 2Gi + requests: + cpu: 200m + memory: 1Gi + ephemeral-storage: 2Gi # -- Configuration for external ArgoCD # Should be used when `argo-cd.enabled` is set to false From ddd7d7ed3bd6dcae4be92b20feabc7c354bc2150 Mon Sep 17 00:00:00 2001 From: Mikhail Klimko Date: Thu, 17 Jul 2025 15:54:18 +0300 Subject: [PATCH 2/2] add tests --- .../gitops-runtime/tests/eventbus_test.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 charts/gitops-runtime/tests/eventbus_test.yaml diff --git a/charts/gitops-runtime/tests/eventbus_test.yaml b/charts/gitops-runtime/tests/eventbus_test.yaml new file mode 100644 index 00000000..f15c6462 --- /dev/null +++ b/charts/gitops-runtime/tests/eventbus_test.yaml @@ -0,0 +1,28 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json +suite: eventbus tests +templates: + - eventbus/codefresh-eventbus.yaml +tests: + - it: Should create an EventBus with the correct type (nats) + template: eventbus/codefresh-eventbus.yaml + values: + - ./values/mandatory-values.yaml + set: + global.runtime.eventBus.type: nats + asserts: + - exists: + path: spec.nats + - notExists: + path: spec.jetstream + + - it: Should create an EventBus with the correct type (jetstream) + template: eventbus/codefresh-eventbus.yaml + values: + - ./values/mandatory-values.yaml + set: + global.runtime.eventBus.type: jetstream + asserts: + - exists: + path: spec.jetstream + - notExists: + path: spec.nats