How to add tcpkill to my kubernetes pod - alpine packages

3/2/2020

I am trying to install/add tcpkill to my pod but getting the below error. Even apk update is also not giving the desired results.

$ kubectl exec -it mypod-v003-ab2cd /bin/sh -n mynamespace
/ # apk add tcpkill
ERROR: unsatisfiable constraints:
  tcpkill (missing):
    required by: world[tcpkill]
/ #
/ #
/ #
/ # apk add dsniff
ERROR: unsatisfiable constraints:
  dsniff (missing):
    required by: world[dsniff]
/ #
/ #
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
v3.9.5-11-ge3b5031082 [http://dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.5-3-gfaabae9a55 [http://dl-cdn.alpinelinux.org/alpine/v3.9/community]
v20200122-2407-g64931a5538 [http://dl-cdn.alpinelinux.org/alpine/edge/testing]
OK: 13818 distinct packages available

I found online that I can add package (https://pkgs.alpinelinux.org/contents?file=tcpkill&path=&name=bash-completion&branch=v3.9&repo=main&arch=x86_64) from alpine linux but not sure how. Can someone please help?

Also If i go to /usr/share/bash-completion/completions/ I can see the tcpkill over there.

/ # ls -l /usr/share/bash-completion/completions/tc*
-rw-r--r--    1 root     root          1011 Dec  4  2018 /usr/share/bash-completion/completions/tcpdump
-rw-r--r--    1 root     root           441 Dec  4  2018 /usr/share/bash-completion/completions/tcpkill
-rw-r--r--    1 root     root           434 Dec  4  2018 /usr/share/bash-completion/completions/tcpnice
/ #
-- Shashank
kubectl
kubernetes
tcp

1 Answer

3/2/2020

This reference is telling you that bash-completion package has a file called tcpkill in it's structure. This file is a index file for bash-completion to auto-complete tcpkill commands.

tcpkill isn't really available for alpine so if you need it, you have to compile it from source.

You may wonder why bash-completion includes references to tcpkill. It happens because it was included in the source package.

To know how-to compile it, take a look at this guide.

I can also suggest you to use another image as ubuntu. Using it you can just run apt-get install dsniff and tcpkill will be available to use.

If this solution suits for you, maybe you want to create your own docker image including these packages so you don't need to install it every time your pod is created. For that, I recommend you this how-to.

-- mWatney
Source: StackOverflow