retina icon indicating copy to clipboard operation
retina copied to clipboard

chore(shell): add bpftrace to shell image

Open alexcastilio opened this issue 6 months ago • 1 comments

Description

Add bpftrace to retina shell.

Related Issue

If this pull request is related to any issue, please mention it here. Additionally, make sure that the issue is assigned to you before submitting this pull request.

Checklist

  • [ ] I have read the contributing documentation.
  • [ ] I signed and signed-off the commits (git commit -S -s ...). See this documentation on signing commits.
  • [ ] I have correctly attributed the author(s) of the code.
  • [ ] I have tested the changes locally.
  • [ ] I have followed the project's style guidelines.
  • [ ] I have updated the documentation, if necessary.
  • [ ] I have added tests, if applicable.

Screenshots (if applicable) or Testing Completed

Tests executed:

# 1. Build binary with: make retina-shell-image
# 2. Push image to registry

# 3. Run kubectl retina shell:
$ ./artifacts/kubectl-retina shell aks-nodepool1-42816995-vmss000000 --capabilities=NET_ADMIN,SYS_ADMIN,SYS_RESOURCE,BPF,MKNOD,SYS_CHROOT --retina-shell-image-version=v0.0.36-3006-5 --retina-shell-image-repo=ghcr.io/alexcastilio/retina/retina-shell --apparmor-unconfined --seccomp-unconfined --mount-host-filesystem

# 4. bpftrace commands executed:
root@aks-nodepool1-42816995-vmss000000 [ / ]# bpftrace -e 'kprobe:tcp_v4_rcv { printf("tcp packet received\n"); }'
Attaching 1 probe...
tcp packet received
tcp packet received
tcp packet received
tcp packet received
tcp packet received
^C

root@aks-nodepool1-42816995-vmss000000 [ / ]# bpftrace -e 'tracepoint:syscalls:sys_enter_connect { printf("connect\n"); }'
Attaching 1 probe...
connect
connect
connect
connect
connect
connect
connect
connect
connect
^C

# for this test, open another terminal and run some commands that make dns calls (e.g. curl, wget)
root@aks-nodepool1-42816995-vmss000000 [ / ]# bpftrace -e 'uprobe:/usr/lib/libc.so.6:getaddrinfo { @start[tid] = nsecs; } uretprobe:/usr/lib/libc.so.6:getaddrinfo { @latency = hist((nsecs - @start[tid]) / 1000); delete(@start[tid]); }'
Attaching 2 probes...
^C
root@aks-nodepool1-42816995-vmss000000 [ / ]#

@latency:
[2K, 4K)               1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[4K, 8K)               1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[8K, 16K)              0 |                                                    |
[16K, 32K)             1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|

Additional Notes

Add any additional notes or context about the pull request here.


Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.

alexcastilio avatar Jun 18 '25 09:06 alexcastilio

Related issue - https://github.com/microsoft/azurelinux/issues/14193

kamilprz avatar Aug 01 '25 14:08 kamilprz