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
1341deploy :
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
3347tests :
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
3951integration :
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
4474lint :
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
5382validate-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
0 commit comments