Giter VIP home page Giter VIP logo

dspcap's Introduction

dspcap

A humble bash script set that uses daemonset to capture tcpdump from all k8s nodes, then collect the captures.

How to use

As simple as:

  1. Call dspcap-start script to start capture.
  2. Call dspcap-stop script to stop capture and collect result to dspcap directory.

Installation:

wget https://raw.githubusercontent.com/tdihp/dspcap/master/dspcap-start
wget https://raw.githubusercontent.com/tdihp/dspcap/master/dspcap-stop
chmod +x dspcap-start dspcap-stop
./dspcap-start
./dspcap-stop

Then you will find all tcpdump files for your K8s nodes in dspcap directory.

Customization

Finetune tcpdump command

Modify TCPDUMP_ARGS line at the top of dspcap-start accordingly. Alternatively, locate and modify the tcpdump line.

images

To change image used, modify IMAGE line at the top of dspcap-start accordingly. Most base images should work as long as nsenter (GNU or busybox version) is provided.

Below images are tested:

  • alpine:3.15 (default)
  • ubuntu:20.04
  • mcr.microsoft.com/dotnet/runtime-deps:6.0

Capture selected nodes

An easy way to achieve this is to add a nodeSelector for the daemonset in dspcap-start, then add the same label for all nodes with kubectl label node/<name>

e.g.

To add a section in .spec.template.spec of the daemonset:

      nodeSelector:
        foo: bar

Then label the target nodes, if not already applied:

kubectl label node/mynode1 foo=bar
kubectl label node/mynode2 foo=bar

Caveat

The current dspcap implementation uses a previleged pod to access root. nsenter is used to get access to root for reaching tcpdump. We do not advise to use the current setting as-is to take long-term capture for the security implication involved. Note however that this can be easily averted by using capabilities instead of privilege to limit the impact, and to download tcpdump package in the pod instead of using the one on the node via nsenter.

dspcap's People

Contributors

lualvare avatar mutazn avatar tdihp avatar yukirii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dspcap's Issues

tcpdump -r error

Hello.

we are not able to use wireshark on our program.
tcpdump -r throwing errors. any suggestion?

tcpdump -r 2023-11-08T17:33.aks-agentpool-33540062-vmss00000R.pcap
reading from file 2023-11-08T17:33.aks-agentpool-33540062-vmss00000R.pcap, link-type 276
tcpdump: unknown data link type 276

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.