Skip to content

Commit 5cdd136

Browse files
committed
ci: add Knative integration and improve K3s setup
- Add proper K3s readiness waiting before deployment - Install Knative Serving and Eventing for notifications - Deploy CloudEvents sink for eoapi-notifier integration - Add Traefik CRD availability checks - Improve component initialization sequencing - Rename integration job to k3s-integration-tests for clarity
1 parent 4f772d8 commit 5cdd136

File tree

1 file changed

+144
-74
lines changed

1 file changed

+144
-74
lines changed

.github/workflows/helm-tests.yml

Lines changed: 144 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ jobs:
2222
with:
2323
version: ${{ env.HELM_VERSION }}
2424

25-
- name: Run Helm unit tests
26-
run: make tests
25+
- name: Install helm unittest plugin
26+
run: helm plugin install https://github.com/helm-unittest/helm-unittest
2727

28-
integration:
29-
name: Integration Tests (K3s)
28+
- run: |
29+
cd charts
30+
helm unittest eoapi -f 'tests/*.yaml' -v eoapi/test-helm-values.yaml
31+
# Run autoscaling-specific unit tests
32+
helm unittest eoapi -f 'tests/autoscaling_tests.yaml'
33+
34+
k3s-integration-tests:
3035
if: github.event.pull_request.head.repo.full_name == github.repository
3136
permissions:
3237
contents: 'read'
@@ -47,106 +52,171 @@ jobs:
4752
- name: Set release name
4853
run: echo "RELEASE_NAME=eoapi-$(echo "${{ github.sha }}" | cut -c1-8)" >> "$GITHUB_ENV"
4954

