-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
312 lines (287 loc) · 9.09 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# Copyright 2022 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# __ __ _ _ _
# \ \ / /_ _ _ __(_) __ _| |__ | | ___ ___
# \ \ / / _` | '__| |/ _` | '_ \| |/ _ \ __|
# \ V / (_| | | | | (_| | |_) | | __\__ \
# \_/ \__,_|_| |_|\__,_|_.__/|_|\___|___/
#
PROJECT=$(shell gcloud config list --format 'value(core.project)')
LOCATION=us-central1
REPOSITORY=space-agon
REGISTRY=${LOCATION}-docker.pkg.dev/${PROJECT}/${REPOSITORY}
TAG=0.000004
FRONTEND_IMG=space-agon-frontend
DIRECTOR_IMG=space-agon-director
DEDICATED_IMG=space-agon-dedicated
MMF_IMG=space-agon-mmf
AGONES_NS:=agones-system
OM_NS:=open-match
AGONES_VER:=1.45.0
OM_VER:=1.8.1
K8S_VERSION:=1.31
# _____ _
# |_ _|_ _ _ __ __ _ ___| |_ ___
# | |/ _` | '__/ _` |/ _ \ __/ __|
# | | (_| | | | (_| | __/ |_\__ \
# |_|\__,_|_| \__, |\___|\__|___/
# |___/
# help output
.PHONY: help
help:
@echo ""
@echo "Build Docker images in local environment"
@echo " make build-local"
@echo ""
@echo "Build Docker images"
@echo " make build"
@echo ""
@echo "Create GKE Cluster"
@echo " make gcloud-test-cluster"
@echo ""
@echo "Add Helm Repositories"
@echo " make helm-repo-add"
@echo ""
@echo "Remove Helm Repositories"
@echo " make helm-repo-remove"
@echo ""
@echo "Install Agones in local-cluster"
@echo " make agones-install-local"
@echo ""
@echo "Install Agones"
@echo " make agones-install"
@echo ""
@echo "Install Open Match in local-cluster"
@echo " make openmatch-install-local"
@echo ""
@echo "Install Open Match"
@echo " make openmatch-install"
@echo ""
@echo "Install Space Agon"
@echo " make install"
@echo ""
@echo "Install Space Agon on minikube"
@echo " make install-local"
@echo ""
@echo "Uninstall Agones"
@echo " make agones-uninstall"
@echo ""
@echo "Uninstall Open Match"
@echo " make openmatch-uninstall"
@echo ""
@echo "Upgrade Space Agon parameters"
@echo " make upgrade"
@echo ""
@echo "Uninstall Space Agon"
@echo " make uninstall"
@echo ""
@echo "Setup skaffold for GKE"
@echo " make skaffold-setup"
@echo ""
@echo "Setup skaffold for local cluster"
@echo " make skaffold-setup-local"
@echo ""
@echo "Run unit test"
@echo " make test"
@echo ""
@echo "Run integration test"
@echo " make integration-test"
@echo ""
# build space-agon docker images in local
.PHONY: build-local
build-local:
./scripts/build.sh test \
${TAG} \
${FRONTEND_IMG} \
${DEDICATED_IMG} \
${DIRECTOR_IMG} \
${MMF_IMG} \
${REGISTRY}
# build space-agon docker images
.PHONY: build
build:
./scripts/build.sh develop \
${TAG} \
${FRONTEND_IMG} \
${DEDICATED_IMG} \
${DIRECTOR_IMG} \
${MMF_IMG} \
${REGISTRY}
# create gke cluster
.PHONY: gcloud-test-cluster
gcloud-test-cluster: GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT ?= 4
gcloud-test-cluster: GCP_CLUSTER_NODEPOOL_MACHINETYPE ?= e2-standard-4
gcloud-test-cluster: NETWORK ?= default
gcloud-test-cluster:
./scripts/create-cluster.sh ${GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT} \
${GCP_CLUSTER_NODEPOOL_MACHINETYPE} \
${LOCATION} \
${NETWORK} \
${K8S_VERSION}
.PHONY: helm-repo-add
helm-repo-add:
helm repo add $(AGONES_NS) https://agones.dev/chart/stable
helm repo add $(OM_NS) https://open-match.dev/chart/stable
helm repo update
.PHONY: helm-repo-remove
helm-repo-remove:
helm repo remove $(AGONES_NS)
helm repo remove $(OM_NS)
# install agones in local-cluster
.PHONY: agones-install-local
agones-install-local:
helm install $(AGONES_NS) --namespace $(AGONES_NS) \
--create-namespace $(AGONES_NS)/agones \
--version $(AGONES_VER) \
--set agones.ping.install=false \
--set agones.controller.replicas=1 \
--set agones.extensions.replicas=1 \
--set agones.allocator.replicas=0
# install agones
.PHONY: agones-install
agones-install:
helm install ${AGONES_NS} --namespace ${AGONES_NS} \
--create-namespace $(AGONES_NS)/agones \
--version ${AGONES_VER}
# uninstall agones and agones resources
.PHONY: agones-uninstall
agones-uninstall:
helm uninstall $(AGONES_NS) --namespace $(AGONES_NS)
kubectl delete namespace $(AGONES_NS)
# install open-match in local-cluster
.PHONY: openmatch-install-local
openmatch-install-local:
helm install $(OM_NS) \
--create-namespace --namespace $(OM_NS) $(OM_NS)/open-match \
--version $(OM_VER) \
--set open-match-customize.enabled=true \
--set open-match-customize.evaluator.enabled=true \
--set open-match-customize.evaluator.replicas=1 \
--set open-match-override.enabled=true \
--set open-match-core.swaggerui.enabled=false \
--set global.kubernetes.horizontalPodAutoScaler.frontend.maxReplicas=1 \
--set global.kubernetes.horizontalPodAutoScaler.backend.maxReplicas=1 \
--set global.kubernetes.horizontalPodAutoScaler.query.minReplicas=1 \
--set global.kubernetes.horizontalPodAutoScaler.query.maxReplicas=1 \
--set global.kubernetes.horizontalPodAutoScaler.evaluator.maxReplicas=1 \
--set query.replicas=1 \
--set frontend.replicas=1 \
--set backend.replicas=1 \
--set redis.master.resources.requests.cpu=0.1 \
--set redis.replica.replicaCount=0 \
--set redis.metrics.enabled=false
# install open-match
.PHONY: openmatch-install
openmatch-install:
helm install ${OM_NS} --create-namespace --namespace \
${OM_NS} $(OM_NS)/open-match \
--version ${OM_VER} \
--set open-match-customize.enabled=true \
--set open-match-customize.evaluator.enabled=true \
--set open-match-customize.evaluator.replicas=1 \
--set open-match-override.enabled=true \
--set open-match-core.swaggerui.enabled=false \
--set redis.sentinel.enabled=false \
--set redis.master.resources.requests.cpu=0.1 \
--set redis.master.persistence.enabled=false \
--set redis.replica.replicaCount=0 \
--set redis.metrics.enabled=false
# uninstall open-match
.PHONY: openmatch-uninstall
openmatch-uninstall:
helm uninstall -n ${OM_NS} ${OM_NS}
kubectl delete namespace ${OM_NS}
.PHONY: skaffold-setup-local
skaffold-setup-local:
./scripts/setup-skaffold.sh \
${PROJECT} \
local \
${FRONTEND_IMG} \
${DEDICATED_IMG} \
${DIRECTOR_IMG} \
${MMF_IMG} \
${LOCATION}
.PHONY: skaffold-setup
skaffold-setup:
./scripts/setup-skaffold.sh \
${PROJECT} \
${REGISTRY} \
${FRONTEND_IMG} \
${DEDICATED_IMG} \
${DIRECTOR_IMG} \
${MMF_IMG} \
${LOCATION}
# install space-agon itself
.PHONY: install
install:
helm install space-agon \
-f install/helm/space-agon/values.yaml \
--set frontend.image.repository="${REGISTRY}/${FRONTEND_IMG}" \
--set frontend.image.tag=${TAG} \
--set dedicated.image.repository="${REGISTRY}/${DEDICATED_IMG}" \
--set dedicated.image.tag=${TAG} \
--set director.image.repository="${REGISTRY}/${DIRECTOR_IMG}" \
--set director.image.tag=${TAG} \
--set mmf.image.repository="${REGISTRY}/${MMF_IMG}" \
--set mmf.image.tag=${TAG} \
--set frontend.replicas=1 \
--set dedicated.replicas=2 \
--set mmf.replicas=1 \
--set dedicated.resources.limits.cpu="500m" \
--set dedicated.resources.limits.memory="200Mi" \
--set dedicated.resources.requests.cpu="500m" \
--set dedicated.resources.requests.memory="200Mi" \
--set dedicated.autoscaler.buffer.bufferSize=2 \
--set dedicated.autoscaler.buffer.minReplicas=0 \
--set dedicated.autoscaler.buffer.maxReplicas=50 \
./install/helm/space-agon
.PHONY: install-local
install-local:
helm install space-agon \
-f install/helm/space-agon/values.yaml \
--set frontend.image.repository="local/${FRONTEND_IMG}" \
--set frontend.image.tag=${TAG} \
--set dedicated.image.repository="local/${DEDICATED_IMG}" \
--set dedicated.image.tag=${TAG} \
--set director.image.repository="local/${DIRECTOR_IMG}" \
--set director.image.tag=${TAG} \
--set mmf.image.repository="local/${MMF_IMG}" \
--set mmf.image.tag=${TAG} \
--set frontend.replicas=1 \
--set dedicated.replicas=1 \
--set mmf.replicas=1 \
--set dedicated.resources.limits.cpu="100m" \
--set dedicated.resources.limits.memory="100Mi" \
--set dedicated.resources.requests.cpu="100m" \
--set dedicated.resources.requests.memory="100Mi" \
--set dedicated.autoscaler.buffer.bufferSize=1 \
--set dedicated.autoscaler.buffer.minReplicas=0 \
--set dedicated.autoscaler.buffer.maxReplicas=1 \
./install/helm/space-agon
# uninstall space-agon itself
.PHONY: uninstall
uninstall:
helm uninstall space-agon
# upgrade space-agon after changing parameters
.PHONY: upgrade
upgrade:
helm upgrade space-agon -f install/helm/space-agon/values.yaml ./install/helm/space-agon
# unit test
.PHONY: test
test:
go test ./frontend/ ./mmf/ ./director/ ./dedicated/ ./game/protostream/
# integration test
.PHONY: integration-test
integration-test:
go test -count=1 -v -timeout 60s test/integration_test.go