Skip to content

Commit 3dfa7a4

Browse files
committed
feat: enhance deployment script with dynamic configuration
- Add support for local test configuration values - Dynamic secret name assignment for eoapi-notifier - Enhanced job completion waiting with better error handling - Add pgstac-migrate job completion verification
1 parent b1dad99 commit 3dfa7a4

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

scripts/deploy.sh

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,17 @@ deploy_eoapi() {
140140
HELM_CMD="$HELM_CMD -f ./eoapi/values.yaml"
141141
fi
142142

143-
# CI-specific configuration
143+
# Environment-specific configuration
144144
if [ "$CI_MODE" = true ] && [ -f "./eoapi/test-k3s-unittest-values.yaml" ]; then
145145
log_info "Using CI test configuration..."
146146
HELM_CMD="$HELM_CMD -f ./eoapi/test-k3s-unittest-values.yaml"
147+
# Fix eoapi-notifier secret name dynamically
148+
HELM_CMD="$HELM_CMD --set eoapi-notifier.config.sources[0].config.connection.existingSecret.name=$RELEASE_NAME-pguser-eoapi"
149+
elif [ -f "./eoapi/test-local-values.yaml" ]; then
150+
log_info "Using local test configuration..."
151+
HELM_CMD="$HELM_CMD -f ./eoapi/test-local-values.yaml"
152+
# Fix eoapi-notifier secret name dynamically for local mode too
153+
HELM_CMD="$HELM_CMD --set eoapi-notifier.config.sources[0].config.connection.existingSecret.name=$RELEASE_NAME-pguser-eoapi"
147154
fi
148155

149156
# Set git SHA if available
@@ -164,8 +171,67 @@ deploy_eoapi() {
164171
log_info "Verifying deployment..."
165172
kubectl get pods -n "$NAMESPACE" -o wide
166173

174+
# Wait for pgstac jobs to complete first
175+
if kubectl get job -n "$NAMESPACE" -l "app=$RELEASE_NAME-pgstac-migrate" >/dev/null 2>&1; then
176+
log_info "Waiting for pgstac-migrate job to complete..."
177+
if ! kubectl wait --for=condition=complete job -l "app=$RELEASE_NAME-pgstac-migrate" -n "$NAMESPACE" --timeout=600s; then
178+
log_error "pgstac-migrate job failed to complete"
179+
kubectl describe job -l "app=$RELEASE_NAME-pgstac-migrate" -n "$NAMESPACE"
180+
kubectl logs -l "app=$RELEASE_NAME-pgstac-migrate" -n "$NAMESPACE" --tail=50 || true
181+
exit 1
182+
fi
183+
fi
184+
185+
if kubectl get job -n "$NAMESPACE" -l "app=$RELEASE_NAME-pgstac-load-samples" >/dev/null 2>&1; then
186+
log_info "Waiting for pgstac-load-samples job to complete..."
187+
if ! kubectl wait --for=condition=complete job -l "app=$RELEASE_NAME-pgstac-load-samples" -n "$NAMESPACE" --timeout=300s; then
188+
log_error "pgstac-load-samples job failed to complete"
189+
kubectl describe job -l "app=$RELEASE_NAME-pgstac-load-samples" -n "$NAMESPACE"
190+
kubectl logs -l "app=$RELEASE_NAME-pgstac-load-samples" -n "$NAMESPACE" --tail=50 || true
191+
exit 1
192+
fi
193+
fi
194+
195+
# Wait for service pods to be ready
196+
log_info "Waiting for eoAPI services to be ready..."
197+
local services=("stac" "raster" "vector")
198+
local failed_services=()
199+
200+
for service in "${services[@]}"; do
201+
# Try different label patterns to find pods
202+
local found=false
203+
local patterns=(
204+
"app.kubernetes.io/instance=$RELEASE_NAME,app.kubernetes.io/name=$service"
205+
"app=$RELEASE_NAME-$service"
206+
)
207+
208+
for pattern in "${patterns[@]}"; do
209+
if kubectl get pods -n "$NAMESPACE" -l "$pattern" >/dev/null 2>&1; then
210+
log_info "Waiting for $service service pods to be ready..."
211+
if kubectl wait --for=condition=Ready pod -l "$pattern" -n "$NAMESPACE" --timeout=300s; then
212+
found=true
213+
break
214+
else
215+
log_warn "$service service pods found but failed readiness check"
216+
kubectl describe pods -n "$NAMESPACE" -l "$pattern" || true
217+
fi
218+
fi
219+
done
220+
221+
if [ "$found" = false ]; then
222+
failed_services+=("$service")
223+
fi
224+
done
225+
226+
if [ ${#failed_services[@]} -ne 0 ]; then
227+
log_error "Failed to start services: ${failed_services[*]}"
228+
kubectl get pods -n "$NAMESPACE" -o wide
229+
kubectl get events -n "$NAMESPACE" --sort-by='.lastTimestamp' | tail -20 || true
230+
exit 1
231+
fi
232+
167233
log_info "eoAPI deployment completed successfully!"
168-
log_info "Services available in namespace: $NAMESPACE"
234+
log_info "All services are ready in namespace: $NAMESPACE"
169235

170236
if [ "$CI_MODE" != true ]; then
171237
log_info "To run integration tests: make integration"

0 commit comments

Comments
 (0)