50-
- name: Deploy eoAPI
51-
id: deploy
52-
continue-on-error: true
55+
- name: Wait for K3s to be fully ready
5356
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
57+
echo "=== Waiting for K3s to be fully ready ==="
5958
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
59+
# Wait for core K3s components to be ready
60+
echo "Waiting for kube-system pods to be ready..."
61+
kubectl wait --for=condition=Ready pod -l k8s-app=kube-dns -n kube-system --timeout=300s
62+
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=traefik -n kube-system --timeout=300s
63+
64+
# Wait for API server to be fully responsive
65+
echo "Checking API server responsiveness..."
66+
kubectl get nodes
67+
kubectl get pods --all-namespaces
6768
68-
- name: Debug pgstac jobs if deployment failed
69-
if: steps.deploy.outcome == 'failure'
70-
continue-on-error: true
69+
# Give K3s a moment to initialize all CRDs
70+
echo "Waiting for K3s initialization to complete..."
71+
sleep 10
72+
73+
echo "✅ K3s is ready"
74+
75+
- name: Install Knative Serving
7176
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"
77+
echo "=== Installing Knative Serving ==="
78+
# Install Knative Serving CRDs
79+
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.17.0/serving-crds.yaml
80+
# Install Knative Serving core components
81+
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.17.0/serving-core.yaml
82+
# Install Kourier networking layer for Knative
83+
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.17.0/kourier.yaml
84+
# Configure Knative to use Kourier
85+
kubectl patch configmap/config-network \
86+
--namespace knative-serving \
87+
--type merge \
88+
--patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}'
89+
# Wait for Knative Serving to be ready
90+
echo "Waiting for Knative Serving to be ready..."
91+
kubectl wait --for=condition=Ready pod -l app=controller -n knative-serving --timeout=300s
92+
kubectl wait --for=condition=Ready pod -l app=webhook -n knative-serving --timeout=300s
93+
kubectl wait --for=condition=Ready pod -l app=3scale-kourier-gateway -n kourier-system --timeout=300s
94+
95+
- name: Install Knative Eventing
96+
run: |
97+
echo "=== Installing Knative Eventing ==="
98+
# Install Knative Eventing CRDs (includes SinkBinding)
99+
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.17.0/eventing-crds.yaml
100+
# Install Knative Eventing core components
101+
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.17.0/eventing-core.yaml
102+
# Wait for Knative Eventing to be ready
103+
echo "Waiting for Knative Eventing to be ready..."
104+
kubectl wait --for=condition=Ready pod -l app=eventing-controller -n knative-eventing --timeout=300s
105+
kubectl wait --for=condition=Ready pod -l app=eventing-webhook -n knative-eventing --timeout=300s
106+
107+
- name: Deploy CloudEvents sink for eoapi-notifier
108+
run: |
109+
echo "=== Deploying CloudEvents sink ==="
110+
# Create the namespace first
111+
kubectl create namespace eoapi || true
112+
# Deploy the CloudEvents sink service
113+
kubectl apply -f charts/eoapi/samples/cloudevents-sink.yaml
114+
# Wait for the Knative service to be ready
115+
echo "Waiting for CloudEvents sink to be ready..."
116+
kubectl wait --for=condition=Ready ksvc/eoapi-cloudevents-sink -n eoapi --timeout=300s
117+
118+
- name: Wait for Traefik to be ready
119+
run: |
120+
echo "=== Waiting for Traefik to be ready ==="
121+
122+
# Wait for Traefik pods to be ready first
123+
echo "Waiting for Traefik controller to be ready..."
124+
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=traefik -n kube-system --timeout=300s
125+
126+
# Wait for essential Traefik CRDs to be available
127+
echo "Checking for Traefik CRDs..."
128+
timeout=300
129+
counter=0
130+
required_crds=("middlewares.traefik.io" "ingressroutes.traefik.io")
131+
132+
for crd in "${required_crds[@]}"; do
133+
echo "Checking for CRD: $crd"
134+
counter=0
135+
while [ $counter -lt $timeout ]; do
136+
if kubectl get crd "$crd" &>/dev/null; then
137+
echo "✅ $crd is available"
138+
break
139+
fi
140+
echo "⏳ Waiting for $crd... ($counter/$timeout)"
141+
sleep 3
142+
counter=$((counter + 3))
99143
done
100-
fi
101-
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
106144
107-
# Check ConfigMaps
108-
echo "===== Relevant ConfigMaps ====="
109-
kubectl get configmaps | grep -E "initdb|pgstac" || echo "No relevant configmaps found"
145+
if [ $counter -ge $timeout ]; then
146+
echo "❌ Timeout waiting for $crd"
147+
echo "Available Traefik CRDs:"
148+
kubectl get crd | grep traefik || echo "No Traefik CRDs found"
149+
echo "All CRDs:"
150+
kubectl get crd
151+
exit 1
152+
fi
153+
done
110154
111-
# Check for any related events
112-
echo "===== Related Kubernetes Events ====="
113-
kubectl get events | grep -E "pgstac|initdb" || echo "No relevant events found"
155+
echo "✅ All required Traefik CRDs are ready"
114156
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"
157+
- name: Deploy eoAPI
158+
id: deploy
159+
run: |
160+
echo "=== Starting eoAPI deployment ==="
161+
export RELEASE_NAME="$RELEASE_NAME"
162+
export PGO_VERSION="${{ env.PGO_VERSION }}"
163+
export GITHUB_SHA="${{ github.sha }}"
164+
./scripts/deploy.sh --ci
119165
120-
exit 1
121166
122167
- name: Run integration tests
123-
if: steps.deploy.outcome == 'success'
124168
run: |
125169
echo "=== Running integration tests ==="
126170
export RELEASE_NAME="$RELEASE_NAME"
127171
./scripts/test.sh integration --debug
128172
129-
- name: Debug deployment status
130-
if: always()
173+
- name: Debug failed deployment
174+
if: failure()
131175
run: |
132-
echo "=== Final Deployment Status ==="
176+
echo "=== Deployment failed - collecting debug information ==="
133177
kubectl get pods -o wide
134178
kubectl get jobs -o wide
135179
kubectl get services -o wide
136-
kubectl get ingress
180+
kubectl get events --sort-by='.lastTimestamp' | tail -20 || true
181+
182+
# Check Knative installation status
183+
echo "=== Knative Installation Status ==="
184+
kubectl get pods -n knative-serving -o wide || echo "Knative Serving not installed"
185+
kubectl get pods -n knative-eventing -o wide || echo "Knative Eventing not installed"
186+
kubectl get pods -n kourier-system -o wide || echo "Kourier not installed"
187+
# Check Knative CRDs
188+
echo "=== Knative CRDs Status ==="
189+
kubectl get crd | grep knative || echo "No Knative CRDs found"
190+
kubectl get crd sinkbindings.sources.knative.dev || echo "SinkBinding CRD not found"
191+
192+
# Check Traefik status
193+
echo "=== Traefik Status ==="
194+
kubectl get pods -n kube-system -l app.kubernetes.io/name=traefik -o wide || echo "No Traefik pods found"
195+
kubectl get crd | grep traefik || echo "No Traefik CRDs found"
196+
kubectl get crd middlewares.traefik.io || echo "Middleware CRD not found"
197+
kubectl get crd ingressroutes.traefik.io || echo "IngressRoute CRD not found"
137198
138199
# Check notification system final status
139200
echo "=== Notification System Final Status ==="
140201
kubectl get deployments -l app.kubernetes.io/name=eoapi-notifier -o wide || echo "No eoapi-notifier deployment"
141202
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"
203+
kubectl get ksvc -n eoapi -o wide || echo "No Knative services in eoapi namespace"
204+
kubectl get ksvc eoapi-cloudevents-sink -n eoapi -o wide || echo "No eoapi-cloudevents-sink Knative service"
205+
kubectl get pods -l serving.knative.dev/service=eoapi-cloudevents-sink -n eoapi -o wide || echo "No CloudEvents sink pods"
206+
# Check SinkBinding resources
207+
echo "=== SinkBinding Resources ==="
208+
kubectl get sinkbindings -A -o wide || echo "No SinkBinding resources found"
144209
145210
# Show notification logs if they exist
146211
echo "=== eoapi-notifier Logs ==="
147212
kubectl logs -l app.kubernetes.io/name=eoapi-notifier --tail=20 || echo "No eoapi-notifier logs"
148213
echo "=== Knative CloudEvents Sink Logs ==="
149-
kubectl logs -l serving.knative.dev/service --tail=20 || echo "No Knative CloudEvents sink logs"
214+
kubectl logs -l serving.knative.dev/service=eoapi-cloudevents-sink -n eoapi --tail=20 || echo "No CloudEvents sink logs"
215+
# Show Knative system logs if there are issues
216+
echo "=== Knative Serving Controller Logs ==="
217+
kubectl logs -n knative-serving -l app=controller --tail=20 || echo "No Knative Serving controller logs"
218+
echo "=== Knative Eventing Controller Logs ==="
219+
kubectl logs -n knative-eventing -l app=eventing-controller --tail=20 || echo "No Knative Eventing controller logs"
150220
151221
152222
- name: Cleanup

0 commit comments

Comments
 (0)