-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (97 loc) · 4.21 KB
/
Makefile
File metadata and controls
109 lines (97 loc) · 4.21 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
SHELL := /usr/bin/env bash
# Colors for fancy output
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
RED := \033[0;31m
PURPLE := \033[0;35m
CYAN := \033[0;36m
WHITE := \033[1;37m
NC := \033[0m
# Default target
.DEFAULT_GOAL := help
# Help target
.PHONY: help
help: ## Show this help message
@echo -e "$(WHITE)Grounds Development Infrastructure (grounds-dev) - Local Kubernetes Development Environment$(NC)"
@echo -e "$(CYAN)Available targets:$(NC)"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# Prerequisites installation
.PHONY: install-prereqs
install-prereqs: ## Install missing prerequisites
@echo -e "$(BLUE)ℹ️ Checking and installing prerequisites...$(NC)"
@./scripts/install-prereqs.sh
# Main targets
.PHONY: up
up: install-prereqs ## Start the complete development environment
@echo -e "$(PURPLE)🚀 Starting Grounds Development Infrastructure environment...$(NC)"
@echo -e "$(BLUE)ℹ️ Creating k3d cluster and deploying services$(NC)"
@./cluster/bootstrap.sh
@echo -e "$(BLUE)ℹ️ Deploying Helm releases...$(NC)"
@helmfile sync
@echo -e "$(BLUE)ℹ️ Creating Velocity forwarding secret...$(NC)"
@./scripts/create-velocity-secret.sh
@echo -e "$(BLUE)ℹ️ Deploying manifests...$(NC)"
@kubectl apply -f manifests
@echo -e "$(BLUE)ℹ️ Waiting for Agones CRDs...$(NC)"
@./scripts/wait-for-crds.sh
@echo -e "$(GREEN)✅ Grounds Development Infrastructure environment is ready!$(NC)"
@echo -e "$(CYAN)📊 Run 'make status' to check deployment status$(NC)"
@echo -e "$(CYAN)🌐 Access dummy server at: http://localhost/demo$(NC)"
.PHONY: down
down: ## Stop and delete the development environment
@echo -e "$(YELLOW)⚠️ Stopping Grounds Development Infrastructure environment...$(NC)"
@k3d cluster delete dev || true
@echo -e "$(GREEN)✅ Grounds Development Infrastructure environment stopped$(NC)"
.PHONY: reset
reset: down up ## Clean teardown and fresh setup
@echo -e "$(GREEN)✅ Environment reset completed$(NC)"
.PHONY: status
status: ## Show cluster and deployment status
@echo -e "$(PURPLE)📊 Cluster Status$(NC)"
@echo -e "$(CYAN)Nodes:$(NC)"
@kubectl get nodes
@echo -e "\n$(CYAN)Pods by namespace:$(NC)"
@kubectl get pods -A
@echo -e "\n$(CYAN)Services:$(NC)"
@kubectl get services -A
@echo -e "\n$(CYAN)Ingress:$(NC)"
@kubectl get ingress -A
.PHONY: logs
logs: ## Show logs for all services
@echo -e "$(PURPLE)📋 Service Logs$(NC)"
@echo -e "$(CYAN)PostgreSQL logs:$(NC)"
@kubectl logs -n databases -l app.kubernetes.io/name=postgresql --tail=20 || true
@echo -e "\n$(CYAN)Agones logs:$(NC)"
@kubectl logs -n games -l app.kubernetes.io/name=agones --tail=20 || true
@echo -e "\n$(CYAN)Dummy HTTP Server logs:$(NC)"
@kubectl logs -n infra -l app=dummy-http-server --tail=20 || true
.PHONY: port-forward
port-forward: ## Port forward services to localhost
@echo -e "$(BLUE)ℹ️ Port forwarding services...$(NC)"
@echo -e "$(CYAN)PostgreSQL: localhost:5432$(NC)"
@echo -e "$(CYAN)Dummy HTTP Server: localhost:8080$(NC)"
@echo -e "$(YELLOW)⚠️ Run in separate terminals:$(NC)"
@echo -e "$(WHITE)kubectl port-forward -n databases svc/postgresql 5432:5432$(NC)"
@echo -e "$(WHITE)kubectl port-forward -n infra svc/dummy-http-server 8080:80$(NC)"
.PHONY: clean
clean: ## Clean up all resources
@echo -e "$(YELLOW)⚠️ Cleaning up all resources...$(NC)"
@k3d cluster delete dev || true
@rm -f kubeconfig || true
@if [ -f ~/.kube/config ]; then \
echo -e "$(BLUE)ℹ️ Cleaning k3d-dev from ~/.kube/config...$(NC)"; \
kubectl config delete-context k3d-dev || true; \
kubectl config delete-cluster k3d-dev || true; \
kubectl config delete-user admin@k3d-dev || true; \
echo -e "$(GREEN)✅ k3d-dev context removed from ~/.kube/config$(NC)"; \
fi
@echo -e "$(GREEN)✅ Cleanup completed$(NC)"
.PHONY: test
test: ## Test the deployment
@echo -e "$(PURPLE)🧪 Testing deployment...$(NC)"
@echo -e "$(BLUE)ℹ️ Testing cluster connectivity...$(NC)"
@kubectl cluster-info
@echo -e "$(BLUE)ℹ️ Testing dummy HTTP server...$(NC)"
@curl -s http://localhost/demo || echo -e "$(YELLOW)⚠️ Dummy server not accessible (may still be starting)$(NC)"
@echo -e "$(GREEN)✅ Tests completed$(NC)"