A container-aware netstat
Перейти к файлу
Noah Lavine 4cb0a6f4f9 Add printJsonTable
This makes cnetstat's table-printing functions generic to the type of
data being printed. This will let us print either connections or
summary statistics using the same code.
2020-09-25 10:27:57 -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 Update in response to review 2020-09-22 15:39:22 -04:00
LICENSE Initial LICENSE commit 2020-09-18 06:51:44 -07:00
README.md Fix two broken links in the README 2020-09-24 14:22:07 -04:00
SECURITY.md Initial SECURITY.md commit 2020-09-18 06:51:46 -07:00
cnetstat.go Add printJsonTable 2020-09-25 10:27:57 -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 Initial commit of cnetstat source code 2020-09-23 13:55:11 -04:00
lsns_test.go Initial commit of cnetstat source code 2020-09-23 13:55:11 -04:00
netstat.go Initial commit of cnetstat source code 2020-09-23 13:55:11 -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

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.

Use it like this (from the repository root directory):

go build
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

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.