Skip to content

Commit 3f16a7c

Browse files
committed
Added local integrations test with k3s.
1 parent 27c30d2 commit 3f16a7c

File tree

11 files changed

+728
-206
lines changed

11 files changed

+728
-206
lines changed

.gitignore

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

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Added
11+
- Added local testing with k3s and minikube
12+
- Base local development values file (`local-base-values.yaml`)
13+
- Unified local cluster management with `CLUSTER_TYPE` variable
14+
1015
## [0.7.12] - 2025-10-17
1116

1217
- Bumped eoapi-notifier dependency version to 0.0.7

Makefile

Lines changed: 74 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,77 @@
11
# Makefile for eoapi-k8s
22

3-
# Variables
4-
HELM_REPO_URL=https://devseed.com/eoapi-k8s/
5-
HELM_CHART_NAME=eoapi/eoapi
6-
PGO_CHART_VERSION=5.7.4
3+
LOCAL_CLUSTER_SCRIPT := ./scripts/local-cluster.sh
4+
DEPLOY_SCRIPT := ./scripts/deploy.sh
5+
TEST_SCRIPT := ./scripts/test.sh
76

8-
.PHONY: all deploy minikube ingest tests integration lint validate-schema help
7+
# Default cluster type (can be overridden)
8+
CLUSTER_TYPE ?= minikube
99

10-
# Default target
11-
all: deploy
10+
.PHONY: help deploy clean tests integration lint validate-schema
11+
.DEFAULT_GOAL := help
12+
13+
help:
14+
@echo "eoAPI Kubernetes Makefile"
15+
@echo ""
16+
@echo "MAIN COMMANDS:"
17+
@echo " deploy Deploy eoAPI to current kubectl context"
18+
@echo " tests Run Helm unit tests"
19+
@echo " integration Run integration tests on current cluster"
20+
@echo " clean Clean up deployment"
21+
@echo ""
22+
@echo "LOCAL DEVELOPMENT:"
23+
@echo " local Create local cluster and deploy (CLUSTER_TYPE=minikube|k3s)"
24+
@echo " local-start Start existing local cluster"
25+
@echo " local-stop Stop local cluster"
26+
@echo " local-delete Delete local cluster"
27+
@echo " local-status Show local cluster status"
28+
@echo " test-local Run full integration tests on local cluster"
29+
@echo ""
30+
@echo "QUALITY:"
31+
@echo " lint Run linting and code quality checks"
32+
@echo " validate-schema Validate Helm schemas"
33+
@echo ""
34+
@echo "VARIABLES:"
35+
@echo " CLUSTER_TYPE Local cluster type: minikube or k3s (default: minikube)"
36+
@echo ""
37+
@echo "EXAMPLES:"
38+
@echo " make local CLUSTER_TYPE=minikube"
39+
@echo " make test-local CLUSTER_TYPE=k3s"
1240

1341
deploy:
14-
@echo "Deploying eoAPI."
15-
@command -v bash >/dev/null 2>&1 || { echo "bash is required but not installed"; exit 1; }
16-
@./scripts/deploy.sh
17-
18-
minikube:
19-
@echo "Starting minikube."
20-
@command -v minikube >/dev/null 2>&1 || { echo "minikube is required but not installed"; exit 1; }
21-
minikube start
22-
# Deploy eoAPI via the regular helm install routine
23-
@make deploy
24-
minikube addons enable ingress
25-
@echo "eoAPI is now available at:"
26-
@minikube service ingress-nginx-controller -n ingress-nginx --url | head -n 1
42+
@$(DEPLOY_SCRIPT)
2743

28-
ingest:
29-
@echo "Ingesting STAC collections and items into the database."
30-
@command -v bash >/dev/null 2>&1 || { echo "bash is required but not installed"; exit 1; }
31-
@./scripts/ingest.sh || { echo "Ingestion failed."; exit 1; }
44+
clean:
45+
@$(DEPLOY_SCRIPT) cleanup
3246

3347
tests:
34-
@echo "Running Helm unit tests..."
35-
@command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed"; exit 1; }
36-
@./scripts/deploy.sh setup
37-
@./scripts/test.sh helm
48+
@$(DEPLOY_SCRIPT) setup
49+
@$(TEST_SCRIPT) helm
3850

