diff --git a/helm-chart/eoapi-notifier/README.md b/helm-chart/eoapi-notifier/README.md index 59aa5cd..afb1157 100644 --- a/helm-chart/eoapi-notifier/README.md +++ b/helm-chart/eoapi-notifier/README.md @@ -27,12 +27,24 @@ config: database: postgis username: postgres password: password + outputs: - type: mqtt config: broker_host: mqtt-broker broker_port: 1883 + - type: cloudevents + config: + source: /eoapi/pgstac + event_type: org.eoapi.stac.item + destination: + ref: + apiVersion: messaging.knative.dev/v1 + kind: Broker + name: my-channel-1 + namespace: serverless + secrets: postgresql: create: true @@ -47,3 +59,23 @@ resources: cpu: 100m memory: 128Mi ``` + +## KNative SinkBinding Support + +The chart automatically creates KNative SinkBinding resources for CloudEvents outputs, resolving object references to URLs via the `K_SINK` environment variable. + +### Configuration + +```yaml +outputs: + - type: cloudevents + config: + source: /eoapi/pgstac + event_type: org.eoapi.stac.item + destination: + ref: + apiVersion: messaging.knative.dev/v1 + kind: Broker + name: my-broker + namespace: default # optional +``` diff --git a/helm-chart/eoapi-notifier/templates/_helpers.tpl b/helm-chart/eoapi-notifier/templates/_helpers.tpl index d8d65eb..bf09fea 100644 --- a/helm-chart/eoapi-notifier/templates/_helpers.tpl +++ b/helm-chart/eoapi-notifier/templates/_helpers.tpl @@ -73,4 +73,5 @@ Return the proper image pull policy */}} {{- define "eoapi-notifier.imagePullPolicy" -}} {{- .Values.image.pullPolicy | default "IfNotPresent" }} -{{- end }} \ No newline at end of file +{{- end }} + diff --git a/helm-chart/eoapi-notifier/templates/configmap.yaml b/helm-chart/eoapi-notifier/templates/configmap.yaml index f05c8a3..8ef2428 100644 --- a/helm-chart/eoapi-notifier/templates/configmap.yaml +++ b/helm-chart/eoapi-notifier/templates/configmap.yaml @@ -19,5 +19,10 @@ data: {{- range .Values.config.outputs}} - type: {{.type}} config: + {{- if eq .type "cloudevents"}} + {{- $config := omit .config "destination"}} + {{- toYaml $config | nindent 10}} + {{- else}} {{- toYaml .config | nindent 10}} + {{- end}} {{- end}} diff --git a/helm-chart/eoapi-notifier/templates/sinkbinding.yaml b/helm-chart/eoapi-notifier/templates/sinkbinding.yaml new file mode 100644 index 0000000..deeb0b2 --- /dev/null +++ b/helm-chart/eoapi-notifier/templates/sinkbinding.yaml @@ -0,0 +1,24 @@ +{{- range $index, $output := .Values.config.outputs }} +{{- if eq $output.type "cloudevents" }} +--- +apiVersion: sources.knative.dev/v1 +kind: SinkBinding +metadata: + name: {{ include "eoapi-notifier.fullname" $ }}-cloudevents-{{ $index }} + labels: + {{- include "eoapi-notifier.labels" $ | nindent 4 }} +spec: + subject: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "eoapi-notifier.fullname" $ }} + sink: + ref: + apiVersion: {{ $output.config.destination.ref.apiVersion }} + kind: {{ $output.config.destination.ref.kind }} + name: {{ $output.config.destination.ref.name }} + {{- if $output.config.destination.ref.namespace }} + namespace: {{ $output.config.destination.ref.namespace }} + {{- end }} +{{- end }} +{{- end }} diff --git a/helm-chart/eoapi-notifier/values.yaml b/helm-chart/eoapi-notifier/values.yaml index e10da8b..3a135b6 100644 --- a/helm-chart/eoapi-notifier/values.yaml +++ b/helm-chart/eoapi-notifier/values.yaml @@ -59,10 +59,14 @@ config: - type: cloudevents config: - # Will be overridden by K_SINK from KNative SinkBinding - endpoint: https://example.com/webhook - source: /eoapi/stac - event_type: org.eoapi.stac + source: /eoapi/pgstac + event_type: org.eoapi.stac.item + destination: + ref: + apiVersion: messaging.knative.dev/v1 + kind: Broker + name: my-channel-1 + namespace: serverless # Secrets secrets: @@ -91,5 +95,4 @@ env: {} # CLOUDEVENTS_SOURCE: /eoapi/stac/production # CLOUDEVENTS_EVENT_TYPE: org.eoapi.stac.item # - # KNative examples (typically set by SinkBinding): - # K_SINK: https://my-knative-service.default.svc.cluster.local + # KNative SinkBinding automatically sets K_SINK environment variable