josepdcs / kubectl-prof

kubectl-prof is a kubectl plugin to profile applications on kubernetes with minimum overhead
Apache License 2.0
36 stars 3 forks source link

Adding multi-arch to jvm based profiling #37

Closed kikokikok closed 4 months ago

kikokikok commented 5 months ago

ADDED: switched to buildx to ease the multi-platform builds ADDED: Variabilization of the async-profiler version CHANGED: switched to supported version of Java container images as a base images fixes #34

josepdcs commented 5 months ago

I think that it will not work now: https://github.com/josepdcs/kubectl-prof/blob/c5d294ea36192b24ce769beda081eba33808744a/internal/agent/profiler/jvm/jcmd.go#L29

By the way, you can test your customized image by using the flag: --image and check that everything still working

kikokikok commented 5 months ago

I think that it will not work now:

https://github.com/josepdcs/kubectl-prof/blob/c5d294ea36192b24ce769beda081eba33808744a/internal/agent/profiler/jvm/jcmd.go#L29

By the way, you can test your customized image by using the flag: --image and check that everything still working

Ok thanks will try that, didn't know how I could test locally built images. I thought the CI would be a effective way of identifying the issues. Will definitely try the --image to test it locally, shouldn't be an issue.

kikokikok commented 5 months ago

updated and tested for debian and alpine based images. I've added a custom built java sdk containing only jcmd to reduce resulting image sizes For Alpine, I had to add an async-profiler build-stage as they don't provide the native libs for arm64.

josepdcs commented 4 months ago

Hi, @kikokikok

Have you tried generating a Heapdump or a JFR with JCMD? Please let me know if it worked for you, whether you used Alpine or not. If it worked, I will accept the PR. Thank you

kikokikok commented 4 months ago

Done, I've tested all scenario you mentioned and everything is working. Had a glitch on the minideb based JDK which is now fixed and an issue I suppose you had also due to the split binary which was not compatible with the -e argument. Everything is functional on my side for both distributions.

kikokikok commented 4 months ago

kubectl prof back-0 --target-container-name back --runtime-path "/run/k3s/containerd" -t 5m -l java -o heapdump --tool jcmd --namespace kapp --image=zot.kyri.test/kubectl-prof:v1.3.17-dev-jvm
Verifying target pod ... ✔ Launching profiler ... ✔ Profiling ... ✔ Remote profiling file downloaded in 14.967091 seconds. ✔ The profiling result file [agent-heapdump-27858-1-2024-05-27T08_51_45Z.hprof] was obtained in 64.394824 seconds. 🔥 ➜ kubectl-prof git:(main) ✗ kubectl prof back-0 --target-container-name back --runtime-path "/run/k3s/containerd" -t 5m -l java -o heapdump --tool jcmd --namespace kapp --image=zot.kyri.test/kubectl-prof:v1.3.17-dev-jvm-alpine Verifying target pod ... ✔ Launching profiler ... ✔ Profiling ... ✔ Remote profiling file downloaded in 8.536349 seconds. ✔ The profiling result file [agent-heapdump-27858-1-2024-05-27T08_54_12Z.hprof] was obtained in 36.787063 seconds. 🔥

josepdcs commented 4 months ago

Great, @kikokikok !!