Skip to content

Commit

Permalink
Data-access - remove Tyk and add sample data load (#83)
Browse files Browse the repository at this point in the history
* Add `sentinel-2-iceland` sample collection

* Add eoepca ingest.sh script

* Add collection links in items

* Fix items.json as a basic array of Features

* [data-access] Remove tyk gateway and associated redis

* [data-access] Add load of sample data into eoAPI

* [data-access] Add more records to sample data

* [data-access] Remove tyk gateway and associated redis

* [data-access] align eoapi values with dev cluster

* [data-access] Use STAC Browser to check loaded sample data
  • Loading branch information
rconway authored Feb 27, 2025
1 parent 7a5f89e commit 1741ac7
Show file tree
Hide file tree
Showing 10 changed files with 171,580 additions and 79 deletions.
62 changes: 22 additions & 40 deletions docs/building-blocks/data-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ The Data Access BB consists of the following main components:

- **Stacture**: Bridges STAC API with OGC API Coverages and OGC WCS.
- **Terravis**: Provides advanced rendering and processing capabilities.
4. **Tyk Gateway**: API Gateway for authentication, authorization, rate-limiting, and caching, integrated with the Identity Management BB.

5. **Redis**: In-memory data structure store used by Tyk.

6. **eoapi-support**<br>
4. **eoapi-support**<br>
Optional but recommended monitoring stack (Grafana, Prometheus, metrics server) to observe and manage the Data Access services.


Expand Down Expand Up @@ -165,36 +162,7 @@ helm upgrade -i stacture eox/stacture \
---

### 4. Deploy Tyk Gateway and Redis

1. **Install Redis for Tyk Gateway:**

```bash
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update bitnami
helm upgrade -i tyk-redis bitnami/redis \
--version 20.1.0 \
--namespace data-access \
--values tyk-gateway/redis-generated-values.yaml
```

2. **Install Tyk Gateway:**

```bash
helm repo add tyk-oss https://helm.tyk.io/public/helm/charts/
helm repo update tyk-oss
helm upgrade -i tyk-oss tyk-oss/tyk-oss \
--version 1.6.0 \
--namespace data-access \
--values tyk-gateway/generated-values.yaml
```


Tyk integrates with Identity Management for secure access and additional capabilities such as rate limiting or caching.

---

### 5. Monitoring the Deployment
### 4. Monitoring the Deployment

After deploying, you can monitor the status of the deployments:

Expand All @@ -206,7 +174,7 @@ Check that all pods are in the `Running` state and that services/ingresses are p

---

### 6. Accessing the Data Access Services
### 5. Accessing the Data Access Services

Once the deployment is complete and all pods are running, you can access the services:

Expand All @@ -216,15 +184,32 @@ Once the deployment is complete and all pods are running, you can access the ser
- **Stacture API (coverages, WCS, etc.):**
`https://stacture.${INGRESS_HOST}/`
<!-- currently ingress issues -->
- **Tyk Gateway Dashboard** (if exposed via ingress):
`https://tyk-gateway.${INGRESS_HOST}/`

- **Grafana** (if `eoapi-support` is installed and ingress is enabled):
`https://eoapisupport.${INGRESS_HOST}/`
<!-- add default credentials -->

---

## Load Sample Collection

The following steps load a sample `Sentinel2-L2A-Iceland` collection into eoAPI.

```bash
cd collections/sentinel-2-iceland
../ingest.sh
cd ../..
```

Check the loaded collection via STAC Browser...

```bash
source ~/.eoepca/state
xdg-open https://radiantearth.github.io/stac-browser/#/external/eoapi.${INGRESS_HOST}/stac/collections/sentinel-2-iceland
```

---

## Testing and Validation

Below are some quick ways to test and validate the Data Access services.
Expand Down Expand Up @@ -293,8 +278,6 @@ curl -X POST "https://eoapi.${INGRESS_HOST}/stac/search" \
To uninstall the Data Access Building Block and clean up associated resources:

```bash
helm uninstall tyk-oss -n data-access
helm uninstall tyk-redis -n data-access
helm uninstall stacture -n data-access
helm uninstall eoapi-support -n data-access
helm uninstall eoapi -n data-access
Expand All @@ -309,5 +292,4 @@ kubectl delete namespace data-access

- [EOEPCA+ Data Access GitHub Repository](https://github.com/EOEPCA/data-access)
- [eoAPI Documentation](https://github.com/developmentseed/eoAPI)
- [Tyk Gateway Documentation](https://tyk.io/docs/)
- [Crunchy Data Postgres Operator Documentation](https://access.crunchydata.com/documentation/postgres-operator/)
79 changes: 79 additions & 0 deletions scripts/data-access/collections/ingest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

# Default files
DEFAULT_COLLECTIONS_FILE="./collections.json"
DEFAULT_ITEMS_FILE="./items.json"

# Check for provided parameters or use defaults
if [ "$#" -eq 2 ]; then
EOAPI_COLLECTIONS_FILE="$1"
EOAPI_ITEMS_FILE="$2"
else
EOAPI_COLLECTIONS_FILE="$DEFAULT_COLLECTIONS_FILE"
EOAPI_ITEMS_FILE="$DEFAULT_ITEMS_FILE"
echo "No specific files provided. Using defaults:"
echo " Collections file: $EOAPI_COLLECTIONS_FILE"
echo " Items file: $EOAPI_ITEMS_FILE"
fi

# Define namespaces
NAMESPACES=("default" "eoapi", "data-access")
EOAPI_POD_RASTER=""
FOUND_NAMESPACE=""

# Discover the pod name from both namespaces
for NS in "${NAMESPACES[@]}"; do
EOAPI_POD_RASTER=$(kubectl get pods -n "$NS" -l app=raster-eoapi -o jsonpath="{.items[0].metadata.name}" 2>/dev/null)
if [ -n "$EOAPI_POD_RASTER" ]; then
FOUND_NAMESPACE="$NS"
echo "Found raster-eoapi pod: $EOAPI_POD_RASTER in namespace: $FOUND_NAMESPACE"
break
fi
done

# Check if the pod was found
if [ -z "$EOAPI_POD_RASTER" ]; then
echo "Could not determine raster-eoapi pod."
exit 1
fi

# Check if input files exist
for FILE in "$EOAPI_COLLECTIONS_FILE" "$EOAPI_ITEMS_FILE"; do
if [ ! -f "$FILE" ]; then
echo "File not found: $FILE. You may set them via the EOAPI_COLLECTIONS_FILE and EOAPI_ITEMS_FILE environment variables."
exit 1
fi
done

# Install required packages
echo "Installing required packages in pod $EOAPI_POD_RASTER in namespace $FOUND_NAMESPACE..."
if ! kubectl exec -n "$FOUND_NAMESPACE" "$EOAPI_POD_RASTER" -- bash -c 'apt update -y && apt install python3 python3-pip -y && pip install pypgstac[psycopg]'; then
echo "Failed to install packages."
exit 1
fi

# Copy files to pod
echo "Copying files to pod..."
echo "Using collections file: $EOAPI_COLLECTIONS_FILE"
echo "Using items file: $EOAPI_ITEMS_FILE"
kubectl cp "$EOAPI_COLLECTIONS_FILE" "$FOUND_NAMESPACE/$EOAPI_POD_RASTER":/tmp/collections.json
kubectl cp "$EOAPI_ITEMS_FILE" "$FOUND_NAMESPACE/$EOAPI_POD_RASTER":/tmp/items.json

# Load collections and items
echo "Loading collections..."
if ! kubectl exec -n "$FOUND_NAMESPACE" "$EOAPI_POD_RASTER" -- bash -c 'pypgstac load collections /tmp/collections.json --dsn "$PGADMIN_URI" --method insert_ignore'; then
echo "Failed to load collections."
exit 1
fi

echo "Loading items..."
if ! kubectl exec -n "$FOUND_NAMESPACE" "$EOAPI_POD_RASTER" -- bash -c 'pypgstac load items /tmp/items.json --dsn "$PGADMIN_URI" --method insert_ignore'; then
echo "Failed to load items."
exit 1
fi

# Clean temporary files
echo "Cleaning temporary files..."
kubectl exec -n "$FOUND_NAMESPACE" "$EOAPI_POD_RASTER" -- bash -c 'rm -f /tmp/collections.json /tmp/items.json'

echo "Ingestion complete."
Loading

0 comments on commit 1741ac7

Please sign in to comment.