forked from kubeovn/kube-ovn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
586 lines (489 loc) · 24.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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
GO_VERSION = 1.19
SHELL=/bin/bash
REGISTRY = kubeovn
DEV_TAG = dev
RELEASE_TAG = $(shell cat VERSION)
COMMIT = git-$(shell git rev-parse --short HEAD)
DATE = $(shell date +"%Y-%m-%d_%H:%M:%S")
GOLDFLAGS = "-w -s -extldflags '-z now' -X github.com/kubeovn/kube-ovn/versions.COMMIT=$(COMMIT) -X github.com/kubeovn/kube-ovn/versions.VERSION=$(RELEASE_TAG) -X github.com/kubeovn/kube-ovn/versions.BUILDDATE=$(DATE)"
CONTROL_PLANE_TAINTS = node-role.kubernetes.io/master node-role.kubernetes.io/control-plane
MULTUS_IMAGE = ghcr.io/k8snetworkplumbingwg/multus-cni:stable
MULTUS_YAML = https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/deployments/multus-daemonset.yml
CILIUM_VERSION = 1.11.6
CILIUM_IMAGE_REPO = quay.io/cilium/cilium
VPC_NAT_GW_IMG = $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG)
E2E_NETWORK = bridge
ifneq ($(VLAN_ID),)
E2E_NETWORK = kube-ovn-vlan
endif
# ARCH could be amd64,arm64
ARCH = amd64
.PHONY: build-go
build-go:
go mod tidy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-cmd -ldflags $(GOLDFLAGS) -v ./cmd
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-webhook -ldflags $(GOLDFLAGS) -v ./cmd/webhook
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(CURDIR)/dist/images/test-server -ldflags $(GOLDFLAGS) -v ./test/server
.PHONY: build-go-windows
build-go-windows:
go mod tidy
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/windows/kube-ovn.exe -ldflags $(GOLDFLAGS) -v ./cmd/windows/cni
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/windows/kube-ovn-daemon.exe -ldflags $(GOLDFLAGS) -v ./cmd/windows/daemon
.PHONY: build-go-arm
build-go-arm:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-cmd -ldflags $(GOLDFLAGS) -v ./cmd
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-webhook -ldflags $(GOLDFLAGS) -v ./cmd/webhook
.PHONY: build-dev
build-dev: build-go
docker build --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(DEV_TAG) -f dist/images/Dockerfile dist/images/
.PHONY: build-dpdk
build-dpdk:
docker buildx build --platform linux/amd64 -t $(REGISTRY)/kube-ovn-dpdk:19.11-$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile.dpdk1911 dist/images/
.PHONY: base-amd64
base-amd64:
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64 -o type=docker -f dist/images/Dockerfile.base dist/images/
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 --build-arg NO_AVX512=true -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64-no-avx512 -o type=docker -f dist/images/Dockerfile.base dist/images/
.PHONY: base-amd64-dpdk
base-amd64-dpdk:
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64-dpdk -o type=docker -f dist/images/Dockerfile.base-dpdk dist/images/
.PHONY: base-arm64
base-arm64:
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 -o type=docker -f dist/images/Dockerfile.base dist/images/
.PHONY: image-kube-ovn
image-kube-ovn: build-go
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-no-avx512 -o type=docker -f dist/images/Dockerfile.no-avx512 dist/images/
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-dpdk -o type=docker -f dist/images/Dockerfile.dpdk dist/images/
.PHONY: image-debug
image-debug: build-go
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:debug -o type=docker -f dist/images/Dockerfile.debug dist/images/
.PHONY: image-vpc-nat-gateway
image-vpc-nat-gateway:
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway
.PHONY: image-centos-compile
image-centos-compile:
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/centos7-compile:$(RELEASE_TAG) -o type=docker -f dist/images/compile/centos7/Dockerfile fastpath/
# docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/centos8-compile:$(RELEASE_TAG) -o type=docker -f dist/images/compile/centos8/Dockerfile fastpath/
.PHOONY: image-test
image-test: build-go
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/test:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile.test dist/images/
.PHONY: release
release: lint image-kube-ovn image-vpc-nat-gateway image-centos-compile
.PHONY: release-arm
release-arm: build-go-arm
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway
.PHONY: push-dev
push-dev:
docker push $(REGISTRY)/kube-ovn:$(DEV_TAG)
.PHONY: push-release
push-release: release
docker push $(REGISTRY)/kube-ovn:$(RELEASE_TAG)
.PHONY: tar-kube-ovn
tar-kube-ovn:
docker save $(REGISTRY)/kube-ovn:$(RELEASE_TAG) $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-no-avx512 -o kube-ovn.tar
.PHONY: tar-vpc-nat-gateway
tar-vpc-nat-gateway:
docker save $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o vpc-nat-gateway.tar
.PHONY: tar-centos-compile
tar-centos-compile:
docker save $(REGISTRY)/centos7-compile:$(RELEASE_TAG) -o centos7-compile.tar
# docker save $(REGISTRY)/centos8-compile:$(RELEASE_TAG) -o centos8-compile.tar
.PHONY: tar
tar: tar-kube-ovn tar-vpc-nat-gateway tar-centos-compile
.PHONY: base-tar-amd64
base-tar-amd64:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64 $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64-no-avx512 -o image-amd64.tar
.PHONY: base-tar-amd64-dpdk
base-tar-amd64-dpdk:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64-dpdk -o image-amd64-dpdk.tar
.PHONY: base-tar-arm64
base-tar-arm64:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 -o image-arm64.tar
define docker_ensure_image_exists
@if ! docker images --format "{{.Repository}}:{{.Tag}}" | grep "^$(1)$$" >/dev/null; then \
docker pull "$(1)"; \
fi
endef
define docker_rm_container
@docker ps -a -f name="$(1)" --format "{{.ID}}" | while read c; do docker rm -f $$c; done
endef
define docker_network_info
$(eval VAR_PREFIX = $(shell echo $(1) | tr '[:lower:]' '[:upper:]'))
$(eval $(VAR_PREFIX)_IPV4_SUBNET = $(shell docker network inspect $(1) -f "{{(index .IPAM.Config 0).Subnet}}"))
$(eval $(VAR_PREFIX)_IPV6_SUBNET = $(shell docker network inspect $(1) -f "{{(index .IPAM.Config 1).Subnet}}"))
$(eval $(VAR_PREFIX)_IPV4_GATEWAY = $(shell docker network inspect $(1) -f "{{(index .IPAM.Config 0).Gateway}}"))
$(eval $(VAR_PREFIX)_IPV6_GATEWAY = $(shell docker network inspect $(1) -f "{{(index .IPAM.Config 1).Gateway}}"))
$(eval $(VAR_PREFIX)_IPV6_GATEWAY := $(shell docker exec kube-ovn-control-plane ip -6 route show default | awk '{print $$3}'))
$(eval $(VAR_PREFIX)_IPV4_EXCLUDE_IPS = $(shell docker network inspect $(1) -f '{{range .Containers}},{{index (split .IPv4Address "/") 0}}{{end}}' | sed 's/^,//'))
$(eval $(VAR_PREFIX)_IPV6_EXCLUDE_IPS = $(shell docker network inspect $(1) -f '{{range .Containers}},{{index (split .IPv6Address "/") 0}}{{end}}' | sed 's/^,//'))
endef
define docker_create_vlan_network
$(eval VLAN_NETWORK_ID = $(shell docker network ls -f name=$(E2E_NETWORK) --format '{{.ID}}'))
@if [ ! -z "$(VLAN_ID)" -a -z "$(VLAN_NETWORK_ID)" ]; then \
docker network create --attachable -d bridge \
--ipv6 --subnet fc00:adb1:b29b:608d::/64 --gateway fc00:adb1:b29b:608d::1 \
-o com.docker.network.bridge.enable_ip_masquerade=true \
-o com.docker.network.driver.mtu=1500 $(E2E_NETWORK); \
fi
endef
define docker_config_bridge
@set -e; \
docker network ls --format "{{.Name}}" | grep '^$(1)$$' >/dev/null || exit 0; \
set -o pipefail; \
default=$$(docker network inspect $(1) -f '{{index .Options "com.docker.network.bridge.default_bridge"}}'); \
br="docker0"; \
[ "$$default" != "true" ] && br="br-$$(docker network inspect $(1) -f "{{.Id}}" | head -c 12)"; \
docker run --rm --privileged --network=host $(REGISTRY)/kube-ovn:$(RELEASE_TAG) bash -ec '\
for brif in $$(ls /sys/class/net/'$$br'/brif); do \
echo $(2) > /sys/class/net/'$$br'/brif/$$brif/hairpin_mode; \
done'; \
if [ -z "$(3)" ]; then \
docker run --rm --privileged --network=host $(REGISTRY)/kube-ovn:$(RELEASE_TAG) bash -ec '\
echo 0 > /sys/class/net/'$$br'/bridge/vlan_filtering; \
'; \
else \
docker run --rm --privileged --network=host $(REGISTRY)/kube-ovn:$(RELEASE_TAG) bash -ec '\
echo 1 > /sys/class/net/'$$br'/bridge/vlan_filtering; \
bridge vlan show | awk "/^'$$br'/{print \$$2; while (getline > 0) {\
if (\$$0 ~ /^[[:blank:]]/) {print \$$1} else {exit 0} }\
}" | while read vid; do \
bridge vlan del vid $$vid dev '$$br' self; \
done; \
bridge vlan add vid $(3) dev '$$br' pvid untagged self; \
for brif in $$(ls /sys/class/net/'$$br'/brif); do \
bridge vlan show | awk "/^$$brif/{print \$$2; while (getline > 0) {\
if (\$$0 ~ /^[[:blank:]]/) {print \$$1} else {exit 0} }\
}" | while read vid; do \
bridge vlan del vid $$vid dev $$brif; \
done; \
bridge vlan add vid $(3) dev $$brif; \
done'; \
fi
endef
define kind_create_cluster
kind create cluster --config $(1) --name $(2)
kubectl delete --ignore-not-found sc standard
kubectl delete --ignore-not-found -n local-path-storage deploy local-path-provisioner
kubectl describe no
endef
define kind_load_image
kind load docker-image --name $(1) $(2)
endef
.PHONY: kind-generate-config
kind-generate-config:
j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
.PHONY: kind-disable-hairpin
kind-disable-hairpin:
$(call docker_config_bridge,kind,0,)
.PHONY: kind-enable-hairpin
kind-enable-hairpin:
$(call docker_config_bridge,kind,1,)
.PHONY: kind-create
kind-create:
$(call kind_create_cluster,yamls/kind.yaml,kube-ovn)
.PHONY: kind-init
kind-init: kind-init-ipv4
.PHONY: kind-init-ipv4
kind-init-ipv4: kind-clean
@$(MAKE) kind-generate-config
@$(MAKE) kind-create
.PHONY: kind-init-ovn-ic
kind-init-ovn-ic: kind-clean-ovn-ic kind-init-single
$(call kind_create_cluster,yamls/kind.yaml,kube-ovn1)
.PHONY: kind-init-iptables
kind-init-iptables:
@kube_proxy_mode=iptables $(MAKE) kind-init
.PHONY: kind-init-ha
kind-init-ha:
@ha=true $(MAKE) kind-init
.PHONY: kind-init-single
kind-init-single:
@single=true $(MAKE) kind-init
.PHONY: kind-init-ipv6
kind-init-ipv6:
@ip_family=ipv6 $(MAKE) kind-init
.PHONY: kind-init-dual
kind-init-dual:
@ip_family=dual $(MAKE) kind-init
.PHONY: kind-init-cilium
kind-init-cilium:
@kube_proxy_mode=iptables $(MAKE) kind-init
.PHONY: kind-load-image
kind-load-image:
$(call kind_load_image,kube-ovn,$(REGISTRY)/kube-ovn:$(RELEASE_TAG))
.PHONY: kind-untaint-control-plane
kind-untaint-control-plane:
@for node in $$(kubectl get no -o jsonpath='{.items[*].metadata.name}'); do \
for key in $(CONTROL_PLANE_TAINTS); do \
taint=$$(kubectl get no $$node -o jsonpath="{.spec.taints[?(@.key==\"$$key\")]}"); \
if [ -n "$$taint" ]; then \
kubectl taint node $$node $$key:NoSchedule-; \
fi; \
done; \
done
.PHONY: kind-helm-install
kind-helm-install: kind-untaint-control-plane
kubectl label no -lbeta.kubernetes.io/os=linux kubernetes.io/os=linux --overwrite
kubectl label no -lnode-role.kubernetes.io/control-plane kube-ovn/role=master --overwrite
kubectl label no -lovn.kubernetes.io/ovs_dp_type!=userspace ovn.kubernetes.io/ovs_dp_type=kernel --overwrite
$(eval MASTERNODES = $(shell docker exec -i kube-ovn-control-plane kubectl get nodes -l node-role.kubernetes.io/control-plane="" -o jsonpath='{.items[*].status.addresses[].address}'))
$(eval EMPTY := )
$(eval SPACE := $(EMPTY))
$(eval MASTERS = $(subst SPACE,,,$(strip $$(MASTERNODES))))
helm install kubeovn ./kubeovn-helm --set MASTER_NODES=$(MASTERNODES)
kubectl -n kube-system get pods -o wide
.PHONY: kind-install
kind-install: kind-load-image
kubectl config use-context kind-kube-ovn
@$(MAKE) kind-untaint-control-plane
ENABLE_SSL=true dist/images/install.sh
kubectl describe no
.PHONY: kind-install-dev
kind-install-dev:
$(call kind_load_image,kube-ovn,$(REGISTRY)/kube-ovn:$(DEV_TAG))
kubectl config use-context kind-kube-ovn
@$(MAKE) kind-untaint-control-plane
sed 's/VERSION=.*/VERSION=$(DEV_TAG)/' dist/images/install.sh | bash
.PHONY: kind-install-ipv4
kind-install-ipv4: kind-install-overlay-ipv4
.PHONY: kind-install-overlay-ipv4
kind-install-overlay-ipv4: kind-install
.PHONY: kind-install-ovn-ic
kind-install-ovn-ic: kind-load-image kind-install
$(call kind_load_image,kube-ovn1,$(REGISTRY)/kube-ovn:$(RELEASE_TAG))
kubectl config use-context kind-kube-ovn1
sed -e 's/10.16.0/10.18.0/g' \
-e 's/10.96.0/10.98.0/g' \
-e 's/100.64.0/100.68.0/g' \
dist/images/install.sh | \
ENABLE_SSL=true bash
kubectl describe no
docker run -d --name ovn-ic-db --network kind $(REGISTRY)/kube-ovn:$(RELEASE_TAG) bash start-ic-db.sh
@set -e; \
ic_db_host=$$(docker inspect ovn-ic-db -f "{{.NetworkSettings.Networks.kind.IPAddress}}"); \
zone=az0 ic_db_host=$$ic_db_host gateway_node_name=kube-ovn-control-plane j2 yamls/ovn-ic.yaml.j2 -o ovn-ic-0.yaml; \
zone=az1 ic_db_host=$$ic_db_host gateway_node_name=kube-ovn1-control-plane j2 yamls/ovn-ic.yaml.j2 -o ovn-ic-1.yaml; \
zone=az1111 ic_db_host=$$ic_db_host gateway_node_name=kube-ovn1-control-plane j2 yamls/ovn-ic.yaml.j2 -o /tmp/ovn-ic-1-alter.yaml
kubectl config use-context kind-kube-ovn
kubectl apply -f ovn-ic-0.yaml
sleep 6
kubectl -n kube-system get pods | grep ovs-ovn | awk '{print $$1}' | xargs kubectl -n kube-system delete pod
kubectl config use-context kind-kube-ovn1
kubectl apply -f ovn-ic-1.yaml
sleep 6
kubectl -n kube-system get pods | grep ovs-ovn | awk '{print $$1}' | xargs kubectl -n kube-system delete pod
.PHONY: kind-install-underlay
kind-install-underlay: kind-install-underlay-ipv4
.PHONY: kind-install-underlay-hairpin
kind-install-underlay-hairpin: kind-install-underlay-hairpin-ipv4
.PHONY: kind-install-underlay-ipv4
kind-install-underlay-ipv4: kind-disable-hairpin kind-load-image kind-untaint-control-plane
$(call docker_network_info,kind)
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV4_SUBNET)"@' \
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
dist/images/install.sh | \
ENABLE_SSL=true ENABLE_VLAN=true VLAN_NIC=eth0 bash
kubectl describe no
.PHONY: kind-install-underlay-hairpin-ipv4
kind-install-underlay-hairpin-ipv4: kind-enable-hairpin kind-load-image kind-untaint-control-plane
$(call docker_network_info,kind)
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV4_SUBNET)"@' \
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
dist/images/install.sh | \
ENABLE_SSL=true ENABLE_VLAN=true VLAN_NIC=eth0 bash
kubectl describe no
.PHONY: kind-install-ipv6
kind-install-ipv6: kind-install-overlay-ipv6
.PHONY: kind-install-overlay-ipv6
kind-install-overlay-ipv6:
IPV6=true $(MAKE) kind-install
.PHONY: kind-install-underlay-ipv6
kind-install-underlay-ipv6: kind-disable-hairpin kind-load-image kind-untaint-control-plane
$(call docker_network_info,kind)
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV6_SUBNET)"@' \
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
dist/images/install.sh | \
ENABLE_SSL=true IPV6=true ENABLE_VLAN=true VLAN_NIC=eth0 bash
.PHONY: kind-install-underlay-hairpin-ipv6
kind-install-underlay-hairpin-ipv6: kind-enable-hairpin kind-load-image kind-untaint-control-plane
$(call docker_network_info,kind)
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV6_SUBNET)"@' \
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
dist/images/install.sh | \
ENABLE_SSL=true IPV6=true ENABLE_VLAN=true VLAN_NIC=eth0 bash
.PHONY: kind-install-dual
kind-install-dual: kind-install-overlay-dual
.PHONY: kind-install-overlay-dual
kind-install-overlay-dual:
DUAL_STACK=true $(MAKE) kind-install
.PHONY: kind-install-underlay-dual
kind-install-underlay-dual: kind-disable-hairpin kind-load-image kind-untaint-control-plane
$(call docker_network_info,kind)
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV4_SUBNET),$(KIND_IPV6_SUBNET)"@' \
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY),$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS),$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
dist/images/install.sh | \
ENABLE_SSL=true DUAL_STACK=true ENABLE_VLAN=true VLAN_NIC=eth0 bash
.PHONY: kind-install-underlay-hairpin-dual
kind-install-underlay-hairpin-dual: kind-enable-hairpin kind-load-image kind-untaint-control-plane
$(call docker_network_info,kind)
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV4_SUBNET),$(KIND_IPV6_SUBNET)"@' \
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY),$(KIND_IPV6_GATEWAY)"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS),$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
dist/images/install.sh | \
ENABLE_SSL=true DUAL_STACK=true ENABLE_VLAN=true VLAN_NIC=eth0 bash
.PHONY: kind-install-underlay-logical-gateway-dual
kind-install-underlay-logical-gateway-dual: kind-disable-hairpin kind-load-image kind-untaint-control-plane
$(call docker_network_info,kind)
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV4_SUBNET),$(KIND_IPV6_SUBNET)"@' \
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY)9,$(KIND_IPV6_GATEWAY)f"@' \
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_GATEWAY),$(KIND_IPV4_EXCLUDE_IPS),$(KIND_IPV6_GATEWAY),$(KIND_IPV6_EXCLUDE_IPS)"@' \
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
dist/images/install.sh | \
ENABLE_SSL=true DUAL_STACK=true ENABLE_VLAN=true \
VLAN_NIC=eth0 LOGICAL_GATEWAY=true bash
.PHONY: kind-install-multus
kind-install-multus: kind-load-image kind-untaint-control-plane
$(call docker_ensure_image_exists,$(MULTUS_IMAGE))
$(call kind_load_image,kube-ovn,$(MULTUS_IMAGE))
$(call kind_load_image,kube-ovn,$(VPC_NAT_GW_IMG))
kubectl apply -f "$(MULTUS_YAML)"
kubectl -n kube-system rollout status ds kube-multus-ds
kubectl apply -f yamls/lb-svc-attachment.yaml
ENABLE_SSL=true ENABLE_LB_SVC=true CNI_CONFIG_PRIORITY=10 dist/images/install.sh
kubectl describe no
.PHONY: kind-install-cilium
kind-install-cilium: kind-load-image kind-untaint-control-plane
$(eval KUBERNETES_SERVICE_HOST = $(shell kubectl get nodes kube-ovn-control-plane -o jsonpath='{.status.addresses[0].address}'))
$(call docker_ensure_image_exists,$(CILIUM_IMAGE_REPO):v$(CILIUM_VERSION))
$(call kind_load_image,kube-ovn,$(CILIUM_IMAGE_REPO):v$(CILIUM_VERSION))
kubectl apply -f yamls/chaining.yaml
helm repo add cilium https://helm.cilium.io/
helm install cilium cilium/cilium \
--version $(CILIUM_VERSION) \
--namespace=kube-system \
--set k8sServiceHost=$(KUBERNETES_SERVICE_HOST) \
--set k8sServicePort=6443 \
--set tunnel=disabled \
--set enableIPv4Masquerade=false \
--set enableIdentityMark=false \
--set cni.chainingMode=generic-veth \
--set cni.customConf=true \
--set cni.configMap=cni-configuration
kubectl -n kube-system rollout status ds cilium --timeout 300s
bash dist/images/cilium.sh
ENABLE_SSL=true ENABLE_LB=false ENABLE_NP=false WITHOUT_KUBE_PROXY=true CNI_CONFIG_PRIORITY=10 bash dist/images/install.sh
kubectl describe no
.PHONY: kind-reload
kind-reload: kind-reload-ovs
kubectl delete pod -n kube-system -l app=kube-ovn-controller
kubectl delete pod -n kube-system -l app=kube-ovn-cni
kubectl delete pod -n kube-system -l app=kube-ovn-pinger
.PHONY: kind-reload-ovs
kind-reload-ovs: kind-load-image
kubectl delete pod -n kube-system -l app=ovs
.PHONY: kind-clean
kind-clean: kind-disable-hairpin
$(call docker_rm_container,kube-ovn-e2e)
kind delete cluster --name=kube-ovn
.PHONY: kind-clean-ovn-ic
kind-clean-ovn-ic: kind-clean
kind delete cluster --name=kube-ovn1
.PHONY: uninstall
uninstall:
bash dist/images/cleanup.sh
.PHONY: lint
lint:
@gofmt -d .
@if [ $$(gofmt -l . | wc -l) -ne 0 ]; then \
echo "Code differs from gofmt's style" 1>&2 && exit 1; \
fi
@GOOS=linux go vet ./...
@GOOS=linux gosec -exclude=G204,G306,G404,G601,G301 -exclude-dir=test -exclude-dir=pkg/client ./...
.PHONY: lint-windows
lint-windows:
@GOOS=windows go vet ./cmd/windows/...
@GOOS=windows gosec -exclude=G204,G601,G301 ./pkg/util
@GOOS=windows gosec -exclude=G204,G601,G301 ./pkg/request
@GOOS=windows gosec -exclude=G204,G601,G301 ./cmd/cni
.PHONY: scan
scan:
trivy image --exit-code=1 --severity=HIGH --ignore-unfixed --security-checks vuln $(REGISTRY)/kube-ovn:$(RELEASE_TAG)
trivy image --exit-code=1 --severity=HIGH --ignore-unfixed --security-checks vuln $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG)
.PHONY: ut
ut:
ginkgo -mod=mod -progress --always-emit-ginkgo-writer --slow-spec-threshold=60s test/unittest
.PHONY: ipam-bench
ipam-bench:
go test -timeout 30m -bench='^BenchmarkIPAM' -benchtime=10000x test/unittest/ipam_bench/ipam_test.go -args -logtostderr=false
go test -timeout 90m -bench='^BenchmarkParallelIPAM' -benchtime=10x test/unittest/ipam_bench/ipam_test.go -args -logtostderr=false
.PHONY: e2e
e2e:
$(call docker_create_vlan_network)
$(eval NODE_COUNT = $(shell kind get nodes --name kube-ovn | wc -l))
$(eval E2E_NETWORK_INFO = $(shell docker inspect -f '{{json (index .NetworkSettings.Networks "$(E2E_NETWORK)")}}' kube-ovn-control-plane))
$(call docker_rm_container,kube-ovn-e2e)
docker run -d --name kube-ovn-e2e --network kind --cap-add=NET_ADMIN $(REGISTRY)/kube-ovn:$(RELEASE_TAG) sleep infinity
@if [ '$(E2E_NETWORK_INFO)' = 'null' ]; then \
kind get nodes --name kube-ovn | while read node; do \
docker network connect $(E2E_NETWORK) $$node; \
done; \
fi
$(call docker_config_bridge,$(E2E_NETWORK),0,$(VLAN_ID))
@echo "{" > test/e2e/network.json
@i=0; kind get nodes --name kube-ovn | while read node; do \
i=$$((i+1)); \
printf '"%s": ' "$$node" >> test/e2e/network.json; \
docker inspect -f '{{json (index .NetworkSettings.Networks "$(E2E_NETWORK)")}}' "$$node" >> test/e2e/network.json; \
if [ $$i -ne $(NODE_COUNT) ]; then echo "," >> test/e2e/network.json; fi; \
done
@echo "}" >> test/e2e/network.json
$(call docker_ensure_image_exists,kubeovn/pause:3.2)
$(call kind_load_image,kube-ovn,kubeovn/pause:3.2)
ginkgo -mod=mod -progress --always-emit-ginkgo-writer --slow-spec-threshold=60s test/e2e
.PHONY: e2e-ipv6
e2e-ipv6:
@IPV6=true $(MAKE) e2e
.PHONY: e2e-vlan
e2e-vlan:
@VLAN_ID=100 $(MAKE) e2e
.PHONY: e2e-vlan-ipv6
e2e-vlan-ipv6:
@IPV6=true $(MAKE) e2e-vlan
.PHONY: e2e-underlay-single-nic
e2e-underlay-single-nic:
@docker inspect -f '{{json .NetworkSettings.Networks.kind}}' kube-ovn-control-plane > test/e2e-underlay-single-nic/node/network.json
ginkgo -mod=mod -progress --always-emit-ginkgo-writer --slow-spec-threshold=60s test/e2e-underlay-single-nic
.PHONY: e2e-ovn-ic
e2e-ovn-ic:
ginkgo -mod=mod -progress --always-emit-ginkgo-writer --slow-spec-threshold=60s test/e2e-ovn-ic
.PHONY: e2e-cilium
e2e-cilium:
docker run -d --name kube-ovn-e2e --network kind --cap-add=NET_ADMIN $(REGISTRY)/kube-ovn:$(RELEASE_TAG) sleep infinity
ginkgo -mod=mod -progress --always-emit-ginkgo-writer --slow-spec-threshold=60s test/e2e-cilium
.PHONY: e2e-multus
e2e-multus:
ginkgo -mod=mod -progress --always-emit-ginkgo-writer --slow-spec-threshold=60s test/e2e-multus
.PHONY: clean
clean:
$(RM) dist/images/kube-ovn dist/images/kube-ovn-cmd
$(RM) yamls/kind.yaml
$(RM) ovn.yaml kube-ovn.yaml kube-ovn-crd.yaml
$(RM) ovn-ic-0.yaml ovn-ic-1.yaml
$(RM) kube-ovn.tar vpc-nat-gateway.tar image-amd64.tar image-arm64.tar
$(RM) test/e2e/ovnnb_db.* test/e2e/ovnsb_db.*
$(RM) test/e2e/network.json test/e2e-underlay-single-nic/node/network.json
.PHONY: changelog
changelog:
./hack/changelog.sh > CHANGELOG.md