Skip to content

Commit c84a6f0

Browse files
committed
Moved pgstac secrets to proper values section.
1 parent 891807f commit c84a6f0

File tree

7 files changed

+133
-99
lines changed

7 files changed

+133
-99
lines changed

helm-chart/eoapi-notifier/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ helm install eoapi-notifier oci://ghcr.io/developmentseed/charts/eoapi-notifier
2020
```yaml
2121
config:
2222
sources:
23-
- type: postgres
23+
- type: pgstac
2424
config:
25-
host: postgresql
26-
port: 5432
27-
database: postgis
28-
username: postgres
29-
password: password
25+
connection:
26+
existingSecret:
27+
name: "postgresql-credentials"
28+
keys:
29+
username: "user"
30+
password: "password"
31+
host: "host"
32+
port: "port"
33+
database: "dbname"
3034

3135
outputs:
3236
- type: mqtt
@@ -45,11 +49,8 @@ config:
4549
name: my-channel-1
4650
namespace: serverless
4751

48-
secrets:
49-
postgresql:
50-
create: true
51-
username: postgres
52-
password: password
52+
# Connection credentials should be provided via existing Kubernetes secrets
53+
# Referenced in sources[].config.connection.existingSecret
5354

5455
resources:
5556
limits:

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ data:
1212
{{- range .Values.config.sources}}
1313
- type: {{.type}}
1414
config:
15+
{{- if eq .type "pgstac"}}
16+
# Connection details provided via environment variables
17+
host: localhost
18+
port: 5432
19+
database: postgis
20+
user: postgres
21+
password: password
22+
{{- else}}
1523
{{- toYaml .config | nindent 10}}
24+
{{- end}}
1625
{{- end}}
1726
1827
outputs:

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

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ spec:
1313
metadata:
1414
annotations:
1515
checksum/config: {{include (print $.Template.BasePath "/configmap.yaml") . | sha256sum}}
16-
checksum/secret: {{include (print $.Template.BasePath "/secret-postgresql.yaml") . | sha256sum}}
16+
1717
labels:
1818
{{- include "eoapi-notifier.selectorLabels" . | nindent 8}}
1919
spec:
@@ -38,17 +38,35 @@ spec:
3838
env:
3939
- name: UV_CACHE_DIR
4040
value: "/tmp"
41-
{{- if .Values.secrets.postgresql.create }}
42-
- name: POSTGRES_USERNAME
41+
{{- range $source := .Values.config.sources }}
42+
{{- if and (eq $source.type "pgstac") $source.config.connection.existingSecret.name }}
43+
{{- $secret := $source.config.connection.existingSecret }}
44+
- name: PGSTAC_HOST
45+
valueFrom:
46+
secretKeyRef:
47+
name: {{ $secret.name }}
48+
key: {{ $secret.keys.host }}
49+
- name: PGSTAC_PORT
50+
valueFrom:
51+
secretKeyRef:
52+
name: {{ $secret.name }}
53+
key: {{ $secret.keys.port }}
54+
- name: PGSTAC_DATABASE
55+
valueFrom:
56+
secretKeyRef:
57+
name: {{ $secret.name }}
58+
key: {{ $secret.keys.database }}
59+
- name: PGSTAC_USER
4360
valueFrom:
4461
secretKeyRef:
45-
name: {{ include "eoapi-notifier.fullname" . }}-postgresql
46-
key: username
47-
- name: POSTGRES_PASSWORD
62+
name: {{ $secret.name }}
63+
key: {{ $secret.keys.username }}
64+
- name: PGSTAC_PASSWORD
4865
valueFrom:
4966
secretKeyRef:
50-
name: {{ include "eoapi-notifier.fullname" . }}-postgresql
51-
key: password
67+
name: {{ $secret.name }}
68+
key: {{ $secret.keys.password }}
69+
{{- end }}
5270
{{- end }}
5371
{{- range $key, $value := .Values.env }}
5472
- name: {{ $key }}

helm-chart/eoapi-notifier/templates/secret-postgresql.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

helm-chart/eoapi-notifier/templates/tests/app-test.yaml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ spec:
4545
fi
4646
echo "✅ Config file accessible"
4747
48-
# Test environment variables are set
49-
if [ -z "$POSTGRES_USERNAME" ] || [ -z "$POSTGRES_PASSWORD" ]; then
50-
echo "❌ Database credentials not available"
51-
exit 1
48+
# Test environment variables are set (if secret is configured)
49+
if [ -n "$PGSTAC_USER" ] && [ -n "$PGSTAC_PASSWORD" ]; then
50+
echo "✅ Database credentials available"
51+
else
52+
echo "⚠️ Database credentials not configured (this may be expected)"
5253
fi
53-
echo "✅ Environment variables set"
5454
5555
# Test app starts (will fail to connect but shouldn't crash)
5656
echo "Testing app startup..."
@@ -60,16 +60,36 @@ spec:
6060
6161
echo "✅ Application functionality test passed"
6262
env:
63-
- name: POSTGRES_USERNAME
63+
{{- range $source := .Values.config.sources }}
64+
{{- if and (eq $source.type "pgstac") $source.config.connection.existingSecret.name }}
65+
{{- $secret := $source.config.connection.existingSecret }}
66+
- name: PGSTAC_HOST
67+
valueFrom:
68+
secretKeyRef:
69+
name: {{ $secret.name }}
70+
key: {{ $secret.keys.host }}
71+
- name: PGSTAC_PORT
72+
valueFrom:
73+
secretKeyRef:
74+
name: {{ $secret.name }}
75+
key: {{ $secret.keys.port }}
76+
- name: PGSTAC_DATABASE
77+
valueFrom:
78+
secretKeyRef:
79+
name: {{ $secret.name }}
80+
key: {{ $secret.keys.database }}
81+
- name: PGSTAC_USER
6482
valueFrom:
6583
secretKeyRef:
66-
name: {{ include "eoapi-notifier.fullname" . }}-postgresql
67-
key: username
68-
- name: POSTGRES_PASSWORD
84+
name: {{ $secret.name }}
85+
key: {{ $secret.keys.username }}
86+
- name: PGSTAC_PASSWORD
6987
valueFrom:
7088
secretKeyRef:
71-
name: {{ include "eoapi-notifier.fullname" . }}-postgresql
72-
key: password
89+
name: {{ $secret.name }}
90+
key: {{ $secret.keys.password }}
91+
{{- end }}
92+
{{- end }}
7393
- name: UV_CACHE_DIR
7494
value: "/tmp"
7595
volumeMounts:

helm-chart/eoapi-notifier/templates/tests/config-test.yaml

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,49 @@ spec:
4141
fi
4242
echo "✅ Outputs section found"
4343
44-
# Test that environment variables from secret are available
45-
if [ -z "$POSTGRES_USERNAME" ]; then
46-
echo "❌ POSTGRES_USERNAME not set"
47-
exit 1
48-
fi
49-
echo "✅ PostgreSQL username available"
50-
51-
if [ -z "$POSTGRES_PASSWORD" ]; then
52-
echo "❌ POSTGRES_PASSWORD not set"
53-
exit 1
54-
fi
55-
echo "✅ PostgreSQL password available"
56-
57-
# Test that environment variables work (they should override config)
58-
echo "Testing environment variable override capability..."
59-
if [ "$POSTGRES_USERNAME" != "postgres" ] || [ "$POSTGRES_PASSWORD" != "password" ]; then
44+
# Test that environment variables from secret are available (if configured)
45+
if [ -n "$PGSTAC_USER" ] && [ -n "$PGSTAC_PASSWORD" ]; then
46+
echo "✅ PostgreSQL credentials available via environment variables"
6047
echo "✅ Environment variables are being used for secrets"
6148
else
62-
echo "⚠️ Using default values (this may be expected in some environments)"
49+
echo "⚠️ PostgreSQL credentials not configured via environment (this may be expected)"
6350
fi
6451
6552
# Test config file format
6653
cat /app/config/config.yaml | head -20
6754
6855
echo "✅ Configuration test passed"
6956
env:
70-
- name: POSTGRES_USERNAME
57+
{{- range $source := .Values.config.sources }}
58+
{{- if and (eq $source.type "pgstac") $source.config.connection.existingSecret.name }}
59+
{{- $secret := $source.config.connection.existingSecret }}
60+
- name: PGSTAC_HOST
61+
valueFrom:
62+
secretKeyRef:
63+
name: {{ $secret.name }}
64+
key: {{ $secret.keys.host }}
65+
- name: PGSTAC_PORT
66+
valueFrom:
67+
secretKeyRef:
68+
name: {{ $secret.name }}
69+
key: {{ $secret.keys.port }}
70+
- name: PGSTAC_DATABASE
71+
valueFrom:
72+
secretKeyRef:
73+
name: {{ $secret.name }}
74+
key: {{ $secret.keys.database }}
75+
- name: PGSTAC_USER
7176
valueFrom:
7277
secretKeyRef:
73-
name: {{ include "eoapi-notifier.fullname" . }}-postgresql
74-
key: username
75-
- name: POSTGRES_PASSWORD
78+
name: {{ $secret.name }}
79+
key: {{ $secret.keys.username }}
80+
- name: PGSTAC_PASSWORD
7681
valueFrom:
7782
secretKeyRef:
78-
name: {{ include "eoapi-notifier.fullname" . }}-postgresql
79-
key: password
83+
name: {{ $secret.name }}
84+
key: {{ $secret.keys.password }}
85+
{{- end }}
86+
{{- end }}
8087
volumeMounts:
8188
- name: config
8289
mountPath: /app/config

helm-chart/eoapi-notifier/values.yaml

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,58 +42,49 @@ affinity: {}
4242
# Application configuration
4343
config:
4444
logLevel: INFO
45+
46+
# Sources: Define where notifications come from
4547
sources:
46-
- type: postgres
48+
- type: pgstac
4749
config:
48-
host: postgresql
49-
port: 5432
50-
database: postgis
51-
username: postgres
52-
password: password
50+
# Database connection from existing Kubernetes secret
51+
connection:
52+
existingSecret:
53+
name: ""
54+
keys:
55+
username: "user"
56+
password: "password"
57+
host: "host"
58+
port: "port"
59+
database: "dbname"
60+
# Optional pgSTAC settings:
61+
# tables: ["items", "collections"]
62+
# min_connections: 1
63+
# max_connections: 10
64+
# enable_correlation: true
5365

66+
# Outputs: Define where notifications are sent
5467
outputs:
5568
- type: mqtt
5669
config:
5770
broker_host: mqtt-broker
5871
broker_port: 1883
72+
# Optional: username, password, use_tls, topic, qos
5973

6074
- type: cloudevents
6175
config:
6276
source: /eoapi/pgstac
6377
event_type: org.eoapi.stac.item
78+
# For KNative SinkBinding:
6479
destination:
6580
ref:
6681
apiVersion: messaging.knative.dev/v1
6782
kind: Broker
6883
name: my-channel-1
6984
namespace: serverless
85+
# For HTTP endpoints, use: endpoint: https://webhook.example.com
7086

71-
# Secrets
72-
secrets:
73-
postgresql:
74-
create: true
75-
username: postgres
76-
password: password
77-
78-
# Environment variables
79-
# These will be injected as environment variables and automatically override config values
80-
# Use plugin-prefixed variables: PGSTAC_PASSWORD, MQTT_USERNAME, CLOUDEVENTS_ENDPOINT, etc
81-
#
82-
# KNative Support:
83-
# The cloudevents plugin supports K_SINK variables for KNative SinkBinding:
84-
# - K_SINK: Overrides CLOUDEVENTS_ENDPOINT (automatically set by SinkBinding)
85-
# - K_CE_OVERRIDE: A JSON object that specifies overrides to the outbound event.
87+
# Environment variables override config values with plugin prefixes
88+
# Examples: PGSTAC_PASSWORD, MQTT_USERNAME, CLOUDEVENTS_ENDPOINT
89+
# KNative: K_SINK automatically overrides CLOUDEVENTS_ENDPOINT
8690
env: {}
87-
# Examples - Standard environment variables:
88-
# PGSTAC_HOST: postgresql-service
89-
# PGSTAC_PORT: "5432"
90-
# PGSTAC_PASSWORD: secret-password
91-
# MQTT_BROKER_HOST: mqtt-broker-service
92-
# MQTT_USE_TLS: "true"
93-
#
94-
# CloudEvents examples:
95-
# CLOUDEVENTS_ENDPOINT: https://my-webhook-url
96-
# CLOUDEVENTS_SOURCE: /eoapi/stac/production
97-
# CLOUDEVENTS_EVENT_TYPE: org.eoapi.stac.item
98-
#
99-
# KNative SinkBinding automatically sets K_SINK environment variable

0 commit comments

Comments
 (0)