-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·402 lines (345 loc) · 13.5 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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
GOCMD=go
GOBUILD=$(GOCMD) build -buildvcs=false
GOCLEAN=$(GOCMD) clean
GOGET=$(GOCMD) get
GOTEST=$(GOCMD) test
BINARY_NAME_AKO=ako
BINARY_NAME_AKO_INFRA=ako-infra
BINARY_NAME_AKO_GATEWAY_API=ako-gateway-api
PACKAGE_PATH_AKO=github.com/vmware/load-balancer-and-ingress-services-for-kubernetes
REL_PATH_AKO=$(PACKAGE_PATH_AKO)/cmd/ako-main
REL_PATH_AKO_INFRA=$(PACKAGE_PATH_AKO)/cmd/infra-main
REL_PATH_AKO_GATEWAY_API=$(PACKAGE_PATH_AKO)/cmd/gateway-api
AKO_OPERATOR_IMAGE=ako-operator
ENDPOINTSLICES_ENABLED?="false"
define GetSupportabilityMatrix
$(shell node -p "require('./buildsettings.json').$(1)")
endef
AVI_MIN_VERSION:=$(call GetSupportabilityMatrix,avi.minVersion)
AVI_MAX_VERSION:=$(call GetSupportabilityMatrix,avi.maxVersion)
K8S_MIN_VERSION:=$(call GetSupportabilityMatrix,kubernetes.minVersion)
K8S_MAX_VERSION:=$(call GetSupportabilityMatrix,kubernetes.maxVersion)
AKO_VERSION:=v$(call GetSupportabilityMatrix,version)
AKO_LDFLAGS:="-X 'main.version=$(AKO_VERSION)' \
-X '$(PACKAGE_PATH_AKO)/internal/lib.aviMinVersion=$(AVI_MIN_VERSION)' \
-X '$(PACKAGE_PATH_AKO)/internal/lib.aviMaxVersion=$(AVI_MAX_VERSION)' \
-X '$(PACKAGE_PATH_AKO)/internal/lib.k8sMinVersion=$(K8S_MIN_VERSION)' \
-X '$(PACKAGE_PATH_AKO)/internal/lib.k8sMaxVersion=$(K8S_MAX_VERSION)'"
ifdef GOLANG_SRC_REPO
BUILD_GO_IMG=$(GOLANG_SRC_REPO)
else
BUILD_GO_IMG=golang:latest
endif
GO_IMG_TEST=golang:bullseye
.PHONY: glob-vars
glob-vars:
$(eval BUILD_ARG_AKO_LDFLAGS=--build-arg AKO_LDFLAGS=$(AKO_LDFLAGS))
ifndef BUILD_TAG
$(eval BUILD_TAG=$(shell ./hack/jenkins/get_build_version.sh "dummy" 0))
endif
ifndef BUILD_TIME
$(eval BUILD_TIME=$(shell date +%Y-%m-%d_%H:%M:%S_%Z))
endif
ifdef GOLANG_SRC_REPO
$(eval BUILD_ARG_GOLANG=--build-arg golang_src_repo=$(GOLANG_SRC_REPO))
else
$(eval BUILD_ARG_GOLANG=)
endif
ifdef PHOTON_SRC_REPO
$(eval BUILD_ARG_PHOTON=--build-arg photon_src_repo=$(PHOTON_SRC_REPO))
else
$(eval BUILD_ARG_PHOTON=)
endif
ifdef UBI_SRC_REPO
$(eval BUILD_ARG_UBI=--build-arg ubi_src_repo=$(UBI_SRC_REPO))
else
$(eval BUILD_ARG_UBI=)
endif
.PHONY: all
all: build docker
.PHONY: sync-crd-files
sync-crd-files:
cp ./helm/ako/crds/* ./ako-operator/helm/ako-operator/crds/
.PHONY: pre-build
pre-build: sync-crd-files
# builds
.PHONY: build
build: pre-build glob-vars
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(BUILD_GO_IMG) \
$(GOBUILD) \
-o /go/src/$(PACKAGE_PATH_AKO)/bin/$(BINARY_NAME_AKO) \
-ldflags $(AKO_LDFLAGS) \
-mod=vendor \
/go/src/$(REL_PATH_AKO)
.PHONY: build-infra
build-infra: pre-build glob-vars
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(BUILD_GO_IMG) \
$(GOBUILD) \
-o /go/src/$(PACKAGE_PATH_AKO)/bin/$(BINARY_NAME_AKO_INFRA) \
-ldflags $(AKO_LDFLAGS) \
-mod=vendor \
/go/src/$(REL_PATH_AKO_INFRA)
.PHONY: build-gateway-api
build-gateway-api: glob-vars
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(BUILD_GO_IMG) \
$(GOBUILD) \
-o /go/src/$(PACKAGE_PATH_AKO)/bin/$(BINARY_NAME_AKO_GATEWAY_API) \
-ldflags $(AKO_LDFLAGS) \
-mod=vendor \
/go/src/$(REL_PATH_AKO_GATEWAY_API)
.PHONY: build-local
build-local: pre-build
$(GOBUILD) \
-o bin/$(BINARY_NAME_AKO) \
-ldflags $(AKO_LDFLAGS) \
-mod=vendor \
./cmd/ako-main
.PHONY: build-local-infra
build-local-infra: pre-build
$(GOBUILD) \
-o bin/$(BINARY_NAME_AKO_INFRA) \
-ldflags $(AKO_LDFLAGS) \
-mod=vendor \
./cmd/infra-main
.PHONY: clean
clean:
$(GOCLEAN) -mod=vendor $(REL_PATH_AKO)
rm -f bin/$(BINARY_NAME_AKO)
.PHONY: deps
deps:
dep ensure -v
# docker images
.PHONY: docker
docker: glob-vars
sudo docker build \
-t $(BINARY_NAME_AKO):latest \
--label "BUILD_TAG=$(BUILD_TAG)" \
--label "BUILD_TIME=$(BUILD_TIME)" \
$(BUILD_ARG_GOLANG) $(BUILD_ARG_PHOTON) $(BUILD_ARG_AKO_LDFLAGS) \
-f Dockerfile.ako .
.PHONY: ako-infra-docker
ako-infra-docker: glob-vars
sudo docker build \
-t $(BINARY_NAME_AKO_INFRA):latest \
--label "BUILD_TAG=$(BUILD_TAG)" \
--label "BUILD_TIME=$(BUILD_TIME)" \
$(BUILD_ARG_GOLANG) $(BUILD_ARG_PHOTON) $(BUILD_ARG_AKO_LDFLAGS) \
-f Dockerfile.ako-infra .
.PHONY: ako-operator-docker
ako-operator-docker: glob-vars
sudo docker build \
-t $(AKO_OPERATOR_IMAGE):latest \
--label "BUILD_TAG=$(BUILD_TAG)" \
--label "BUILD_TIME=$(BUILD_TIME)" \
$(BUILD_ARG_GOLANG) $(BUILD_ARG_UBI) \
-f Dockerfile.ako-operator .
.PHONY: ako-gateway-api-docker
ako-gateway-api-docker: glob-vars
sudo docker build \
-t $(BINARY_NAME_AKO_GATEWAY_API):latest \
--label "BUILD_TAG=$(BUILD_TAG)" \
--label "BUILD_TIME=$(BUILD_TIME)" \
$(BUILD_ARG_GOLANG) $(BUILD_ARG_PHOTON) $(BUILD_ARG_AKO_LDFLAGS) \
-f Dockerfile.ako-gateway-api .
# tests
.PHONY: k8stest
k8stest:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/k8stest -failfast -coverprofile cover-1.out -coverpkg=./...
.PHONY: integrationtest
integrationtest:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/integrationtest -failfast -coverprofile cover-2.out -coverpkg=./...
.PHONY: ingresstests
ingresstests:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/ingresstests -failfast -timeout 0 -coverprofile cover-3.out -coverpkg=./...
.PHONY: oshiftroutetests
oshiftroutetests:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/oshiftroutetests -failfast -timeout 0 -coverprofile cover-4.out -coverpkg=./...
.PHONY: bootuptests
bootuptests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/bootuptests -failfast -coverprofile cover-5.out -coverpkg=./...
.PHONY: multicloudtests
multicloudtests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/multicloudtests -failfast -coverprofile cover-6.out -coverpkg=./...
.PHONY: servicesapitests
servicesapitests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/servicesapitests -failfast -coverprofile cover-7.out -coverpkg=./...
.PHONY: advl4tests
advl4tests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/advl4tests -failfast -coverprofile cover-8.out -coverpkg=./...
.PHONY: namespacesynctests
namespacesynctests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/namespacesynctests -failfast -timeout 0 -coverprofile cover-9.out -coverpkg=./...
.PHONY: misc
temp:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/temp -failfast
.PHONY: npltests
npltests:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/npltests -failfast -coverprofile cover-10.out -coverpkg=./...
.PHONY: evhtests
evhtests:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/evhtests -failfast -timeout 0 -coverprofile cover-11.out -coverpkg=./...
.PHONY: vippernstests
vippernstests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/evhtests -failfast -timeout 0 -isVipPerNS=true -coverprofile cover-12.out -coverpkg=./...
.PHONY: dedicatedevhtests
dedicatedevhtests:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/dedicatedevhtests -failfast -timeout 0 -coverprofile cover-13.out -coverpkg=./...
.PHONY: dedicatedvippernstests
dedicatedvippernstests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/dedicatedevhtests -failfast -timeout 0 -isVipPerNS=true -coverprofile cover-14.out -coverpkg=./...
.PHONY: dedicatedvstests
dedicatedvstests:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/dedicatedvstests -failfast -timeout 0 -coverprofile cover-15.out -coverpkg=./...
.PHONY: infratests
infratests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/infratests -failfast -timeout 0
# .PHONY: multiclusteringresstests
# multiclusteringresstests:
# sudo docker run \
# -w=/go/src/$(PACKAGE_PATH_AKO) \
# -v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(BUILD_GO_IMG) \
# $(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/multiclusteringresstests -failfast -coverprofile cover-16.out -coverpkg=./...
.PHONY: hatests
hatests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/hatests -failfast -coverprofile cover-17.out -coverpkg=./...
.PHONY: calicotests
calicotests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/cnitests -failfast -cniPlugin=calico -coverprofile cover-18.out -coverpkg=./...
.PHONY: ciliumtests
ciliumtests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/cnitests -failfast -cniPlugin=cilium -coverprofile cover-19.out -coverpkg=./...
.PHONY: helmtests
helmtests:
sudo docker run \
-u root:root \
-v $(PWD)/helm/ako:/apps \
-v $(PWD)/tests/helmtests:/apps/tests \
avi-buildops-docker-registry-02.eng.vmware.com:5000/avi-buildops/helmunittest/helm-unittest:3.11.1-0.3.0 .
.PHONY: gatewayapitests
gatewayapitests:
sudo docker run \
-e ENDPOINTSLICES_ENABLED=$(ENDPOINTSLICES_ENABLED) \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -mod=vendor $(PACKAGE_PATH_AKO)/tests/gatewayapitests/... -failfast -timeout 0 -coverprofile cover-20.out -coverpkg=./...
.PHONY: multitenancytests
multitenancytests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -mod=vendor $(PACKAGE_PATH_AKO)/tests/multitenancytests -failfast -timeout 0 -coverprofile cover-21.out -coverpkg=./...
.PHONY: urltests
urltests:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/urltests -failfast -coverprofile cover-22.out -coverpkg=./...
.PHONY: int_test
int_test:
make -j 1 k8stest integrationtest ingresstests evhtests vippernstests dedicatedevhtests dedicatedvippernstests oshiftroutetests bootuptests multicloudtests advl4tests namespacesynctests servicesapitests npltests misc dedicatedvstests hatests calicotests ciliumtests helmtests infratests urltests gatewayapitests
.PHONY: multi_tenancy
multi_tenancy:
make -j 1 multitenancytests
.PHONY: eps_enabled
eps_enabled:
make -j 1 k8stest integrationtest ingresstests evhtests dedicatedevhtests oshiftroutetests npltests dedicatedvstests gatewayapitests ENDPOINTSLICES_ENABLED="true"
.PHONY: scale_test
scale_test:
sudo docker run \
-w=/go/src/$(PACKAGE_PATH_AKO) \
--mount type=bind,source=$(TestbedFilePath),target=$(TestbedFilePath) \
--mount type=bind,source=$(KubeConfigFileName),target=$(KubeConfigFileName) \
-v $(PWD):/go/src/$(PACKAGE_PATH_AKO) $(GO_IMG_TEST) \
$(GOTEST) -v -mod=vendor $(PACKAGE_PATH_AKO)/tests/scaletest -failfast -test.timeout=$(Timeout) -kubeConfigFileName=$(KubeConfigFileName) -testbedFileName=$(TestbedFilePath) -numGoRoutines=$(NumGoRoutines) -numOfLBSvc=$(NumOfLBSvc) -numOfIng=$(NumOfIng)
# linting and formatting
GO_FILES := $(shell find . -type d -path ./vendor -prune -o -type f -name '*.go' -print)
.PHONY: fmt
fmt:
@echo
@echo "Formatting Go files"
@gofmt -s -l -w $(GO_FILES)
.golangci-bin:
@echo "Installing Golangci-lint"
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $@ v1.55.2
.PHONY: golangci
golangci: .golangci-bin
@echo "Running golangci"
@GOOS=linux GOGC=1 .golangci-bin/golangci-lint run -c .golangci.yml
.PHONY: golangci-fix
golangci-fix: .golangci-bin
@echo "Running golangci-fix"
@GOOS=linux GOGC=1 .golangci-bin/golangci-lint run -c .golangci.yml --fix