3951
integration:
40-
@echo "Running integration tests against Kubernetes cluster..."
41-
@command -v bash >/dev/null 2>&1 || { echo "bash is required but not installed"; exit 1; }
42-
@./scripts/test.sh integration
52+
@$(TEST_SCRIPT) integration
53+
54+
local:
55+
@$(LOCAL_CLUSTER_SCRIPT) deploy --type $(CLUSTER_TYPE)
56+
57+
local-start:
58+
@$(LOCAL_CLUSTER_SCRIPT) start --type $(CLUSTER_TYPE)
59+
60+
local-stop:
61+
@$(LOCAL_CLUSTER_SCRIPT) stop --type $(CLUSTER_TYPE)
62+
63+
local-delete:
64+
@$(LOCAL_CLUSTER_SCRIPT) delete --type $(CLUSTER_TYPE)
65+
66+
local-status:
67+
@$(LOCAL_CLUSTER_SCRIPT) status --type $(CLUSTER_TYPE)
68+
69+
test-local:
70+
@$(LOCAL_CLUSTER_SCRIPT) start --type $(CLUSTER_TYPE)
71+
@$(LOCAL_CLUSTER_SCRIPT) context --type $(CLUSTER_TYPE)
72+
@$(MAKE) integration
4373

4474
lint:
45-
@echo "Running linting and code quality checks..."
4675
@if [ ! -f .git/hooks/pre-commit ]; then \
4776
echo "Installing pre-commit..."; \
4877
uv pip install pre-commit yamllint shellcheck-py || pip3 install --user pre-commit yamllint shellcheck-py; \
@@ -51,37 +80,27 @@ lint:
5180
@pre-commit run --all-files
5281

