Comments (5)
It depends on the path of your tcp dump file, if you save the file under /proc/1/root/
then you can access the file directly in the root filesystem of your application container, otherwise you have to locate the file under the root filesystem of the debug container.
For example, if you save the tcpdump data to /proc/1/root/tmp/tcpdump
in the debug container, then you can copy this file via:
kubectl cp -n <namespace> <application-pod-name>:/tmp/tcpdump -c <application-container-name> ./tcpdump
However, if you save the file to /tmp/tcpdump
in the debug container, you should run the following command:
kubectl cp -n <namespace> <application-pod-name>:/proc/{debug-container-pid}/root/tmp/tcpdump -c <application-container-name> ./tcpdump
from kubectl-debug.
[root@master ~]# kubectl debug litemall-all-7f7b98487-kb27g --agentless --port-forward
Agent Pod info: [Name:debug-agent-pod-e1fbf12f-2d0b-11ea-8ded-5254003c4391, Namespace:default, Image:aylei/debug-agent:latest, HostPort:10027, ContainerPort:10027]
Waiting for pod debug-agent-pod-e1fbf12f-2d0b-11ea-8ded-5254003c4391 to run...
pod litemall-all-7f7b98487-kb27g PodIP 10.100.219.100, agentPodIP 172.21.0.15
wait for forward port to debug agent ready...
Forwarding from 127.0.0.1:10027 -> 10027
Forwarding from [::1]:10027 -> 10027
Handling connection for 10027
pulling image nicolaka/netshoot:latest...
latest: Pulling from nicolaka/netshoot
Digest: sha256:8b020dc72d8ef07663e44c449f1294fc47c81a10ef5303dc8c2d9635e8ca22b1
Status: Image is up to date for nicolaka/netshoot:latest
starting debug container...
container created, open tty...
bash-5.0#
bash-5.0# cd /proc/1/root
bash-5.0# cd tmp/
bash-5.0# echo 11 > tcpdump
bash-5.0# ls -l
total 20
-rw-r--r-- 1 root root 2 Jan 2 01:48 1.txt
drwxr-xr-x 2 root root 4096 Dec 31 09:49 hsperfdata_root
-rw-r--r-- 1 root root 3 Jan 2 03:03 tcpdump
drwxr-xr-x 2 root root 4096 Dec 31 09:49 tomcat-docbase.373760562388174187.8080
drwxr-xr-x 3 root root 4096 Dec 31 09:49 tomcat.1895695548235022299.8080
bash-5.0# pwd
/proc/1/root/tmp
bash-5.0
[root@master ~]# kubectl cp -n default debug-agent-pod-e1fbf12f-2d0b-11ea-8ded-5254003c4391:/tmp/tcpdump ./tcpdump
command terminated with exit code 126
from kubectl-debug.
@aylei Hello, following your instructions, I still get an error
from kubectl-debug.
[root@master ~]# kubectl cp default/debug-agent-pod-e1fbf12f-2d0b-11ea-8ded-5254003c4391:/tmp/tcpdump ./tcpdump --v=10
I0102 11:12:30.470357 22693 round_trippers.go:423] curl -k -v -XPOST -H "X-Stream-Protocol-Version: v4.channel.k8s.io" -H "X-Stream-Protocol-Version: v3.channel.k8s.io" -H "X-Stream-Protocol-Version: v2.channel.k8s.io" -H "X-Stream-Protocol-Version: channel.k8s.io" -H "User-Agent: kubectl/v1.16.3 (linux/amd64) kubernetes/b3cbbae" 'https://172.21.0.15:6443/api/v1/namespaces/default/pods/debug-agent-pod-e1fbf12f-2d0b-11ea-8ded-5254003c4391/exec?command=tar&command=cf&command=-&command=%2Ftmp%2Ftcpdump&container=debug-agent&stderr=true&stdout=true'
I0102 11:12:30.493746 22693 round_trippers.go:443] POST https://172.21.0.15:6443/api/v1/namespaces/default/pods/debug-agent-pod-e1fbf12f-2d0b-11ea-8ded-5254003c4391/exec?command=tar&command=cf&command=-&command=%2Ftmp%2Ftcpdump&container=debug-agent&stderr=true&stdout=true 101 Switching Protocols in 23 milliseconds
I0102 11:12:30.493760 22693 round_trippers.go:449] Response Headers:
I0102 11:12:30.493766 22693 round_trippers.go:452] Date: Thu, 02 Jan 2020 03:12:30 GMT
I0102 11:12:30.493770 22693 round_trippers.go:452] Connection: Upgrade
I0102 11:12:30.493774 22693 round_trippers.go:452] Upgrade: SPDY/3.1
I0102 11:12:30.493777 22693 round_trippers.go:452] X-Stream-Protocol-Version: v4.channel.k8s.io
F0102 11:12:30.587480 22693 helpers.go:114] command terminated with exit code 126
[root@master ~]#
from kubectl-debug.
@liabio The file is stored in the target Pod, not the debug agent, try kubectl cp litemall-all-7f7b98487-kb27g
😁
from kubectl-debug.
Related Issues (20)
- Plugin stuck creating exec stream
- plan to support sts
- Error: No such image HOT 2
- Error: No such image: nicolaka/netshoot:latest HOT 18
- The default agent image version should be coordinated with the plugin
- Do not use HostPort when using --port-forward
- Agent pod failed HOT 4
- not output command result when excute no interactive command
- `RegistrySecretName` inf config file don't work HOT 2
- Errors with containerd runtime HOT 2
- cannot get the debug docker image No such image: docker.io/nicolaka/netshoot:latest HOT 2
- I can't join some pods HOT 1
- k8s.io/api/admissionregistration/v1alpha1: module k8s.io/api@latest found (v0.20.5), but does not contain package k8s.io/api/admissionregistration/v1alpha1 HOT 1
- aliyun-exporter使用时出现错误
- If my target pod has multiple contianers? HOT 1
- Seems the kubectl has build-in debug sub command, it conflicts with it HOT 2
- What is the reason behind `CGO_ENABLED=0`?
- parse namespace error HOT 1
- 项目是结束维护了么,好久没看到更新 HOT 2
- run error when use containerd runtime
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubectl-debug.