forked from eldadru/ksniff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (51 loc) · 1.87 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
TCPDUMP_VERSION=4.9.2
STATIC_TCPDUMP_NAME=static-tcpdump
NEW_PLUGIN_SYSTEM_MINIMUM_KUBECTL_VERSION=12
UNAME := $(shell uname)
KUBECTL_MINOR_VERSION=$(shell kubectl version --client=true --short=true -o yaml | grep minor | grep -Eow "[0-9]+")
IS_NEW_PLUGIN_SUBSYSTEM := $(shell [ $(KUBECTL_MINOR_VERSION) -ge $(NEW_PLUGIN_SYSTEM_MINIMUM_KUBECTL_VERSION) ] && echo true)
ifeq ($(IS_NEW_PLUGIN_SUBSYSTEM),true)
PLUGIN_FOLDER=/usr/local/bin
else
PLUGIN_FOLDER=~/.kube/plugins/sniff
endif
ifeq ($(UNAME), Darwin)
PLUGIN_NAME=kubectl-sniff-darwin
endif
ifeq ($(UNAME), Linux)
PLUGIN_NAME=kubectl-sniff
endif
linux:
GO111MODULE=on GOOS=linux GOARCH=amd64 go build -o kubectl-sniff cmd/kubectl-sniff.go
windows:
GO111MODULE=on GOOS=windows GOARCH=amd64 go build -o kubectl-sniff-windows cmd/kubectl-sniff.go
darwin:
GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -o kubectl-sniff-darwin cmd/kubectl-sniff.go
all: linux windows darwin
test:
GO111MODULE=on go test ./...
static-tcpdump:
wget http://www.tcpdump.org/release/tcpdump-${TCPDUMP_VERSION}.tar.gz
tar -xvf tcpdump-${TCPDUMP_VERSION}.tar.gz
cd tcpdump-${TCPDUMP_VERSION} && CFLAGS=-static ./configure --without-crypto && make
mv tcpdump-${TCPDUMP_VERSION}/tcpdump ./${STATIC_TCPDUMP_NAME}
rm -rf tcpdump-${TCPDUMP_VERSION} tcpdump-${TCPDUMP_VERSION}.tar.gz
package:
zip ksniff.zip kubectl-sniff kubectl-sniff-windows kubectl-sniff-darwin static-tcpdump Makefile plugin.yaml
install:
mkdir -p ${PLUGIN_FOLDER}
cp ${PLUGIN_NAME} ${PLUGIN_FOLDER}/kubectl-sniff
cp plugin.yaml ${PLUGIN_FOLDER}
cp ${STATIC_TCPDUMP_NAME} ${PLUGIN_FOLDER}
uninstall:
rm -f ${PLUGIN_FOLDER}/kubectl-sniff
rm -f ${PLUGIN_FOLDER}/plugin.yaml
rm -f ${PLUGIN_FOLDER}/${STATIC_TCPDUMP_NAME}
verify_version:
./scripts/verify_version.sh
clean:
rm -f kubectl-sniff
rm -f kubectl-sniff-windows
rm -f kubectl-sniff-darwin
rm -f static-tcpdump
rm -f ksniff.zip