Skip to content

Commit 0135ec1

Browse files
committed
feat: add Knative integration for notifications
- Add CloudEvents sink deployment for eoapi-notifier integration - Configure dynamic secret name for PostgreSQL connection - Add local development configuration with reduced resources - Support both CI and local test environments
1 parent 6e471e4 commit 0135ec1

File tree

15 files changed

+1278
-898
lines changed

15 files changed

+1278
-898
lines changed

.github/workflows/helm-tests.yml

Lines changed: 36 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
- name: Run Helm unit tests
2626
run: make tests
2727

28-
integration:
29-
name: Integration Tests (K3s)
28+
k3s-integration-tests:
29+
name: K3s Integration Tests
3030
if: github.event.pull_request.head.repo.full_name == github.repository
3131
permissions:
3232
contents: 'read'
@@ -36,7 +36,7 @@ jobs:
3636
steps:
3737
- uses: actions/checkout@v5
3838

39-
- name: Start K3s cluster
39+
- name: Setup K3s cluster
4040
uses: jupyterhub/action-k3s-helm@v4
4141
with:
4242
k3s-channel: latest
@@ -47,106 +47,54 @@ jobs:
4747
- name: Set release name
4848
run: echo "RELEASE_NAME=eoapi-$(echo "${{ github.sha }}" | cut -c1-8)" >> "$GITHUB_ENV"
4949

