Skip to content

Commit db6af1c

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 3f16a7c commit db6af1c

File tree

14 files changed

+1283
-120
lines changed

14 files changed

+1283
-120
lines changed

.github/workflows/helm-tests.yml

Lines changed: 241 additions & 78 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,269 @@ jobs:
4747
- name: Set release name
4848
run: echo "RELEASE_NAME=eoapi-$(echo "${{ github.sha }}" | cut -c1-8)" >> "$GITHUB_ENV"
4949

50+
- name: Wait for K3s to be fully ready
51+
run: |
52+
echo "=== Waiting for K3s to be fully ready ==="
53+
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
58+
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
63+
64+
# Give K3s a moment to initialize all CRDs
65+
echo "Waiting for K3s initialization to complete..."
66+
sleep 10
67+
68+
echo "✅ K3s is ready"
69+
70+
71+
- name: Wait for Traefik to be ready
72+
run: |
73+
echo "=== Waiting for Traefik to be ready ==="
74+
75+
# Wait for Traefik pods to be ready first
76+
echo "Waiting for Traefik controller to be ready..."
77+
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=traefik -n kube-system --timeout=300s
78+
79+
# Wait for essential Traefik CRDs to be available
80+
echo "Checking for Traefik CRDs..."
81+
timeout=300
82+
counter=0
83+
required_crds=("middlewares.traefik.io" "ingressroutes.traefik.io")
84+
85+
for crd in "${required_crds[@]}"; do
86+
echo "Checking for CRD: $crd"
87+
counter=0
88+
while [ $counter -lt $timeout ]; do
89+
if kubectl get crd "$crd" &>/dev/null; then
90+
echo "✅ $crd is available"
91+
break
92+
fi
93+
echo "⏳ Waiting for $crd... ($counter/$timeout)"
94+
sleep 3
95+
counter=$((counter + 3))
96+
done
97+
98+
if [ $counter -ge $timeout ]; then
99+
echo "❌ Timeout waiting for $crd"
100+
echo "Available Traefik CRDs:"
101+
kubectl get crd | grep traefik || echo "No Traefik CRDs found"
102+
echo "All CRDs:"
103+
kubectl get crd
104+
exit 1
105+
fi
106+
done
107+
108+
echo "✅ All required Traefik CRDs are ready"
109+
110+
- name: Pre-deployment debugging
111+
run: |
112+
echo "=== Pre-deployment State Check ==="
113+
114+
# Check basic cluster state
115+
echo "Cluster nodes:"
116+
kubectl get nodes -o wide
117+
echo ""
118+
119+
echo "All namespaces:"
120+
kubectl get namespaces
121+
echo ""
122+
123+
# Check PGO status
124+
echo "PostgreSQL Operator status:"
125+
kubectl get deployment pgo -o wide || echo "PGO not found"
126+
kubectl get pods -l postgres-operator.crunchydata.com/control-plane=postgres-operator -o wide || echo "No PGO pods found"
127+
echo ""
128+
129+
# Check for any existing knative-operator
130+
echo "Looking for knative-operator before deployment:"
131+
kubectl get deployment knative-operator --all-namespaces -o wide || echo "knative-operator not found yet"
132+
echo ""
133+
134+
# Check available helm repositories
135+
echo "Helm repositories:"
136+
helm repo list
137+
echo ""
138+
139+
# Check if eoapi namespace exists (shouldn't yet)
140+
echo "eoAPI namespace check:"
141+
kubectl get namespace eoapi || echo "eoapi namespace doesn't exist yet (expected)"
142+
echo ""
143+
144+
- name: Validate deployment script
145+
run: |
146+
echo "=== Script Validation ==="
147+
echo "Checking script exists and is executable:"
148+
ls -la scripts/deploy.sh
149+
echo ""
150+
echo "Testing script help:"
151+
./scripts/deploy.sh --help
152+
echo ""
153+
echo "✅ Script validation complete"
154+
50155
- name: Deploy eoAPI
51156
id: deploy
52-
continue-on-error: true
53157
run: |
54158
echo "=== Starting eoAPI deployment ==="
55-
export RELEASE_NAME="$RELEASE_NAME"
159+
echo "Working directory: $(pwd)"
160+
echo "Environment: RELEASE_NAME=${RELEASE_NAME}, PGO_VERSION=${{ env.PGO_VERSION }}"
161+
162+
echo "=== Prerequisites Check ==="
163+
kubectl version --client
164+
helm version
165+
kubectl cluster-info
166+
kubectl get nodes
167+
168+
echo "=== Initial Helm Repository Check ==="
169+
helm repo list || echo "No repositories configured yet"
170+
171+
echo "=== Deploy Script Validation ==="
172+
if [ ! -f scripts/deploy.sh ]; then
173+
echo "❌ Deploy script not found!"
174+
ls -la scripts/ || echo "Scripts directory not found"
175+
exit 1
176+
fi
177+
178+
if [ ! -x scripts/deploy.sh ]; then
179+
echo "❌ Deploy script not executable, fixing..."
180+
chmod +x scripts/deploy.sh
181+
fi
182+
183+
echo "✅ Script validation:"
184+
ls -la scripts/deploy.sh
185+
echo "Script help test:"
186+
./scripts/deploy.sh --help | head -5
187+
188+
echo "=== Setting environment variables ==="
189+
export RELEASE_NAME="${RELEASE_NAME}"
56190
export PGO_VERSION="${{ env.PGO_VERSION }}"
57191
export GITHUB_SHA="${{ github.sha }}"
58-
./scripts/deploy.sh --ci
192+
export CI_MODE=true
193+
export DEBUG_MODE=true
194+
195+
echo "Environment check:"
196+
echo "RELEASE_NAME=$RELEASE_NAME"
197+
echo "PGO_VERSION=$PGO_VERSION"
198+
echo "CI_MODE=$CI_MODE"
199+
200+
echo "=== Pre-deployment cluster state ==="
201+
kubectl get ns || true
202+
kubectl get deployments --all-namespaces || true
203+
204+
echo "=== Executing deployment script ==="
205+
echo "Command: ./scripts/deploy.sh --ci"
206+
echo "Starting deployment at $(date)..."
207+
208+
# Run with explicit error handling
209+
if ! ./scripts/deploy.sh --ci; then
210+
DEPLOY_EXIT_CODE=$?
211+
echo "❌ Deployment script failed with exit code $DEPLOY_EXIT_CODE"
212+
213+
echo "=== Post-failure debugging ==="
214+
echo "Working directory: $(pwd)"
215+
echo "Available files: $(ls -la)"
216+
217+
echo "Helm repositories:"
218+
helm repo list || echo "No helm repositories"
219+
220+
echo "Helm releases:"
221+
helm list --all-namespaces || echo "No helm releases"
222+
223+
echo "Namespaces:"
224+
kubectl get ns || echo "Cannot get namespaces"
225+
226+
echo "Recent events:"
227+
kubectl get events --all-namespaces --sort-by='.lastTimestamp' | tail -20 || echo "Cannot get events"
228+
229+
echo "All pods:"
230+
kubectl get pods --all-namespaces || echo "Cannot get pods"
231+
232+
exit $DEPLOY_EXIT_CODE
233+
fi
234+
235+
echo "✅ Deployment completed successfully at $(date)"
59236
60-
- name: Check deployment status
61-
id: check
62-
if: steps.deploy.outcome == 'success'
237+
- name: Debug Knative Integration
238+
if: always()
63239
run: |
64-
echo "=== Checking deployment status ==="
65-
export RELEASE_NAME="$RELEASE_NAME"
66-
./scripts/test.sh check-deployment --debug
240+
echo "=== Knative Integration Debug ==="
241+
echo "Checking Knative operator status..."
242+
kubectl get deployments -l app.kubernetes.io/name=knative-operator --all-namespaces || echo "Knative operator not found"
243+
244+
echo "=== Knative CRDs ==="
245+
kubectl get crd | grep knative || echo "No Knative CRDs found"
246+
247+
echo "=== KnativeServing Resources ==="
248+
kubectl get knativeservings --all-namespaces -o wide || echo "No KnativeServing resources"
249+
250+
echo "=== KnativeEventing Resources ==="
251+
kubectl get knativeeventings --all-namespaces -o wide || echo "No KnativeEventing resources"
252+
253+
echo "=== Knative Pods ==="
254+
kubectl get pods -n knative-serving || echo "No knative-serving namespace"
255+
kubectl get pods -n knative-eventing || echo "No knative-eventing namespace"
256+
257+
echo "=== eoapi-notifier Status ==="
258+
kubectl get pods -l app.kubernetes.io/name=eoapi-notifier -n eoapi || echo "No eoapi-notifier pods"
259+
kubectl logs -l app.kubernetes.io/name=eoapi-notifier -n eoapi --tail=10 || echo "No eoapi-notifier logs"
260+
261+
echo "=== CloudEvents Sink ==="
262+
kubectl get ksvc -n eoapi || echo "No Knative services in eoapi namespace"
67263
68-
- name: Debug pgstac jobs if deployment failed
69-
if: steps.deploy.outcome == 'failure'
70-
continue-on-error: true
264+
echo "=== SinkBindings ==="
265+
kubectl get sinkbindings -n eoapi || echo "No SinkBindings in eoapi namespace"
266+
267+
echo "=== Knative Jobs and Hooks ==="
268+
kubectl get jobs -n eoapi | grep knative || echo "No Knative-related jobs"
269+
270+
- name: Validate Helm dependencies
71271
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
272+
echo "=== Validating Helm Dependencies Post-Deployment ==="
87273
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
274+
# Check helm repositories
275+
echo "Configured helm repositories:"
276+
helm repo list || echo "No repositories configured"
277+
echo ""
101278
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
279+
# Check if Chart.lock files exist
280+
echo "Chart.lock files:"
281+
find charts/ -name "Chart.lock" -exec ls -la {} \; || echo "No Chart.lock files found"
282+
echo ""
106283
107-
# Check ConfigMaps
108-
echo "===== Relevant ConfigMaps ====="
109-
kubectl get configmaps | grep -E "initdb|pgstac" || echo "No relevant configmaps found"
284+
# Check if dependencies were downloaded
285+
echo "Downloaded chart dependencies:"
286+
find charts/ -name "charts" -type d -exec ls -la {} \; || echo "No chart dependencies found"
287+
echo ""
110288
111-
# Check for any related events
112-
echo "===== Related Kubernetes Events ====="
113-
kubectl get events | grep -E "pgstac|initdb" || echo "No relevant events found"
289+
# Check knative-operator specifically
290+
echo "Checking for knative-operator deployment:"
291+
kubectl get deployment knative-operator --all-namespaces -o wide || echo "knative-operator deployment not found"
292+
echo ""
114293
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"
294+
# Check helm release status
295+
echo "Helm release status:"
296+
helm status "$RELEASE_NAME" -n eoapi || echo "Release status unavailable"
297+
echo ""
119298
120-
exit 1
299+
# Check eoAPI namespace resources
300+
echo "Resources in eoAPI namespace:"
301+
kubectl get all -n eoapi -o wide || echo "No resources in eoapi namespace"
121302
122303
- name: Run integration tests
123-
if: steps.deploy.outcome == 'success'
124304
run: |
125305
echo "=== Running integration tests ==="
126306
export RELEASE_NAME="$RELEASE_NAME"
127307
./scripts/test.sh integration --debug
128308
129-
- name: Debug deployment status
130-
if: always()
309+
- name: Debug failed deployment
310+
if: failure()
131311
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"
312+
./scripts/debug-deployment.sh
150313
151314
152315
- 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ dependencies:
5454
repository: "https://devseed.com/eoapi-k8s/"
5555
condition: postgrescluster.enabled
5656
- name: eoapi-notifier
57-
version: 0.0.7
57+
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

0 commit comments

Comments
 (0)