-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (90 loc) · 4.28 KB
/
Copy pathMakefile
File metadata and controls
113 lines (90 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#
# This source file is part of the Stanford Spezi open source project
#
# SPDX-FileCopyrightText: 2026 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#
.PHONY: help dev dev-down dev-status \
prod-plan prod-apply prod-down prod-destroy prod-bootstrap prod-status \
prod-scale-down prod-scale-up \
argocd-password validate lint test
TOFU := tofu -chdir=terraform
KIND_CLUSTER := spezi-study-platform
BRANCH ?=
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ---------------------------------------------------------------------------
# Local development (KIND)
# ---------------------------------------------------------------------------
dev: ## Create KIND cluster and bootstrap ArgoCD + apps
@kind get clusters 2>/dev/null | grep -q '^$(KIND_CLUSTER)$$' || kind create cluster --name $(KIND_CLUSTER) --config tools/kind-config.yaml
python3 tools/setup.py $(if $(BRANCH),--branch $(BRANCH))
dev-status: ## Show ArgoCD Application sync status
kubectl get applications -n argocd
dev-down: ## Delete KIND cluster
kind delete cluster --name $(KIND_CLUSTER)
# ---------------------------------------------------------------------------
# Production (OpenTofu + GKE)
# ---------------------------------------------------------------------------
prod-plan: ## Preview infrastructure changes
$(TOFU) plan
prod-apply: ## Apply infrastructure changes
$(TOFU) apply
prod-down: ## Destroy GKE cluster only (keeps IP, VPC, IAM, secrets)
$(TOFU) destroy \
-target=google_container_node_pool.primary \
-target=google_container_cluster.primary
prod-destroy: ## Tear down all cloud infrastructure
@echo "This will destroy ALL cloud infrastructure (VPC, IP, IAM, secrets, cluster)."
@printf "Type 'destroy' to confirm: " && read ans && [ "$$ans" = "destroy" ] || (echo "Aborted."; exit 1)
$(TOFU) destroy
prod-bootstrap: ## Bootstrap ArgoCD on prod GKE cluster
python3 tools/setup.py --env prod
prod-status: ## Show ArgoCD Application sync status (prod context)
kubectl get applications -n argocd
prod-scale-down: ## Scale GKE node pool to 0
gcloud container clusters resize $$($(TOFU) output -raw cluster_name) \
--node-pool $$($(TOFU) output -raw cluster_name)-pool \
--num-nodes 0 \
--zone $$($(TOFU) output -raw cluster_zone) \
--project $$($(TOFU) output -raw project_id) \
--quiet
prod-scale-up: ## Scale GKE node pool to 1
gcloud container clusters resize $$($(TOFU) output -raw cluster_name) \
--node-pool $$($(TOFU) output -raw cluster_name)-pool \
--num-nodes 1 \
--zone $$($(TOFU) output -raw cluster_zone) \
--project $$($(TOFU) output -raw project_id) \
--quiet
# ---------------------------------------------------------------------------
# Shared
# ---------------------------------------------------------------------------
argocd-password: ## Print ArgoCD admin password
@kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d; echo
# ---------------------------------------------------------------------------
# Validation & Testing
# ---------------------------------------------------------------------------
OVERLAYS := infrastructure/dev infrastructure/prod apps/dev apps/prod \
bootstrap/dev bootstrap/prod argocd-apps/dev argocd-apps/prod
validate: ## Validate all Kustomize overlays build cleanly
@failed=0; \
for overlay in $(OVERLAYS); do \
echo "Building $$overlay..."; \
kubectl kustomize $$overlay > /dev/null || failed=1; \
done; \
if [ $$failed -ne 0 ]; then echo "Some overlays failed."; exit 1; fi
@echo "All overlays build successfully."
lint: ## Run kubeconform schema validation (with CRD schemas) on all overlays
@failed=0; \
for overlay in $(OVERLAYS); do \
echo "Validating $$overlay..."; \
kubectl kustomize $$overlay | kubeconform \
-strict -summary -output text \
-schema-location default \
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
-skip CustomResourceDefinition || failed=1; \
done; \
if [ $$failed -ne 0 ]; then exit 1; fi
test: ## Run smoke test (requires running cluster from 'make dev')
bash tools/smoke-test.sh