A container-aware netstat
Перейти к файлу
noahl 853cae8b57
Merge pull request #8 from microsoft/add-chmod-to-readme
Add chmod to README
2020-12-07 11:49:21 -05:00
.github/workflows Create go.yml 2020-09-28 14:48:17 -04:00
.gitignore Initial commit 2020-09-18 13:51:34 +00:00
CODE_OF_CONDUCT.md Initial CODE_OF_CONDUCT.md commit 2020-09-18 06:51:43 -07:00
Contributing.md Update in response to review 2020-09-22 15:39:22 -04:00
Design.md Remove summary stats from the roadmap 2020-12-01 10:50:53 -05:00
LICENSE Initial LICENSE commit 2020-09-18 06:51:44 -07:00
README.md Add chmod to README 2020-12-07 11:26:52 -05:00
SECURITY.md Initial SECURITY.md commit 2020-09-18 06:51:46 -07:00
cnetstat.go Add constants for tableFormat and jsonFormat 2020-10-14 10:22:57 -04:00
cnetstat_test.go go fmt 2020-09-29 16:48:37 -04:00
dockerPidMap.go Initial commit of cnetstat source code 2020-09-23 13:55:11 -04:00
dockerPidMap_test.go Initial commit of cnetstat source code 2020-09-23 13:55:11 -04:00
lsns.go Use lsns' human-readable output instead of JSON 2020-09-28 10:01:36 -04:00
lsns_test.go Use lsns' human-readable output instead of JSON 2020-09-28 10:01:36 -04:00
netstat.go Use lsns' human-readable output instead of JSON 2020-09-28 10:01:36 -04:00
netstat_test.go Initial commit of cnetstat source code 2020-09-23 13:55:11 -04:00
print_table.go Add printJsonTable 2020-09-25 10:27:57 -04:00
print_table_test.go Add printJsonTable 2020-09-25 10:27:57 -04:00
util.go Use lsns' human-readable output instead of JSON 2020-09-28 10:01:36 -04:00

README.md

cnetstat: a container-aware netstat

cnetstat dumps a list of TCP connections on a host, with their Kubernetes container and pod names if they are from a container. It currently assumes that the containers run on Docker, with labels in the format that my version of Kubelet uses.

To get an x86-64 binary, download the latest release like this:

curl -L https://github.com/microsoft/cnetstat/releases/latest/download/cnetstat.x86_64 > cnetstat

Make it executable:

chmod +x ./cnetstat

and then run it like this:

sudo ./cnetstat

You should see output like this:

Namespace  Pod       Container    Protocol  Local Host        Local Port  Remote Host  Remote Port  Connection State
myapp      frontend  fe-server    https     aks-nodepool1-23  4592        10.2.9.76    https        ESTABLISHED
myapp      backend   be-server    https     aks-nodepool1-23  6820        10.2.10.82   https        ESTABLISHED
myapp      backend   log-scraper  https     aks-nodepool1-23  7819        10.2.9.83    https        TIME_WAIT

If you want JSON output, try this:

sudo ./cnetstat --format=json

If you want to count connections per origin/destination pair, use the --summaryStatistics option.

(To run on other architectures, you'll need to build from source. There are instructions in the contributing doc.

Why cnetstat?

We built cnetstat to help figure out which containers in a Kubernetes cluster were using up TCP ports by opening lots of short-lived outbound connections.

You might want to use cnetstat if you have that problem, or any problem related to the interaction of container-level and host-level networking. We hope cnetstat will be helpful to you too.

Design and Roadmap

See the design doc.

Getting Involved

Is there a feature that would make cnetstat more useful for you? Are you hitting a bug? Is the documentation unclear or lacking? Please let us know!

See the contributing doc for the details.

Whether it's a feature, a bug report, or anything else, your contributions make cnetstat better for everyone. Thank you.