Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (73 loc) · 3.01 KB
/
Copy pathMakefile
File metadata and controls
92 lines (73 loc) · 3.01 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
NAMESPACE := webscraper
API_IMAGE := webscraper/api:local
WORKER_IMAGE := webscraper/worker:local
AWS_REGION := us-west-1
INFRA_DIR := WebScraperInfra
.PHONY: k8s-start k8s-build k8s-deploy k8s-up k8s-down k8s-status \
k8s-logs-api k8s-logs-worker k8s-url k8s-restart \
k8s-aws-auth k8s-aws-deploy k8s-aws-status \
k8s-aws-logs-api k8s-aws-logs-worker k8s-aws-url k8s-aws-down
## Start minikube (docker driver)
k8s-start:
minikube start --driver=docker
## Build both images directly into minikube's Docker daemon
k8s-build:
minikube image build -t $(API_IMAGE) ./WebScraperAPI
minikube image build -t $(WORKER_IMAGE) ./WebScraperWorker
## Apply all manifests (postgres first, wait for ready, then api + worker)
k8s-deploy:
kubectl apply -f k8s/local/namespace.yaml
kubectl apply -f k8s/local/secret.yaml
kubectl apply -f k8s/local/postgres.yaml
@echo "Waiting for postgres to be ready..."
kubectl wait --for=condition=ready pod -l app=postgres -n $(NAMESPACE) --timeout=90s
kubectl apply -f k8s/local/api.yaml
kubectl apply -f k8s/local/worker.yaml
## Full start: minikube + build + deploy
k8s-up: k8s-start k8s-build k8s-deploy
@echo ""
@echo "Cluster is up. API available at:"
@minikube service webscraper-api -n $(NAMESPACE) --url
## Rebuild images and restart both deployments (no cluster teardown)
k8s-restart:
$(MAKE) k8s-build
kubectl rollout restart deployment/webscraper-api -n $(NAMESPACE)
kubectl rollout restart deployment/webscraper-worker -n $(NAMESPACE)
## Tear down everything (deletes the namespace and all resources inside it)
k8s-down:
kubectl delete namespace $(NAMESPACE) --ignore-not-found
## Show all resources in the webscraper namespace
k8s-status:
kubectl get all -n $(NAMESPACE)
## Stream API logs
k8s-logs-api:
kubectl logs -n $(NAMESPACE) -l app=webscraper-api -f --all-containers
## Stream worker logs
k8s-logs-worker:
kubectl logs -n $(NAMESPACE) -l app=webscraper-worker -f
## Print the minikube URL for the API
k8s-url:
@minikube service webscraper-api -n $(NAMESPACE) --url
# ── AWS / EKS ────────────────────────────────────────────────────────────────
## Configure kubectl to point at the EKS cluster
k8s-aws-auth:
aws eks update-kubeconfig --region $(AWS_REGION) --name $(NAMESPACE)
## Deploy API and worker to EKS
k8s-aws-deploy: k8s-aws-auth
kubectl apply -f k8s/aws/
## Show all resources in the EKS webscraper namespace
k8s-aws-status:
kubectl get all -n $(NAMESPACE)
## Stream API logs from EKS
k8s-aws-logs-api:
kubectl logs -n $(NAMESPACE) -l app=webscraper-api -f
## Stream worker logs from EKS
k8s-aws-logs-worker:
kubectl logs -n $(NAMESPACE) -l app=webscraper-worker -f
## Print the ALB hostname for the API
k8s-aws-url:
@terraform -chdir=$(INFRA_DIR) output -raw alb_dns_name
@echo ""
## Tear down all app resources from EKS (leaves cluster intact)
k8s-aws-down:
kubectl delete namespace $(NAMESPACE) --ignore-not-found