Skip to content

Commit dcaf3e4

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 878a10d commit dcaf3e4

File tree

7 files changed

+340
-78
lines changed

7 files changed

+340
-78
lines changed

.github/workflows/helm-tests.yml

Lines changed: 137 additions & 73 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'
@@ -47,106 +47,170 @@ 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 to be fully ready
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 to be fully 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+
# Wait for core K3s components to be ready
55+
echo "Waiting for kube-system pods to be ready..."
56+
kubectl wait --for=condition=Ready pod -l k8s-app=kube-dns -n kube-system --timeout=300s
57+
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=traefik -n kube-system --timeout=300s
6758
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
59+
# Wait for API server to be fully responsive
60+
echo "Checking API server responsiveness..."
61+
kubectl get nodes
62+
kubectl get pods --all-namespaces
10163
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
64+
# Give K3s a moment to initialize all CRDs
65+
echo "Waiting for K3s initialization to complete..."
66+
sleep 10
10667
107-
# Check ConfigMaps
108-
echo "===== Relevant ConfigMaps ====="
109-
kubectl get configmaps | grep -E "initdb|pgstac" || echo "No relevant configmaps found"
68+
echo "✅ K3s is ready"
11069
111-
# Check for any related events
112-
echo "===== Related Kubernetes Events ====="
113-
kubectl get events | grep -E "pgstac|initdb" || echo "No relevant events found"
70+
- name: Install Knative Serving
71+
run: |
72+
echo "=== Installing Knative Serving ==="
73+
# Install Knative Serving CRDs
74+
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.17.0/serving-crds.yaml
75+
# Install Knative Serving core components
76+
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.17.0/serving-core.yaml
77+
# Install Kourier networking layer for Knative
78+
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.17.0/kourier.yaml
79+
# Configure Knative to use Kourier
80+
kubectl patch configmap/config-network \
81+
--namespace knative-serving \
82+
--type merge \
83+
--patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}'
84+
# Wait for Knative Serving to be ready
85+
echo "Waiting for Knative Serving to be ready..."
86+
kubectl wait --for=condition=Ready pod -l app=controller -n knative-serving --timeout=300s
87+
kubectl wait --for=condition=Ready pod -l app=webhook -n knative-serving --timeout=300s
88+
kubectl wait --for=condition=Ready pod -l app=3scale-kourier-gateway -n kourier-system --timeout=300s
89+
90+
- name: Install Knative Eventing
91+
run: |
92+
echo "=== Installing Knative Eventing ==="
93+
# Install Knative Eventing CRDs (includes SinkBinding)
94+
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.17.0/eventing-crds.yaml
95+
# Install Knative Eventing core components
96+
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.17.0/eventing-core.yaml
97+
# Wait for Knative Eventing to be ready
98+
echo "Waiting for Knative Eventing to be ready..."
99+
kubectl wait --for=condition=Ready pod -l app=eventing-controller -n knative-eventing --timeout=300s
100+
kubectl wait --for=condition=Ready pod -l app=eventing-webhook -n knative-eventing --timeout=300s
101+
102+
- name: Deploy CloudEvents sink for eoapi-notifier
103+
run: |
104+
echo "=== Deploying CloudEvents sink ==="
105+
# Create the namespace first
106+
kubectl create namespace eoapi || true
107+
# Deploy the CloudEvents sink service
108+
kubectl apply -f charts/eoapi/samples/cloudevents-sink.yaml
109+
# Wait for the Knative service to be ready
110+
echo "Waiting for CloudEvents sink to be ready..."
111+
kubectl wait --for=condition=Ready ksvc/eoapi-cloudevents-sink -n eoapi --timeout=300s
112+
113+
- name: Wait for Traefik to be ready
114+
run: |
115+
echo "=== Waiting for Traefik to be ready ==="
116+
117+
# Wait for Traefik pods to be ready first
118+
echo "Waiting for Traefik controller to be ready..."
119+
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=traefik -n kube-system --timeout=300s
120+
121+
# Wait for essential Traefik CRDs to be available
122+
echo "Checking for Traefik CRDs..."
123+
timeout=300
124+
counter=0
125+
required_crds=("middlewares.traefik.io" "ingressroutes.traefik.io")
126+
127+
for crd in "${required_crds[@]}"; do
128+
echo "Checking for CRD: $crd"
129+
counter=0
130+
while [ $counter -lt $timeout ]; do
131+
if kubectl get crd "$crd" &>/dev/null; then
132+
echo "✅ $crd is available"
133+
break
134+
fi
135+
echo "⏳ Waiting for $crd... ($counter/$timeout)"
136+
sleep 3
137+
counter=$((counter + 3))
138+
done
114139
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"
140+
if [ $counter -ge $timeout ]; then
141+
echo "❌ Timeout waiting for $crd"
142+
echo "Available Traefik CRDs:"
143+
kubectl get crd | grep traefik || echo "No Traefik CRDs found"
144+
echo "All CRDs:"
145+
kubectl get crd
146+
exit 1
147+
fi
148+
done
119149
120-
exit 1
150+
echo "✅ All required Traefik CRDs are ready"
151+
152+
- name: Deploy eoAPI
153+
id: deploy
154+
run: |
155+
echo "=== Starting eoAPI deployment ==="
156+
export RELEASE_NAME="$RELEASE_NAME"
157+
export PGO_VERSION="${{ env.PGO_VERSION }}"
158+
export GITHUB_SHA="${{ github.sha }}"
159+
./scripts/deploy.sh --ci
121160
122161
- name: Run integration tests
123-
if: steps.deploy.outcome == 'success'
124162
run: |
125163
echo "=== Running integration tests ==="
126164
export RELEASE_NAME="$RELEASE_NAME"
127165
./scripts/test.sh integration --debug
128166
129-
- name: Debug deployment status
130-
if: always()
167+
- name: Debug failed deployment
168+
if: failure()
131169
run: |
132-
echo "=== Final Deployment Status ==="
170+
echo "=== Deployment failed - collecting debug information ==="
133171
kubectl get pods -o wide
134172
kubectl get jobs -o wide
135173
kubectl get services -o wide
136-
kubectl get ingress
174+
kubectl get events --sort-by='.lastTimestamp' | tail -20 || true
175+
176+
# Check Knative installation status
177+
echo "=== Knative Installation Status ==="
178+
kubectl get pods -n knative-serving -o wide || echo "Knative Serving not installed"
179+
kubectl get pods -n knative-eventing -o wide || echo "Knative Eventing not installed"
180+
kubectl get pods -n kourier-system -o wide || echo "Kourier not installed"
181+
# Check Knative CRDs
182+
echo "=== Knative CRDs Status ==="
183+
kubectl get crd | grep knative || echo "No Knative CRDs found"
184+
kubectl get crd sinkbindings.sources.knative.dev || echo "SinkBinding CRD not found"
185+
186+
# Check Traefik status
187+
echo "=== Traefik Status ==="
188+
kubectl get pods -n kube-system -l app.kubernetes.io/name=traefik -o wide || echo "No Traefik pods found"
189+
kubectl get crd | grep traefik || echo "No Traefik CRDs found"
190+
kubectl get crd middlewares.traefik.io || echo "Middleware CRD not found"
191+
kubectl get crd ingressroutes.traefik.io || echo "IngressRoute CRD not found"
137192
138193
# Check notification system final status
139194
echo "=== Notification System Final Status ==="
140195
kubectl get deployments -l app.kubernetes.io/name=eoapi-notifier -o wide || echo "No eoapi-notifier deployment"
141196
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"
197+
kubectl get ksvc -n eoapi -o wide || echo "No Knative services in eoapi namespace"
198+
kubectl get ksvc eoapi-cloudevents-sink -n eoapi -o wide || echo "No eoapi-cloudevents-sink Knative service"
199+
kubectl get pods -l serving.knative.dev/service=eoapi-cloudevents-sink -n eoapi -o wide || echo "No CloudEvents sink pods"
200+
# Check SinkBinding resources
201+
echo "=== SinkBinding Resources ==="
202+
kubectl get sinkbindings -A -o wide || echo "No SinkBinding resources found"
144203
145204
# Show notification logs if they exist
146205
echo "=== eoapi-notifier Logs ==="
147206
kubectl logs -l app.kubernetes.io/name=eoapi-notifier --tail=20 || echo "No eoapi-notifier logs"
148207
echo "=== Knative CloudEvents Sink Logs ==="
149-
kubectl logs -l serving.knative.dev/service --tail=20 || echo "No Knative CloudEvents sink logs"
208+
kubectl logs -l serving.knative.dev/service=eoapi-cloudevents-sink -n eoapi --tail=20 || echo "No CloudEvents sink logs"
209+
# Show Knative system logs if there are issues
210+
echo "=== Knative Serving Controller Logs ==="
211+
kubectl logs -n knative-serving -l app=controller --tail=20 || echo "No Knative Serving controller logs"
212+
echo "=== Knative Eventing Controller Logs ==="
213+
kubectl logs -n knative-eventing -l app=eventing-controller --tail=20 || echo "No Knative Eventing controller logs"
150214
151215
152216
- name: Cleanup

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ charts/config.yaml
55
charts/eoapi/charts/*.tgz
66
config_ingress.yaml
77
__pycache__
8+
9+
CLAUDE.md

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- Added knative in CI to test eoapi-notifier.
11+
1012
## [0.7.12] - 2025-10-17
1113

1214
- Bumped eoapi-notifier dependency version to 0.0.7

charts/eoapi/test-k3s-unittest-values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ eoapi-notifier:
6262
channel: pgstac_items_change
6363
connection:
6464
existingSecret:
65-
name: "eoapi-test-pguser-eoapi"
65+
name: ""
6666
keys:
6767
username: "user"
6868
password: "password"
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Local test configuration for minikube/local development
2+
# Based on test-k3s-unittest-values.yaml with minimal changes for local environment
3+
4+
testing: true
5+
ingress:
6+
enabled: true
7+
className: "nginx" # Changed from "traefik" for minikube
8+
pathType: "Prefix"
9+
host: "eoapi.local"
10+
11+
pgstacBootstrap:
12+
enabled: true
13+
settings:
14+
resources:
15+
requests:
16+
cpu: "256m"
17+
memory: "1024Mi"
18+
limits:
19+
cpu: "512m"
20+
memory: "1024Mi"
21+
22+
raster:
23+
enabled: true
24+
settings:
25+
resources:
26+
limits:
27+
cpu: "768m"
28+
memory: "2048Mi" # Reduced from 4096Mi for local
29+
requests:
30+
cpu: "256m"
31+
memory: "1024Mi"
32+
33+
stac:
34+
enabled: true
35+
settings:
36+
resources:
37+
limits:
38+
cpu: "1280m"
39+
memory: "1536Mi"
40+
requests:
41+
cpu: "512m"
42+
memory: "1024Mi"
43+
44+
vector:
45+
enabled: true
46+
settings:
47+
resources:
48+
limits:
49+
cpu: "768m"
50+
memory: "1536Mi"
51+
requests:
52+
cpu: "256m"
53+
memory: "1024Mi"
54+
envVars:
55+
TIPG_DEBUG: "True"
56+
57+
eoapi-notifier:
58+
enabled: true
59+
config:
60+
logLevel: DEBUG
61+
sources:
62+
- type: pgstac
63+
config:
64+
channel: pgstac_items_change
65+
connection:
66+
existingSecret:
67+
name: "" # Set dynamically by deploy script
68+
keys:
69+
username: "user"
70+
password: "password"
71+
host: "host"
72+
port: "port"
73+
database: "dbname"
74+
outputs:
75+
- type: cloudevents
76+
config:
77+
source: /eoapi/pgstac
78+
event_type: org.eoapi.stac.item
79+
destination:
80+
ref:
81+
apiVersion: serving.knative.dev/v1
82+
kind: Service
83+
name: eoapi-cloudevents-sink
84+
resources:
85+
requests:
86+
cpu: "50m"
87+
memory: "64Mi"
88+
limits:
89+
cpu: "200m"
90+
memory: "128Mi"
91+
92+
# Reduce PostgreSQL resources for local development
93+
postgrescluster:
94+
instances:
95+
- name: "postgres"
96+
replicas: 1
97+
dataVolumeClaimSpec:
98+
accessModes:
99+
- "ReadWriteOnce"
100+
resources:
101+
requests:
102+
storage: "1Gi" # Reduced for local
103+
resources:
104+
requests:
105+
cpu: "100m" # Reduced for local
106+
memory: "512Mi" # Reduced for local
107+
limits:
108+
cpu: "500m" # Reduced for local
109+
memory: "1Gi" # Reduced for local

0 commit comments

Comments
 (0)