50-
- name: Deploy eoAPI
51-
id: deploy
52-
continue-on-error: true
50+
- name: Wait for K3s readiness
5351
run: |
54-
echo "=== Starting eoAPI deployment ==="
55-
export RELEASE_NAME="$RELEASE_NAME"
56-
export PGO_VERSION="${{ env.PGO_VERSION }}"
57-
export GITHUB_SHA="${{ github.sha }}"
58-
./scripts/deploy.sh --ci
52+
echo "=== Waiting for K3s cluster to be ready ==="
5953
60-
- name: Check deployment status
61-
id: check
62-
if: steps.deploy.outcome == 'success'
63-
run: |
64-
echo "=== Checking deployment status ==="
65-
export RELEASE_NAME="$RELEASE_NAME"
66-
./scripts/test.sh check-deployment --debug
54+
# The action already sets up kubectl context, just verify it works
55+
kubectl cluster-info
56+
kubectl get nodes
6757
68-
- name: Debug pgstac jobs if deployment failed
69-
if: steps.deploy.outcome == 'failure'
70-
continue-on-error: true
71-
run: |
72-
echo "=== Debugging pgstac job failures ==="
73-
74-
# Check pgstac-migrate job
75-
echo "===== pgstac-migrate Job Status ====="
76-
kubectl get jobs -l app.kubernetes.io/name=pgstac-migrate -o wide || echo "No pgstac-migrate jobs found"
77-
78-
MIGRATE_PODS=$(kubectl get pods -l app.kubernetes.io/name=pgstac-migrate -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
79-
if [ -n "$MIGRATE_PODS" ]; then
80-
for POD in $MIGRATE_PODS; do
81-
echo "--- Logs from migrate pod $POD ---"
82-
kubectl logs "$POD" --tail=100 || true
83-
echo "--- Description of migrate pod $POD ---"
84-
kubectl describe pod "$POD"
85-
done
86-
fi
87-
88-
# Check pgstac-load-samples job
89-
echo "===== pgstac-load-samples Job Status ====="
90-
kubectl get jobs -l app.kubernetes.io/name=pgstac-load-samples -o wide || echo "No pgstac-load-samples jobs found"
91-
92-
SAMPLES_PODS=$(kubectl get pods -l app.kubernetes.io/name=pgstac-load-samples -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
93-
if [ -n "$SAMPLES_PODS" ]; then
94-
for POD in $SAMPLES_PODS; do
95-
echo "--- Logs from samples pod $POD ---"
96-
kubectl logs "$POD" --tail=100 || true
97-
echo "--- Description of samples pod $POD ---"
98-
kubectl describe pod "$POD"
99-
done
100-
fi
58+
# Wait for core components
59+
kubectl wait --for=condition=Ready pod -l k8s-app=kube-dns -n kube-system --timeout=300s
60+
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=traefik -n kube-system --timeout=300s
10161
102-
# Check database status
103-
echo "===== Database Pod Status ====="
104-
kubectl get pods -l postgres-operator.crunchydata.com/cluster -o wide
105-
kubectl get postgrescluster -o wide
62+
# Verify Traefik CRDs
63+
timeout=300; counter=0
64+
for crd in "middlewares.traefik.io" "ingressroutes.traefik.io"; do
65+
while [ $counter -lt $timeout ] && ! kubectl get crd "$crd" &>/dev/null; do
66+
sleep 3; counter=$((counter + 3))
67+
done
68+
[ $counter -ge $timeout ] && { echo "❌ Timeout waiting for $crd"; exit 1; }
69+
done
10670
107-
# Check ConfigMaps
108-
echo "===== Relevant ConfigMaps ====="
109-
kubectl get configmaps | grep -E "initdb|pgstac" || echo "No relevant configmaps found"
71+
echo "✅ K3s cluster ready"
11072
111-
# Check for any related events
112-
echo "===== Related Kubernetes Events ====="
113-
kubectl get events | grep -E "pgstac|initdb" || echo "No relevant events found"
73+
- name: Deploy eoAPI
74+
id: deploy
75+
run: |
76+
echo "=== eoAPI Deployment ==="
77+
export RELEASE_NAME="${RELEASE_NAME}"
78+
export PGO_VERSION="${{ env.PGO_VERSION }}"
79+
export CI_MODE=true
11480
115-
# Check notification system status
116-
echo "===== Notification System Status ====="
117-
kubectl get deployments -l app.kubernetes.io/name=eoapi-notifier -o wide || echo "No eoapi-notifier deployment found"
118-
kubectl get ksvc -l app.kubernetes.io/component=cloudevents-sink -o wide || echo "No Knative CloudEvents sink found"
81+
# Deploy using consolidated script with CI mode
82+
./scripts/deploy.sh --ci
11983
120-
exit 1
84+
- name: Validate deployment
85+
run: |
86+
echo "=== Post-deployment validation ==="
87+
./scripts/test.sh check-deployment
12188
12289
- name: Run integration tests
123-
if: steps.deploy.outcome == 'success'
12490
run: |
125-
echo "=== Running integration tests ==="
12691
export RELEASE_NAME="$RELEASE_NAME"
12792
./scripts/test.sh integration --debug
12893
129-
- name: Debug deployment status
130-
if: always()
94+
- name: Debug failed deployment
95+
if: failure()
13196
run: |
132-
echo "=== Final Deployment Status ==="
133-
kubectl get pods -o wide
134-
kubectl get jobs -o wide
135-
kubectl get services -o wide
136-
kubectl get ingress
137-
138-
# Check notification system final status
139-
echo "=== Notification System Final Status ==="
140-
kubectl get deployments -l app.kubernetes.io/name=eoapi-notifier -o wide || echo "No eoapi-notifier deployment"
141-
kubectl get pods -l app.kubernetes.io/name=eoapi-notifier -o wide || echo "No eoapi-notifier pods"
142-
kubectl get ksvc -l app.kubernetes.io/component=cloudevents-sink -o wide || echo "No Knative CloudEvents sink"
143-
kubectl get pods -l serving.knative.dev/service -o wide || echo "No Knative CloudEvents sink pods"
144-
145-
# Show notification logs if they exist
146-
echo "=== eoapi-notifier Logs ==="
147-
kubectl logs -l app.kubernetes.io/name=eoapi-notifier --tail=20 || echo "No eoapi-notifier logs"
148-
echo "=== Knative CloudEvents Sink Logs ==="
149-
kubectl logs -l serving.knative.dev/service --tail=20 || echo "No Knative CloudEvents sink logs"
97+
./scripts/debug-deployment.sh
15098
15199
152100
- name: Cleanup

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Added local testing with k3s and minikube
1212
- Base local development values file (`local-base-values.yaml`)
1313
- Unified local cluster management with `CLUSTER_TYPE` variable
14+
- Added knative in CI to test eoapi-notifier.
1415

1516
## [0.7.12] - 2025-10-17
1617

charts/eoapi/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ dependencies:
5757
version: 0.0.8
5858
repository: "oci://ghcr.io/developmentseed/charts"
5959
condition: eoapi-notifier.enabled
60+
- name: knative-operator
61+
version: 1.17.8
62+
repository: https://knative.github.io/operator
63+
condition: knative.enabled

charts/eoapi/local-k3s-values.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,65 @@ ingress:
77
className: "traefik"
88
annotations:
99
traefik.ingress.kubernetes.io/router.entrypoints: web
10+
11+
# Knative components for CloudEvents
12+
knative:
13+
enabled: true
14+
cloudEventsSink:
15+
enabled: true
16+
17+
# eoapi-notifier configuration with CloudEvents output
18+
eoapi-notifier:
19+
enabled: true
20+
waitForKnativeCRDs: true
21+
config:
22+
logLevel: DEBUG
23+
sources:
24+
- type: pgstac
25+
config:
26+
channel: pgstac_items_change
27+
connection:
28+
existingSecret:
29+
name: "" # Set dynamically by deploy script
30+
keys:
31+
username: "user"
32+
password: "password"
33+
host: "host"
34+
port: "port"
35+
database: "dbname"
36+
outputs:
37+
- type: cloudevents
38+
config:
39+
source: /eoapi/pgstac
40+
event_type: org.eoapi.stac.item
41+
destination:
42+
ref:
43+
apiVersion: serving.knative.dev/v1
44+
kind: Service
45+
name: eoapi-cloudevents-sink
46+
resources:
47+
requests:
48+
cpu: "50m"
49+
memory: "64Mi"
50+
limits:
51+
cpu: "200m"
52+
memory: "128Mi"
53+
54+
# Reduce PostgreSQL resources for local development
55+
postgrescluster:
56+
instances:
57+
- name: "postgres"
58+
replicas: 1
59+
dataVolumeClaimSpec:
60+
accessModes:
61+
- "ReadWriteOnce"
62+
resources:
63+
requests:
64+
storage: "1Gi"
65+
resources:
66+
requests:
67+
cpu: "100m"
68+
memory: "512Mi"
69+
limits:
70+
cpu: "500m"
71+
memory: "1Gi"

charts/eoapi/local-minikube-values.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,65 @@ ingress:
88
annotations:
99
nginx.ingress.kubernetes.io/rewrite-target: /$2
1010
nginx.ingress.kubernetes.io/use-regex: "true"
11+
12+
# Knative components for CloudEvents
13+
knative:
14+
enabled: true
15+
cloudEventsSink:
16+
enabled: true
17+
18+
# eoapi-notifier configuration with CloudEvents output
19+
eoapi-notifier:
20+
enabled: true
21+
waitForKnativeCRDs: true
22+
config:
23+
logLevel: DEBUG
24+
sources:
25+
- type: pgstac
26+
config:
27+
channel: pgstac_items_change
28+
connection:
29+
existingSecret:
30+
name: "" # Set dynamically by deploy script
31+
keys:
32+
username: "user"
33+
password: "password"
34+
host: "host"
35+
port: "port"
36+
database: "dbname"
37+
outputs:
38+
- type: cloudevents
39+
config:
40+
source: /eoapi/pgstac
41+
event_type: org.eoapi.stac.item
42+
destination:
43+
ref:
44+
apiVersion: serving.knative.dev/v1
45+
kind: Service
46+
name: eoapi-cloudevents-sink
47+
resources:
48+
requests:
49+
cpu: "50m"
50+
memory: "64Mi"
51+
limits:
52+
cpu: "200m"
53+
memory: "128Mi"
54+
55+
# Reduce PostgreSQL resources for local development
56+
postgrescluster:
57+
instances:
58+
- name: "postgres"
59+
replicas: 1
60+
dataVolumeClaimSpec:
61+
accessModes:
62+
- "ReadWriteOnce"
63+
resources:
64+
requests:
65+
storage: "1Gi"
66+
resources:
67+
requests:
68+
cpu: "100m"
69+
memory: "512Mi"
70+
limits:
71+
cpu: "500m"
72+
memory: "1Gi"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{- $hasCloudEventsOutput := false }}
2+
{{- range (index .Values "eoapi-notifier").outputs }}
3+
{{- if eq .type "cloudevents" }}
4+
{{- $hasCloudEventsOutput = true }}
5+
{{- end }}
6+
{{- end }}
7+
{{- if and (index .Values "eoapi-notifier").enabled .Values.knative.enabled .Values.knative.cloudEventsSink.enabled $hasCloudEventsOutput }}
8+
---
9+
apiVersion: serving.knative.dev/v1
10+
kind: Service
11+
metadata:
12+
name: eoapi-cloudevents-sink
13+
namespace: {{ .Release.Namespace }}
14+
labels:
15+
{{- include "eoapi.labels" . | nindent 4 }}
16+
app.kubernetes.io/component: cloudevents-sink
17+
annotations:
18+
helm.sh/hook: "post-install,post-upgrade"
19+
helm.sh/hook-weight: "10"
20+
helm.sh/hook-delete-policy: "before-hook-creation"
21+
spec:
22+
template:
23+
metadata:
24+
annotations:
25+
autoscaling.knative.dev/minScale: "1"
26+
autoscaling.knative.dev/maxScale: "1"
27+
labels:
28+
{{- include "eoapi.selectorLabels" . | nindent 8 }}
29+
app.kubernetes.io/component: cloudevents-sink
30+
spec:
31+
containers:
32+
- name: cloudevents-sink
33+
image: gcr.io/knative-samples/helloworld-go:latest
34+
ports:
35+
- containerPort: 8080
36+
env:
37+
- name: PORT
38+
value: "8080"
39+
- name: TARGET
40+
value: "eoAPI CloudEvents Sink"
41+
command: ["/ko-app/helloworld"]
42+
readinessProbe:
43+
httpGet:
44+
path: /
45+
port: 8080
46+
initialDelaySeconds: 5
47+
periodSeconds: 10
48+
livenessProbe:
49+
httpGet:
50+
path: /
51+
port: 8080
52+
initialDelaySeconds: 15
53+
periodSeconds: 20
54+
resources:
55+
{{- toYaml .Values.knative.cloudEventsSink.resources | nindent 10 }}
56+
{{- end }}

0 commit comments

Comments
 (0)