Skip to content

Instantly share code, notes, and snippets.

@tirumaraiselvan
Last active October 4, 2020 04:42
Show Gist options
  • Save tirumaraiselvan/9879536054ba63ab74910077e9ed538c to your computer and use it in GitHub Desktop.
Save tirumaraiselvan/9879536054ba63ab74910077e9ed538c to your computer and use it in GitHub Desktop.
tcpdump kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: hasura
hasuraService: custom
name: hasura
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: hasura
template:
metadata:
labels:
app: hasura
spec:
containers:
- image: hasura/graphql-engine:v1.3.2
name: hasura
env:
- name: HASURA_GRAPHQL_DATABASE_URL
value: postgres://postgres:password@0.tcp.ngrok.io:5432/postgres
ports:
- containerPort: 8080
protocol: TCP
- image: corfr/tcpdump
name: tcpdump
command: ["/bin/sleep", "infinity"]
@tirumaraiselvan
Copy link
Author

Commands:

  1. Ssh into the container: kubectl exec --stdin --tty hasura-574895c6bf-cdzdp --container tcpdump -- sh
  2. Run tcpdump in container: tcpdump -s 0 -w dump.pcap . After capturing, quit the process and exit the container.
  3. Copy capture file: kubectl cp hasura-574895c6bf-cdzdp:/dump.pcap -c tcpdump dump.pcap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment