-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
349 lines (294 loc) · 13.1 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
CONFIG_PATH=${HOME}/.gitstafette/
LOCAL_VERSION = $(shell git describe --tags --always)
PACKAGE_VERSION ?= "0.1.0-$(LOCAL_VERSION)"
NAME := gitstafette
PROJECT_ID := kearos-gcp
MAIN_GO :=
.PHONY: init
init:
mkdir -p ${CONFIG_PATH}
.PHONY: docs
docs:
mkdocs serve
.PHONY: publish-docs
publish-docs:
mkdocs gh-deploy -b gh-pages
.PHONY: proto
proto:
protoc api/v1/*.proto \
--go_out=. \
--go_opt=paths=source_relative \
--proto_path=.
protoc api/health/v1/*.proto \
--go_out=. \
--go_opt=paths=source_relative \
--proto_path=.
protoc api/info/*.proto \
--go_out=. \
--go_opt=paths=source_relative \
--proto_path=.
.PHONY: compile
compile:
protoc api/v1/*.proto \
--go_out=. \
--go-grpc_out=. \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
--proto_path=.
protoc api/health/v1/*.proto \
--go_out=. \
--go-grpc_out=. \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
--proto_path=.
protoc api/info/*.proto \
--go_out=. \
--go-grpc_out=. \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
--proto_path=.
.PHONY: sbom-server
sbom-server:
cyclonedx-gomod app -json -output app-server.bom.json -licenses -main cmd/server .
.PHONY: sbom-client
sbom-client:
cyclonedx-gomod app -json -output app-client.bom.json -licenses -main cmd/client .
.PHONY: probe-1
probe-1:
grpc-health-probe -addr=localhost:50051
.PHONY: probe-1-tls
probe-1-tls:
grpc-health-probe -addr=localhost:50051 \
-tls \
-tls-ca-cert /mnt/d/Projects/homelab-rpi/certs/ca.pem \
-tls-client-cert /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local.pem \
-tls-client-key /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local-key.pem
.PHONY: probe-aws
probe-aws:
grpc-health-probe -addr=events.gitstafette.joostvdg.net:50051 \
-tls -tls-ca-cert=/home/joostvdg/projects/homelab/certs/ca.pem \
-tls-client-cert /home/joostvdg/projects/homelab/certs/gitstafette/client-local.pem \
-tls-client-key /home/joostvdg/projects/homelab/certs/gitstafette/client-local-key.pem \
-tls-server-name=events.gitstafette.joostvdg.net \
-v
.PHONY: gcurl-aws
gcurl-aws:
grpcurl \
-proto api/health/v1/healthcheck.proto \
-d '{"client_id": "local-grpcurl", "repository_id": "537845873", "last_received_event_id": 1}' \
events.gitstafette.joostvdg.net:50051 \
gitstafette.v1.Gitstafette.FetchWebhookEvents
.PHONY: gcurl-gcr-hc
gcurl-gcr-hc:
grpcurl \
-proto api/health/v1/healthcheck.proto \
gitstafette-server-qad46fd4qq-ez.a.run.app:443 \
grpc.health.v1.Health/Check
.PHONY: gcurl-local-1-tls
gcurl-local-1-tls:
grpcurl \
-proto api/v1/gitstafette.proto \
-d '{"client_id": "me", "repository_id": "537845873", "last_received_event_id": 1}' \
-cacert /mnt/d/Projects/homelab-rpi/certs/ca.pem \
-cert /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local.pem \
-key /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local-key.pem \
localhost:50051 \
gitstafette.v1.Gitstafette.FetchWebhookEvents
.PHONY: ghz-local-2
ghz-local-2:
ghz --insecure \
--proto api/v1/gitstafette.proto \
--call gitstafette.v1.Gitstafette.FetchWebhookEvents \
--data '{"client_id": "me", "repository_id": "537845873", "last_received_event_id": 1}' \
localhost:50052
.PHONY: server-1
server-1:
export OTEL_SERVICE_NAME=GSF-Server-1; export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317; go \
run cmd/server/main.go --repositories 537845873 \
--port 1323 --grpcPort 50051 --grpcHealthPort 50051
# export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317;\
# export OTEL_SERVICE_NAME=Server-1;\
# export OTEL_RESOURCE_ATTRIBUTES="service.namespace=gitstafette,service.name=Server,service.instance.id=Server-1";\
# export PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces;\
.PHONY: server-1-hmac
server-1-hmac:
go run cmd/server/main.go --repositories 537845873 \
--port 1323 --grpcPort 50051 \
--webhookHMAC=${GITSTAFETTE_HMAC}
.PHONY: server-1-tls
server-1-tls:
OAUTH_TOKEN="Q4HEg0ODGuie0wraqUn4" go run cmd/server/main.go --repositories "537845873,478599060" --port 1323 --grpcPort 50051 --grpcHealthPort 50051 \
--caFileLocation /mnt/d/Projects/homelab-rpi/certs/ca.pem \
--certFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/server-local.pem \
--certKeyFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/server-local-key.pem
.PHONY: server-2
server-2:
go run cmd/server/main.go --repositories 537845873 --port 1324 --grpcPort 50052
.PHONY: server-relay
server-relay:
OAUTH_TOKEN="abc" go run cmd/server/main.go --repositories 537845873 --port 1325 --grpcPort 50053\
--relayEnabled=true --relayHost=127.0.0.1 --relayPort=50051 \
--caFileLocation /mnt/d/Projects/homelab-rpi/certs/ca.pem \
--certFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/server-local.pem \
--certKeyFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/server-local-key.pem
.PHONY: server-relay-gcr
server-relay-gcr:
go run cmd/server/main.go --repositories 537845873 --port 1325 --grpcPort 50053\
--relayEnabled=true --relayHost=gitstafette.joostvdg.net --relayPort=443
.PHONY: test-client-1
test-client-1:
export OTEL_SERVICE_NAME=GSF-TEST-CLIENT-1; go run cmd/test-client/main.go --server "localhost" --port 50051
.PHONY: client-1
client-1:
export OTEL_SERVICE_NAME=GSF-Client-1; export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317; go \
run cmd/client/main.go --repo 537845873 --server "localhost" \
--port 50051 --insecure=true \
--streamWindow 15
# export OTEL_SERVICE_NAME=Client-1;\
# export OTEL_RESOURCE_ATTRIBUTES="service.namespace=gitstafette,service.name=Client,service.instance.id=Client-1";\
# export PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces;\
.PHONY: client-1-tls
client-1-tls:
export OAUTH_TOKEN="Q4HEg0ODGuie0wraqUn4";export OTEL_SERVICE_NAME=GSF-CLIENT-1; go run cmd/client/main.go --repo 537845873 --server "127.0.0.1" --port 50051 \
--secure \
--streamWindow 100 \
--healthCheckPort=8081 \
--clientId="local-1" \
--caFileLocation /mnt/d/Projects/homelab-rpi/certs/ca.pem \
--certFileLocation /home/joostvdg/projects/homelab/certs/gitstafette/client-local.pem \
--certKeyFileLocation /home/joostvdg/projects/homelab/certs/gitstafette/client-local-key.pem
client-aws: # need to set OAUTH_TOKEN
go run cmd/client/main.go --repo 537845873 --server "events.gitstafette.joostvdg.net" --port 50051 \
--secure \
--streamWindow 3600 \
--healthCheckPort=8081 \
--clientId="local-1" \
--caFileLocation /home/joostvdg/projects/homelab/certs/ca.pem \
--certFileLocation /home/joostvdg/projects/homelab/certs/gitstafette/client-local.pem \
--certKeyFileLocation /home/joostvdg/projects/homelab/certs/gitstafette/client-local-key.pem
client-aws-2: # need to set OAUTH_TOKEN
export OTEL_SERVICE_NAME=GSF-AWS_CLIENT-1; OTEL_ENABLED=true; go run cmd/client/main.go --repo 537845873 --server "events.gitstafette.joostvdg.net" --port 50051 \
--streamWindow 3600 \
--healthCheckPort=8081 \
--clientId="local-1" \
--caFileLocation /home/joostvdg/projects/homelab/certs/ca.pem \
--certFileLocation /home/joostvdg/projects/homelab/certs/gitstafette/client-local.pem \
--certKeyFileLocation /home/joostvdg/projects/homelab/certs/gitstafette/client-local-key.pem \
--relayEnabled=true \
--relayHost el-gitstafette-image-builds.gsf.svc.cluster.local \
--relayPath / \
--relayHealthCheckPath / \
--relayPort "8080" \
--relayProtocol http \
--relayInsecure "true" \
--secure
.PHONY: client-2-tls
client-2-tls:
OAUTH_TOKEN="Q4HEg0ODGuie0wraqUn4" go run cmd/client/main.go --repo 478599060 --server "127.0.0.1" --port 50051 \
--secure \
--streamWindow 100 \
--healthCheckPort=8082 \
--clientId="local-2" \
--caFileLocation /mnt/d/Projects/homelab-rpi/certs/ca.pem \
--certFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local.pem \
--certKeyFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local-key.pem
.PHONY: client-2
client-2:
go run cmd/client/main.go --repo 537845873 --server "127.0.0.1" --port 50052 --insecure=true
.PHONY: client-3
client-3:
go run cmd/client/main.go --repo 537845873 --server "127.0.0.1" -port- 50051 --relayEndpoint http://localhost:1324/v1/github/
.PHONY: client-cluster-send
client-cluster-send:
go run cmd/client/main.go --repo 537845873 --server gitstafette-server-qad46fd4qq-ez.a.run.app --port 443
.PHONY: client-cluster-receive
client-cluster-receive:
go run cmd/client/main.go --repo 537845873 --server "gitstafette.home.lab" --port 443 --insecure
.PHONY: client-cluster-receive-tls
client-cluster-receive-tls:
go run cmd/client/main.go --repo 583684693 --server "gitstafette.home.lab" --port 443 \
--secure \
--caFileLocation /mnt/d/Projects/homelab-rpi/certs/ca.pem \
--certFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local.pem \
--certKeyFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local-key.pem
.PHONY: client-gcr-receive
client-gcr-receive:
go run cmd/client/main.go \
--repo 537845873 \
--server "gitstafette-server-qad46fd4qq-ez.a.run.app" \
--port 443 --secure
.PHONY: client-local-server-relay-jenkins
client-local-server-relay-jenkins:
go run cmd/client/main.go --repo 537845873 --server "127.0.0.1" --port 50051 \
--secure \
--caFileLocation /mnt/d/Projects/homelab-rpi/certs/ca.pem \
--certFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local.pem \
--certKeyFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local-key.pem \
--relayEnabled=true \
--relayHost="cranberry.fritz.box" \
--relayPath="/github-webhook/" \
--relayHealthCheckPath="/login" \
--relayPort=443 \
--relayProtocol=https \
--relayInsecure=true \
--clientId="test-local"
# gitstafette.joostvdg.net
# gitstafette-server-qad46fd4qq-ez.a.run.app
.PHONY: client-gcr-server-relay-jenkins
client-gcr-server-relay-jenkins:
go run cmd/client/main.go --repo 537845873 --server gitstafette.joostvdg.net --port 443 \
--secure \
--caFileLocation /mnt/d/Projects/homelab-rpi/certs/ca.pem \
--certFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local.pem \
--certKeyFileLocation /mnt/d/Projects/homelab-rpi/certs/gitstafette/client-local-key.pem \
--relayEnabled=true \
--relayHost="cranberry.fritz.box" \
--relayPath="/github-webhook/" \
--relayHealthCheckPath="/login" \
--relayPort=443 \
--relayProtocol=https \
--relayInsecure=true \
--webhookHMAC=${GITSTAFETTE_HMAC} \
--clientId="test-local"
go-build-server:
CGO_ENABLED=0 go build -o bin/$(NAME) cmd/server/main.go
go-build-client:
CGO_ENABLED=0 go build -o bin/$(NAME) cmd/client/main.go
dxbuild-server:
docker buildx build . --platform linux/arm64,linux/amd64 --tag ghcr.io/joostvdg/gitstafette/server:${PACKAGE_VERSION}
dxpush-server:
docker buildx build . --platform linux/arm64,linux/amd64 --tag ghcr.io/joostvdg/gitstafette/server:${PACKAGE_VERSION} --push
dxbuild-client:
docker buildx build . -f ./Dockerfile.client --platform linux/arm64,linux/amd64 --tag ghcr.io/joostvdg/gitstafette/client:${PACKAGE_VERSION}
dxpush-client:
docker buildx build . -f ./Dockerfile.client --platform linux/arm64,linux/amd64 --tag ghcr.io/joostvdg/gitstafette/client:${PACKAGE_VERSION} --push
gpush: dxpush-server
docker pull ghcr.io/joostvdg/gitstafette/server:${PACKAGE_VERSION}
docker tag ghcr.io/joostvdg/gitstafette/server:${PACKAGE_VERSION} gcr.io/${PROJECT_ID}/${NAME}-server:${PACKAGE_VERSION}
docker push gcr.io/${PROJECT_ID}/${NAME}-server:${PACKAGE_VERSION}
gdeploy: gpush
gcloud run deploy gitstafette-server-http --image=gcr.io/${PROJECT_ID}/${NAME}-server:${PACKAGE_VERSION} \
--memory=128Mi --max-instances=1 --timeout=30 --project=${PROJECT_ID} \
--platform managed --allow-unauthenticated --region=europe-west4 \
--args="--repositories=537845873,478599060" \
--args="--port=8080" \
--args="--grpcPort=50051" \
--args="--relayEnabled=true" \
--args="--relayHost=gitstafette.joostvdg.net" \
--args="--relayPort=443" \
--args="--webhookHMAC=${GITSTAFETTE_HMAC}"
gcloud run deploy gitstafette-server \
--use-http2 \
--image=gcr.io/${PROJECT_ID}/${NAME}-server:${PACKAGE_VERSION} \
--memory=128Mi --max-instances=1 --timeout=300 --project=${PROJECT_ID}\
--platform managed --allow-unauthenticated --region=europe-west4 \
--args="--repositories=537845873,478599060" \
--args="--port=1323"\
--args="--grpcPort=8080" \
--args="--grpcHealthPort=8080"
helm-server:
helm upgrade gitstafette-server --install -n gitstafette --create-namespace ./helm/gitstafette-server --values ./helm/server-values.yaml
helm-client-local:
helm upgrade gitstafette-client-local --install -n gitstafette --create-namespace ./helm/gitstafette-client --values ./helm/client-local-values.yaml
helm-client-gcr:
helm upgrade gitstafette-client-gcr --install -n gitstafette --create-namespace ./helm/gitstafette-client --values ./helm/client-gcr-values.yaml