5382
validate-schema:
54-
@echo "Validating Helm values schemas..."
55-
@command -v helm >/dev/null 2>&1 || { echo "❌ helm is required but not installed"; exit 1; }
56-
@command -v ajv >/dev/null 2>&1 || { echo "❌ ajv-cli is required but not installed. Run: npm install -g ajv-cli ajv-formats"; exit 1; }
83+
@command -v helm >/dev/null 2>&1 || { echo "❌ helm required but not installed"; exit 1; }
84+
@command -v ajv >/dev/null 2>&1 || { echo "❌ ajv-cli required. Run: npm install -g ajv-cli ajv-formats"; exit 1; }
5785
@for chart_dir in charts/*/; do \
5886
chart_name=$$(basename "$$chart_dir"); \
5987
if [ -f "$${chart_dir}values.schema.json" ]; then \
60-
echo "🔍 Validating schema for $$chart_name..."; \
61-
if helm lint "$$chart_dir" --strict && \
62-
helm template test "$$chart_dir" >/dev/null && \
63-
ajv compile -s "$${chart_dir}values.schema.json" --spec=draft7 --strict=false && \
64-
python3 -c "import yaml,json; json.dump(yaml.safe_load(open('$${chart_dir}values.yaml')), open('/tmp/values-$${chart_name}.json','w'))" && \
65-
ajv validate -s "$${chart_dir}values.schema.json" -d "/tmp/values-$${chart_name}.json" --spec=draft7; then \
66-
rm -f "/tmp/values-$${chart_name}.json"; \
67-
echo "$$chart_name validation passed"; \
68-
else \
88+
echo "🔍 Validating $$chart_name..."; \
89+
helm lint "$$chart_dir" --strict && \
90+
helm template test "$$chart_dir" >/dev/null && \
91+
ajv compile -s "$${chart_dir}values.schema.json" --spec=draft7 --strict=false && \
92+
python3 -c "import yaml,json; json.dump(yaml.safe_load(open('$${chart_dir}values.yaml')), open('/tmp/values-$${chart_name}.json','w'))" && \
93+
ajv validate -s "$${chart_dir}values.schema.json" -d "/tmp/values-$${chart_name}.json" --spec=draft7 && \
94+
rm -f "/tmp/values-$${chart_name}.json" && \
95+
echo "$$chart_name validation passed" || { \
6996
rm -f "/tmp/values-$${chart_name}.json"; \
7097
echo "$$chart_name validation failed"; \
7198
exit 1; \
72-
fi; \
99+
}; \
73100
else \
74101
echo "⚠️ $$chart_name: no values.schema.json found, skipping"; \
75102
fi; \
76103
done
77104

78-
help:
79-
@echo "Makefile commands:"
80-
@echo " make deploy - Deploy eoAPI to the configured Kubernetes cluster."
81-
@echo " make minikube - Install eoAPI on minikube."
82-
@echo " make ingest - Ingest STAC collections and items into the database."
83-
@echo " make integration - Run integration tests on connected Kubernetes cluster."
84-
@echo " make tests - Run unit tests."
85-
@echo " make lint - Run linting and code quality checks."
86-
@echo " make validate-schema - Validate Helm values schemas."
87-
@echo " make help - Show this help message."
105+
ingest:
106+
@./scripts/ingest.sh
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Base local development values for eoAPI
2+
# Common configuration shared between minikube and k3s
3+
# Platform-specific values should override only what's different
4+
5+
testing: false
6+
7+
# Database configuration optimized for local development
8+
database:
9+
enabled: true
10+
connectionPooling:
11+
enabled: false # Simplify for local development
12+
13+
# Enable pgstac bootstrap with sample data
14+
pgstacBootstrap:
15+
enabled: true
16+
settings:
17+
resources:
18+
requests:
19+
cpu: "256m"
20+
memory: "1024Mi"
21+
limits:
22+
cpu: "512m"
23+
memory: "1024Mi"
24+
25+
# STAC API service
26+
stac:
27+
enabled: true
28+
settings:
29+
resources:
30+
requests:
31+
cpu: "512m"
32+
memory: "1024Mi"
33+
limits:
34+
cpu: "1280m"
35+
memory: "1536Mi"
36+
envVars:
37+
# Enable debug mode for development
38+
STAC_FASTAPI_DEBUG: "True"
39+
# Disable CORS for local development
40+
STAC_FASTAPI_CORS_ORIGINS: "*"
41+
42+
# Raster service (TiTiler)
43+
raster:
44+
enabled: true
45+
settings:
46+
resources:
47+
requests:
48+
cpu: "256m"
49+
memory: "1024Mi"
50+
limits:
51+
cpu: "768m"
52+
memory: "4096Mi"
53+
envVars:
54+
# Enable debug logging
55+
TITILER_DEBUG: "True"
56+
57+
# Vector service (TiPG)
58+
vector:
59+
enabled: true
60+
settings:
61+
resources:
62+
requests:
63+
cpu: "256m"
64+
memory: "1024Mi"
65+
limits:
66+
cpu: "768m"
67+
memory: "1536Mi"
68+
envVars:
69+
# Enable debug mode for integration tests
70+
TIPG_DEBUG: "True"
71+
72+
# STAC Browser
73+
browser:
74+
enabled: true
75+
settings:
76+
resources:
77+
requests:
78+
cpu: "50m"
79+
memory: "64Mi"
80+
limits:
81+
cpu: "200m"
82+
memory: "128Mi"
83+
84+
# Disable resource-intensive features for local development
85+
monitoring:
86+
enabled: false
87+
88+
autoscaling:
89+
enabled: false
90+
91+
# Simple ingress configuration (platform-specific parts overridden)
92+
ingress:
93+
enabled: true
94+
pathType: "Prefix"
95+
host: "localhost"
96+
tls:
97+
enabled: false # Simplify for local development

charts/eoapi/local-k3s-values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# k3s development and testing values for eoAPI
2+
# Inherits from local-base-values.yaml, only overrides k3s-specific settings
3+
# Usage: helm install eoapi ./charts/eoapi -f local-base-values.yaml -f local-k3s-values.yaml
4+
5+
# Ingress configuration for Traefik (k3s built-in)
6+
ingress:
7+
className: "traefik"
8+
annotations:
9+
traefik.ingress.kubernetes.io/router.entrypoints: web
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Local minikube development values for eoAPI
2+
# Inherits from local-base-values.yaml, only overrides minikube-specific settings
3+
# Usage: helm install eoapi ./charts/eoapi -f local-base-values.yaml -f local-minikube-values.yaml
4+
5+
# Ingress configuration for nginx (minikube default)
6+
ingress:
7+
className: "nginx"
8+
annotations:
9+
nginx.ingress.kubernetes.io/rewrite-target: /$2
10+
nginx.ingress.kubernetes.io/use-regex: "true"

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

Lines changed: 0 additions & 88 deletions
This file was deleted.

docs/installation/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ helm upgrade --install \
6868

6969
### Post-Installation
7070

71-
1. Enable ingress (for Minikube):
71+
1. Enable ingress (for Minikube only - k3s has Traefik built-in):
7272
```bash
7373
minikube addons enable ingress
7474
```

0 commit comments

Comments
 (0)