This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
220 lines (161 loc) · 9.37 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
.DEFAULT_GOAL := help
.PHONY: help
developer-setup: setup-source create-pre-commit-hooks ## Run this only once. Downloads github repos and creates pre-commit hooks.
setup-source:
echo "Installing glide"
mkdir $(GOPATH)/bin
curl https://glide.sh/get | sh
echo "Installing goimports"
go get golang.org/x/tools/cmd/goimports
echo "Cloning Repos"
cd .. && (git clone https://github.com/k8guard/k8guardlibs.git || true) && cd k8guardlibs && make deps
cd .. && (git clone https://github.com/k8guard/k8guard-discover.git || true) && cd k8guard-discover && make deps
cd .. && (git clone https://github.com/k8guard/k8guard-action.git || true) && cd k8guard-action && make deps
cd .. && (git clone https://github.com/k8guard/k8guard-report.git || true) && cd k8guard-report && make deps
echo "Creating config files"
cp .env-creds-template .env-creds
cp .env-template .env
cp minikube/action/k8guard-action-secrets.yaml.EXAMPLE minikube/action/k8guard-action-secrets.yaml
cp minikube/report/k8guard-report-secrets.yaml.EXAMPLE minikube/report/k8guard-report-secrets.yaml
update-source: ## git pulls origin/master on all the k8guard repos and updates dependencies.
@read -p "This will pull origin/master on all k8guard repos, please enter to continue " _
cd ../k8guardlibs && git checkout master && git pull origin master && make deps
cd ../k8guard-discover && git checkout master && git pull origin master && make deps
cd ../k8guard-action && git checkout master && git pull origin master && make deps
cd ../k8guard-report && git checkout master && git pull origin master && make deps
create-pre-commit-hooks: ## creates pre-commit hooks for formatting for all the repos.
cd ../k8guard-discover && make create-pre-commit-hooks
cd ../k8guard-action && make create-pre-commit-hooks
cd ../k8guardlibs && make create-pre-commit-hooks
cd ../k8guard-report && make create-pre-commit-hooks
build-discover: ## builds discover microservice from source.
cd ../k8guard-discover && make clean
cd ../k8guard-discover && make build
build-action: ## builds action microservice from source.
cd ../k8guard-action && make clean
cd ../k8guard-action && make build
build-report: ## builds report microservice from source.
cd ../k8guard-report && make clean
cd ../k8guard-report && make build
build-all: build-discover build-action build-report ## builds all the microservices from source.
build-action-local-docker:
cd ../k8guard-action && make build-docker
build-discover-local-docker:
cd ../k8guard-discover && make build-docker
build-report-local-docker:
cd ../k8guard-report && make build-docker
build-local-dockers: build-action-local-docker build-discover-local-docker build-report-local-docker ## Builds all the docker images locally from source code
#############################################################################
####### original docker compose using memcache/kafka/zookeeper #######
#############################################################################
clean-compose: clean-action-compose clean-discover-compose clean-report-compose clean-core-compose
clean-core-compose:
docker-compose -f docker-compose-core.yaml down
up-core-compose: clean-core-compose
docker-compose -f docker-compose-core.yaml up -d
clean-action-compose:
docker-compose -f docker-compose-action.yaml down
up-action-compose: clean-action-compose
docker-compose -f docker-compose-action.yaml build
docker-compose -f docker-compose-action.yaml up
up-action-compose-d: clean-action-compose
docker-compose -f docker-compose-action.yaml build
docker-compose -f docker-compose-action.yaml up -d
clean-discover-compose:
docker-compose -f docker-compose-discover.yaml down
up-discover-compose: clean-discover-compose
docker-compose -f docker-compose-discover.yaml build
docker-compose -f docker-compose-discover.yaml up
up-discover-compose-d: clean-discover-compose
docker-compose -f docker-compose-discover.yaml build
docker-compose -f docker-compose-discover.yaml up -d
clean-report-compose:
docker-compose -f docker-compose-report.yaml down
up-report-compose: clean-report-compose
docker-compose -f docker-compose-report.yaml build
docker-compose -f docker-compose-report.yaml up
up-report-compose-d: clean-report-compose
docker-compose -f docker-compose-report.yaml build
docker-compose -f docker-compose-report.yaml up -d
up-compose: up-core-compose up-action-compose-d up-discover-compose-d up-report-compose-d ## deploys all the microservices to dokcer-compose
####################################################################
####### lightweight docker compose using redis #######
####################################################################
clean-compose-lightweight: clean-action-compose-lightweight clean-discover-compose-lightweight clean-report-compose-lightweight clean-core-compose-lightweight
clean-core-compose-lightweight:
docker-compose -f docker-compose-core-lightweight.yaml down
up-core-compose-lightweight: clean-core-compose-lightweight
docker-compose -f docker-compose-core-lightweight.yaml up -d
clean-action-compose-lightweight:
docker-compose -f docker-compose-action-lightweight.yaml down
up-action-compose-lightweight: clean-action-compose-lightweight
docker-compose -f docker-compose-action-lightweight.yaml build
docker-compose -f docker-compose-action-lightweight.yaml up
up-action-compose-lightweight-d: clean-action-compose-lightweight
docker-compose -f docker-compose-action-lightweight.yaml build
docker-compose -f docker-compose-action-lightweight.yaml up -d
clean-discover-compose-lightweight:
docker-compose -f docker-compose-discover-lightweight.yaml down
up-discover-compose-lightweight: clean-discover-compose-lightweight
docker-compose -f docker-compose-discover-lightweight.yaml build
docker-compose -f docker-compose-discover-lightweight.yaml up
up-discover-compose-lightweight-d: clean-discover-compose-lightweight
docker-compose -f docker-compose-discover-lightweight.yaml build
docker-compose -f docker-compose-discover-lightweight.yaml up -d
clean-report-compose-lightweight:
docker-compose -f docker-compose-report-lightweight.yaml down
up-report-compose-lightweight: clean-report-compose-lightweight
docker-compose -f docker-compose-report-lightweight.yaml build
docker-compose -f docker-compose-report-lightweight.yaml up
up-report-compose-lightweight-d: clean-report-compose-lightweight
docker-compose -f docker-compose-report-lightweight.yaml build
docker-compose -f docker-compose-report-lightweight.yaml up -d
up-compose-lightweight: up-core-compose-lightweight up-action-compose-lightweight-d up-discover-compose-lightweight-d up-report-compose-lightweight-d ## deploys all the microservices to dokcer-compose
##################################################################################
####### original minikube deployment using memcache/kafka/zookepper #######
##################################################################################
clean-minikube: ## delete all pods and jobs on the minikube
kubectl delete -f minikube/core || true
kubectl delete -f minikube/report || true
kubectl delete -f minikube/discover-api || true
kubectl delete -f minikube/discover-cronjob || true
kubectl delete -f minikube/action || true
sclean-minikube: ## super clean minikube, delete minikube completely.
minikube delete
deploy-minikube: build-local-dockers ## Builds all docker images from source and deploys to minikube.
kubectl config use-context minikube
kubectl apply -f minikube/core
@read -p "Pausing ... Please press enter to continue " _
kubectl apply -f minikube/action
kubectl apply -f minikube/report
kubectl apply -f minikube/discover-api
kubectl apply -f minikube/discover-cronjob
clean-helm:
helm delete k8guard-chart
deploy-helm:
helm upgrade -i k8guard-chart helm -f helm/values.yaml
build-deploy-minikube: build-all deploy-minikube
####################################################################
####### lightweight minikube deployment using redis #######
####################################################################
clean-minikube-lightweight: ## delete all pods and jobs on the minikube
kubectl delete -f minikube/core-lightweight || true
kubectl delete -f minikube/report-lightweight || true
kubectl delete -f minikube/discover-api-lightweight || true
kubectl delete -f minikube/discover-cronjob-lightweight || true
kubectl delete -f minikube/action-lightweight || true
sclean-minikube-lightweight: sclean-minikube-lightweight ## super clean minikube, delete minikube completely.
deploy-minikube-lightweight: build-local-dockers ## Builds all docker images from source and deploys to minikube.
kubectl config use-context minikube
kubectl apply -f minikube/core-lightweight
@read -p "Pausing ... Please press enter to continue " _
kubectl apply -f minikube/action-lightweight
kubectl apply -f minikube/report-lightweight
kubectl apply -f minikube/discover-api-lightweight
kubectl apply -f minikube/discover-cronjob-lightweight
build-deploy-minikube-lightweight: build-all deploy-minikube-lightweight
build-deploy-helm: build-all deploy-helm
up-compose: up-core-compose up-action-compose-d up-discover-compose-d up-report-compose-d ## deploys all the microservices to dokcer-compose
sup-compose: build-all up ## super up (Builds all and then deploys up all the microservices in docker-compose)
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'