-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for Kubectl 1.12+, adding more verifications to improv…
…e UX
- Loading branch information
eldadru
committed
Oct 25, 2018
1 parent
9d81588
commit 1078863
Showing
3 changed files
with
84 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
PLUGIN_FOLDER=~/.kube/plugins/sniff | ||
|
||
TCPDUMP_VERSION=4.9.2 | ||
NEW_PLUGIN_SYSTEM_MINIMUM_KUBECTL_VERSION=12 | ||
KUBECTL_MINOR_VERSION=$(shell kubectl version --client=true --short=true -o json | jq .clientVersion.minor) | ||
IS_NEW_PLUGIN_SUBSYSTEM := $(shell [ $(KUBECTL_MINOR_VERSION) -ge $(NEW_PLUGIN_SYSTEM_MINIMUM_KUBECTL_VERSION) ] && echo true) | ||
STATIC_TCPDUMP_NAME=static-tcpdump | ||
|
||
ifeq ($(IS_NEW_PLUGIN_SUBSYSTEM),true) | ||
PLUGIN_FOLDER=/usr/local/bin | ||
PLUGIN_NAME=kubectl-sniff | ||
else | ||
PLUGIN_FOLDER=~/.kube/plugins/sniff | ||
PLUGIN_NAME=ksniff.sh | ||
endif | ||
|
||
install: install-static-tcpdump install-plugin | ||
|
||
plugin-folder: | ||
mkdir -p ~/.kube/plugins/sniff | ||
mkdir -p ${PLUGIN_FOLDER} | ||
|
||
install-plugin: plugin-folder | ||
cp ksniff.sh plugin.yaml ${PLUGIN_FOLDER} | ||
chmod +x ${PLUGIN_FOLDER}/ksniff.sh | ||
if [ "${IS_NEW_PLUGIN_SUBSYSTEM}" != "true" ]; then \ | ||
cp plugin.yaml ${PLUGIN_FOLDER};\ | ||
fi | ||
|
||
cp ksniff.sh ${PLUGIN_FOLDER}/${PLUGIN_NAME} | ||
chmod +x ${PLUGIN_FOLDER}/${PLUGIN_NAME} | ||
|
||
install-static-tcpdump: plugin-folder static-tcpdump | ||
mv static-tcpdump ${PLUGIN_FOLDER} | ||
mv ${STATIC_TCPDUMP_NAME} ${PLUGIN_FOLDER} | ||
|
||
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 | ||
mv tcpdump-${TCPDUMP_VERSION}/tcpdump ./${STATIC_TCPDUMP_NAME} | ||
rm -rf tcpdump-${TCPDUMP_VERSION} tcpdump-${TCPDUMP_VERSION}.tar.gz | ||
|
||
uninstall: | ||
if [ "${IS_NEW_PLUGIN_SUBSYSTEM}" != "true" ]; then \ | ||
rm -f ${PLUGIN_FOLDER}/plugin.yaml;\ | ||
fi | ||
|
||
rm -f ${PLUGIN_FOLDER}/${STATIC_TCPDUMP_NAME} | ||
rm -f ${PLUGIN_FOLDER}/${PLUGIN_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters