Skip to content

Commit

Permalink
support Apple Silicon M1 (#133)
Browse files Browse the repository at this point in the history
Co-authored-by: Weidong Feng <[email protected]>
  • Loading branch information
fenngwd and fenngwd authored Feb 14, 2022
1 parent 03b0401 commit 67b1799
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .krew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ spec:
matchLabels:
os: darwin
arch: amd64
- {{ addURIAndSha "https://github.com/eldadru/ksniff/releases/download/{{ .TagName }}/ksniff.zip" .TagName }}
bin: kubectl-sniff
files:
- from: kubectl-sniff-darwin-arm64
to: kubectl-sniff
- from: static-tcpdump
to: .
- from: LICENSE
to: .
selector:
matchLabels:
os: darwin
arch: arm64
- {{ addURIAndSha "https://github.com/eldadru/ksniff/releases/download/{{ .TagName }}/ksniff.zip" .TagName }}
bin: kubectl-sniff
files:
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ TCPDUMP_VERSION=4.9.2
STATIC_TCPDUMP_NAME=static-tcpdump
NEW_PLUGIN_SYSTEM_MINIMUM_KUBECTL_VERSION=12
UNAME := $(shell uname)
ARCH_NAME := $(shell uname -m)
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)

Expand All @@ -12,8 +13,12 @@ PLUGIN_FOLDER=~/.kube/plugins/sniff
endif

ifeq ($(UNAME), Darwin)
ifeq ($(ARCH_NAME), arm64)
PLUGIN_NAME=kubectl-sniff-darwin-arm64
else
PLUGIN_NAME=kubectl-sniff-darwin
endif
endif

ifeq ($(UNAME), Linux)
PLUGIN_NAME=kubectl-sniff
Expand All @@ -27,6 +32,7 @@ windows:

darwin:
GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -o kubectl-sniff-darwin cmd/kubectl-sniff.go
GO111MODULE=on GOOS=darwin GOARCH=arm64 go build -o kubectl-sniff-darwin-arm64 cmd/kubectl-sniff.go

all: linux windows darwin

Expand All @@ -41,7 +47,7 @@ static-tcpdump:
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 LICENSE
zip ksniff.zip kubectl-sniff kubectl-sniff-windows kubectl-sniff-darwin kubectl-sniff-darwin-arm64 static-tcpdump Makefile plugin.yaml LICENSE

install:
mkdir -p ${PLUGIN_FOLDER}
Expand All @@ -61,6 +67,7 @@ clean:
rm -f kubectl-sniff
rm -f kubectl-sniff-windows
rm -f kubectl-sniff-darwin
rm -f kubectl-sniff-darwin-arm64
rm -f static-tcpdump
rm -f ksniff.zip

0 comments on commit 67b1799

Please sign in to comment.