eldadru / ksniff

Kubectl plugin to ease sniffing on kubernetes pods using tcpdump and wireshark
Apache License 2.0
3.18k stars 190 forks source link

Error: exit status 1 #151

Open fefer opened 2 years ago

fefer commented 2 years ago

Hi,

Installed ksniff using krew and I am getting the following error:

vagrant@rio-amazonas-jauarana:~/ksniff-master$ !1316
kubectl sniff smf-f7d9788b5-pvh96 -f “port 8805” -n omec -p — socket /run/k3s/containerd/containerd.sock
INFO[0000] no container specified, taking first container we found in pod.
INFO[0000] selected container: 'smf'
INFO[0000] sniffing method: privileged pod
INFO[0000] sniffing on pod: 'smf-f7d9788b5-pvh96' [namespace: 'omec', container: 'smf', filter: '“port', interface: 'any']
INFO[0000] creating privileged pod on node: 'rio-amazonas-jauarana'
INFO[0000] pod: 'ksniff-znw2q' created successfully in namespace: 'omec'
INFO[0000] waiting for pod successful startup
INFO[0002] pod: 'ksniff-znw2q' created successfully on node: 'rio-amazonas-jauarana'
INFO[0002] spawning wireshark!
INFO[0002] starting remote sniffing using privileged pod
INFO[0002] executing command: '[/bin/sh -c
    set -ex
    export CONTAINERD_SOCKET="/run/containerd/containerd.sock"
    export CONTAINERD_NAMESPACE="k8s.io"
    export CONTAINER_RUNTIME_ENDPOINT="unix:///host${CONTAINERD_SOCKET}"
    export IMAGE_SERVICE_ENDPOINT=${CONTAINER_RUNTIME_ENDPOINT}
    crictl pull docker.io/maintained/tcpdump:latest >/dev/null
    netns=$(crictl inspect 1febcb90c752074f2b5b6c655f46ee5839ab6b248fa66b9f470f7598558c398c | jq '.info.runtimeSpec.linux.namespaces[] | select(.type == "network") | .path' | tr -d '"')
    exec chroot /host ctr -a ${CONTAINERD_SOCKET} run --rm --with-ns "network:${netns}" docker.io/maintained/tcpdump:latest ksniff-container-EkUMLWmV tcpdump -i any -U -w - “port
    ]' on container: 'ksniff-privileged', pod: 'ksniff-znw2q', namespace: 'omec'
INFO[0002] starting sniffer cleanup
INFO[0002] removing privileged container: 'ksniff-privileged'
INFO[0002] executing command: '[/bin/sh -c
    set -ex
    export CONTAINERD_SOCKET="/run/containerd/containerd.sock"
    export CONTAINERD_NAMESPACE="k8s.io"
    export CONTAINER_ID="ksniff-container-EkUMLWmV"
    chroot /host ctr -a ${CONTAINERD_SOCKET} task kill -s SIGKILL ${CONTAINER_ID}
    ]' on container: 'ksniff-privileged', pod: 'ksniff-znw2q', namespace: 'omec'
INFO[0002] command: '[/bin/sh -c
    set -ex
    export CONTAINERD_SOCKET="/run/containerd/containerd.sock"
    export CONTAINERD_NAMESPACE="k8s.io"
    export CONTAINER_ID="ksniff-container-EkUMLWmV"
    chroot /host ctr -a ${CONTAINERD_SOCKET} task kill -s SIGKILL ${CONTAINER_ID}
    ]' executing successfully exitCode: '1', stdErr :'+ export 'CONTAINERD_SOCKET=/run/containerd/containerd.sock'
+ export 'CONTAINERD_NAMESPACE=k8s.io'
+ export 'CONTAINER_ID=ksniff-container-EkUMLWmV'
+ chroot /host ctr -a /run/containerd/containerd.sock task kill -s SIGKILL ksniff-container-EkUMLWmV
ctr: container "ksniff-container-EkUMLWmV" in namespace "k8s.io": not found
'
INFO[0002] privileged container: 'ksniff-privileged' removed successfully
INFO[0002] removing pod: 'ksniff-znw2q'
INFO[0002] removing privileged pod: 'ksniff-znw2q'
INFO[0002] privileged pod: 'ksniff-znw2q' removed
INFO[0002] pod: 'ksniff-znw2q' removed successfully
INFO[0002] sniffer cleanup completed successfully
Error: exit status 1

OS Version: 18.04 Wireshark: 3.6.5

Am I doing something wrong? Can someone give me a hint?

Thank you in advance!

bostrt commented 2 years ago

Hi @fefer!

I'm not immediately sure what the problem is to be honest. I think the logging needs to be improved a lot but I'll track that in a separate issue.

Can you tell me which version of ksniff you are using?

$ kubectl krew list