-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
135 lines (110 loc) · 3.69 KB
/
Makefile
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
SHELL := /bin/bash
GREEN=$(shell echo -e "\033[0;32m")
RED=$(shell echo -e "\033[0;31m")
YELLOW=$(shell echo -e "\033[0;33m")
NOCOLOR=$(shell echo -e "\033[0m")
HEADER=$(GREEN)Recipe:$(NOCOLOR)
include .env
export
.PHONY: help
default: help
help: ## show this help
@echo '$(HEADER) help'
@echo 'usage: make [target] ...'
@echo ''
@echo 'targets:'
@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*##/#/' | column -t -c 2 -s '#'
.PHONY: start
start: ## start all services
@echo '$(HEADER) start'
docker-compose -f docker-compose.cs.yml up
.PHONY: sl
sl: ## start start in local mode
@echo '$(HEADER) start'
docker-compose -f docker-compose.local.yml up
.PHONY: startd
startd: ## start all services as a daemon
@echo '$(HEADER) startd'
docker-compose up -d
.PHONY: logs
logs: ## tail all logs
@echo '$(HEADER) logs'
docker-compose logs -f
.PHONY: stop
stop: ## stop all services
@echo '$(HEADER) stop'
docker-compose down
.PHONY: build
build: ## build
@echo '$(HEADER) build'
@cd backend && docker build . -t talk2robots_backend:latest
.PHONY: test
test: ## test
@echo '$(HEADER) test'
pushd backend && go test -v ./... && popd
.PHONY: cleanup
cleanup: ## cleanup
@echo '$(HEADER) cleanup'
docker system prune -a
## Kubernetes
.PHONY: dologin
dologin: ## login to digital ocean
@echo '$(HEADER) dologin'
doctl auth init -t $(DO_PAT)
doctl kubernetes cluster list
doctl kubernetes cluster kubeconfig save k8s-do-sfo3-talk2robots-prod
.PHONY: klogin
klogin: ## login to k8s
@echo '$(HEADER) klogin'
doctl kubernetes cluster kubeconfig save k8s-do-sfo3-talk2robots-prod
.PHONY: klogs
klogs: ## tail app k8s logs
@echo '$(HEADER) klogs'
kubectl logs -f -n talk2robots -l app=backend --tail=100 --all-containers=true --ignore-errors=true --timestamps=true
.PHONY: klogsredis
klogsredis: ## tail redis k8s logs
@echo '$(HEADER) klogsredis'
kubectl logs -f -n stateful -l app=redis --tail=100 --all-containers=true --ignore-errors=true --timestamps=true
.PHONY: configure-helm
configure-helm: ## configure helm
@echo '$(HEADER) configure-helm'
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update ingress-nginx
helm search repo ingress-nginx
helm repo add datadog https://helm.datadoghq.com
helm repo update datadog
helm search repo datadog
.PHONY: apply-ingress-resources
apply-ingress-resources: ## apply ingress resources
@echo '$(HEADER) apply-ingress-resources'
cat ./infra/ingress/resources.yaml | kubectl apply -f -
.PHONY: update-ingress
update-ingress: ## upgrade ingress controller
helm upgrade ingress-nginx ingress-nginx/ingress-nginx --version 4.5.2 \
-n ingress-nginx \
--values ./infra/ingress/helm-values.yaml
.PHONY: tail-ingress-logs
tail-ingress-logs: ## tail ingress logs
kubectl logs -f -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx --tail=100
.PHONY: grafana
grafana: ## open grafana
@echo '$(HEADER) grafana'
kubectl --namespace monitoring port-forward svc/kube-prom-stack-grafana 3000:80
.PHONY: redis
redis: ## open redis
@echo '$(HEADER) redis'
echo "redis-cli -P 6380"
kubectl --namespace stateful port-forward svc/redis 6380:6379
.PHONY: update-datadog
update-datadog: ## upgrade datadog
helm upgrade datadog-agent datadog/datadog \
-n default \
--set MONGO_HOST=$(MONGO_HOST),MONGO_PASSWORD=$(DATADOG_MONGO_PASS) \
--values ./infra/observability/datadog.yaml
.PHONY: mongo
mongo: ## remind to curl ifconfig.me and open mongo
@echo '$(HEADER) mongo'
echo $$(curl ifconfig.me)
@echo 'remember to add the ip to the mongo whitelist at https://cloud.digitalocean.com/databases/'
connection_string=$$(kubectl get secret --namespace default admin -o jsonpath="{.data.mongo}" | base64 --decode) && \
mongo $${connection_string}