forked from kubernetes-retired/kpng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
148 lines (122 loc) · 3.89 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
# Copyright 2022 The Kubernetes Authors.
#
# 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.
.PHONY: all
all: help
# kpng build info
VERSION=$(shell git describe --tags --always --long)
LDFLAGS="-X main.version=$(VERSION)"
ARCH="amd64"
BUILD_DIR="kpng-bin"
export PLATFORM=""
# Auto Generate help from: https://gist.github.com/prwhite/8168133
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHAR_NUM=20
.PHONY: help
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
# Dependecies
go_mod_tests_requirement:
go install golang.org/x/lint/golint@latest
# Development mode - SKIP E2E
# Most of users use IPV4 and iptables as backend
# let's use it as default values
## Starts modd with the template available in-tree
modd:
modd -f modd.conf.template
## Creates k8s cluster with IPV4 and IPTABLES (No E2E involved)
debug:
./hack/test_e2e.sh -i ipv4 -b iptables -d
## Trigger unittests
test: go_mod_tests_requirement ## Execute unittests
./hack/test_unit.sh
## E2E with IPV4 and IPTABLES
e2e-ipv4-iptables: go_mod_tests_requirement
./hack/test_e2e.sh -i ipv4 -b iptables
## E2E with IPV6 and IPTABLES
e2e-ipv6-iptables: go_mod_tests_requirement
./hack/test_e2e.sh -i ipv6 -b iptables
## E2E with DUAL and IPTABLES
e2e-dual-iptables: go_mod_tests_requirement
./hack/test_e2e.sh -i dual -b iptables
## E2E with IPV4 and IPVS
e2e-ipv4-ipvs: go_mod_tests_requirement
./hack/test_e2e.sh -i ipv4 -b ipvs
## E2E with IPV6 and IPVS
e2e-ipv6-ipvs: go_mod_tests_requirement
./hack/test_e2e.sh -i ipv6 -b ipvs
## E2E with DUAL and IPVS
e2e-dual-ipvs: go_mod_tests_requirement
./hack/test_e2e.sh -i dual -b ipvs
## E2E with IPV4 and NFT
e2e-ipv4-nft: go_mod_tests_requirement
./hack/test_e2e.sh -i ipv4 -b nft
## E2E with IPV6 and NFT
e2e-ipv6-nft: go_mod_tests_requirement
./hack/test_e2e.sh -i ipv6 -b nft
## E2E with DUAL and NFT
e2e-dual-nft: go_mod_tests_requirement
./hack/test_e2e.sh -i dual -b nft
## Execute ALL E2E listed above
e2e: e2e-ipv4-iptables \
e2e-ipv6-iptables \
e2e-dual-iptables \
e2e-ipv4-ipvs \
e2e-ipv6-ipvs \
e2e-dual-ipvs \
e2e-ipv4-nft \
e2e-ipv6-nft \
e2e-dual-nft
## Build binary for Windows platform
windows: PLATFORM="windows"
windows:
@$(MAKE) -e build
build:
@mkdir -p $(BUILD_DIR)/$(PLATFORM)/$(VERSION)
@cd cmd && \
env GOOS=$(PLATFORM) \
GOARCH=$(ARCH) \
go build \
-trimpath \
-o ../$(BUILD_DIR)/$(PLATFORM)/$(VERSION) \
-v \
-ldflags=$(LDFLAGS) \
./...
@echo "\tkpng $(YELLOW)$(PLATFORM)$(RESET) binaries available in: $(GREEN)$(BUILD_DIR)/$(PLATFORM)/$(VERSION)$(RESET)\n"
## Create Kind cluster for Tilt. It requires backend(b) and ipfamily (i) as args. eg: make tilt-setup i=ipv4 b=nft m=split-process-per-node
tilt-setup:
./hack/tilt/setup.sh -i $(i) -b $(b) -m $(m)
## Start Tilt server.
tilt-up:
@tilt up -f ./hack/tilt/Tiltfile --host=0.0.0.0
## Stop TiltServer.
tilt-down:
@tilt down -f ./hack/tilt/Tiltfile