Skip to content

Commit 9b41b18

Browse files
authored
Started to support SinkBinding in helm-chart. (#2)
1 parent e204a00 commit 9b41b18

File tree

5 files changed

+72
-7
lines changed

5 files changed

+72
-7
lines changed

helm-chart/eoapi-notifier/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,24 @@ config:
2727
database: postgis
2828
username: postgres
2929
password: password
30+
3031
outputs:
3132
- type: mqtt
3233
config:
3334
broker_host: mqtt-broker
3435
broker_port: 1883
3536

37+
- type: cloudevents
38+
config:
39+
source: /eoapi/pgstac
40+
event_type: org.eoapi.stac.item
41+
destination:
42+
ref:
43+
apiVersion: messaging.knative.dev/v1
44+
kind: Broker
45+
name: my-channel-1
46+
namespace: serverless
47+
3648
secrets:
3749
postgresql:
3850
create: true
@@ -47,3 +59,23 @@ resources:
4759
cpu: 100m
4860
memory: 128Mi
4961
```
62+
63+
## KNative SinkBinding Support
64+
65+
The chart automatically creates KNative SinkBinding resources for CloudEvents outputs, resolving object references to URLs via the `K_SINK` environment variable.
66+
67+
### Configuration
68+
69+
```yaml
70+
outputs:
71+
- type: cloudevents
72+
config:
73+
source: /eoapi/pgstac
74+
event_type: org.eoapi.stac.item
75+
destination:
76+
ref:
77+
apiVersion: messaging.knative.dev/v1
78+
kind: Broker
79+
name: my-broker
80+
namespace: default # optional
81+
```

helm-chart/eoapi-notifier/templates/_helpers.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ Return the proper image pull policy
7373
*/}}
7474
{{- define "eoapi-notifier.imagePullPolicy" -}}
7575
{{- .Values.image.pullPolicy | default "IfNotPresent" }}
76-
{{- end }}
76+
{{- end }}
77+

helm-chart/eoapi-notifier/templates/configmap.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ data:
1919
{{- range .Values.config.outputs}}
2020
- type: {{.type}}
2121
config:
22+
{{- if eq .type "cloudevents"}}
23+
{{- $config := omit .config "destination"}}
24+
{{- toYaml $config | nindent 10}}
25+
{{- else}}
2226
{{- toYaml .config | nindent 10}}
27+
{{- end}}
2328
{{- end}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- range $index, $output := .Values.config.outputs }}
2+
{{- if eq $output.type "cloudevents" }}
3+
---
4+
apiVersion: sources.knative.dev/v1
5+
kind: SinkBinding
6+
metadata:
7+
name: {{ include "eoapi-notifier.fullname" $ }}-cloudevents-{{ $index }}
8+
labels:
9+
{{- include "eoapi-notifier.labels" $ | nindent 4 }}
10+
spec:
11+
subject:
12+
apiVersion: apps/v1
13+
kind: Deployment
14+
name: {{ include "eoapi-notifier.fullname" $ }}
15+
sink:
16+
ref:
17+
apiVersion: {{ $output.config.destination.ref.apiVersion }}
18+
kind: {{ $output.config.destination.ref.kind }}
19+
name: {{ $output.config.destination.ref.name }}
20+
{{- if $output.config.destination.ref.namespace }}
21+
namespace: {{ $output.config.destination.ref.namespace }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}

helm-chart/eoapi-notifier/values.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ config:
5959

6060
- type: cloudevents
6161
config:
62-
# Will be overridden by K_SINK from KNative SinkBinding
63-
endpoint: https://example.com/webhook
64-
source: /eoapi/stac
65-
event_type: org.eoapi.stac
62+
source: /eoapi/pgstac
63+
event_type: org.eoapi.stac.item
64+
destination:
65+
ref:
66+
apiVersion: messaging.knative.dev/v1
67+
kind: Broker
68+
name: my-channel-1
69+
namespace: serverless
6670

6771
# Secrets
6872
secrets:
@@ -91,5 +95,4 @@ env: {}
9195
# CLOUDEVENTS_SOURCE: /eoapi/stac/production
9296
# CLOUDEVENTS_EVENT_TYPE: org.eoapi.stac.item
9397
#
94-
# KNative examples (typically set by SinkBinding):
95-
# K_SINK: https://my-knative-service.default.svc.cluster.local
98+
# KNative SinkBinding automatically sets K_SINK environment variable

0 commit comments

Comments
 (0)