我必须在容器中放入什么才能让代理运行?只是 libjprofilerti.so 本身不起作用,我明白了
Could not find agent.jar. The agentpath parameter must point to
libjprofilerti.so in an unmodified JProfiler installation.
这对我来说听起来很明显是胡说八道 - 当然我不能在每个我想要分析某些内容的容器中安装超过 137.5 MB 的文件,其中 99% 将是无关紧要的?
-agentpath:/path/to/libjprofilerti.so=nowait
最佳答案
一种方法是使用 Init Container .
这个想法是将 JProfiler 的图像与应用程序的图像分开。将 JProfiler 镜像用于初始化容器; Init Container 将 JProfiler 安装复制到该 Init Container 和将在 Pod 中启动的其他 Container 之间共享的卷。这样,JVM 可以在启动时从共享卷中引用 JProfiler 代理。
它是这样的(更多细节在这个 blog article 中):
volumes:
- name: jprofiler
emptyDir: {}
initContainers:
- name: jprofiler-init
image: <JPROFILER_IMAGE:TAG>
command: ["/bin/sh", "-c", "cp -R /jprofiler/ /tmp/"]
volumeMounts:
- name: jprofiler
mountPath: "/tmp/jprofiler"
替换
/jprofiler/
上面带有 JProfiler 镜像中安装目录的正确路径。请注意,复制命令将创建 /tmp/jprofiler
JProfiler 安装所在的目录 - 用作安装路径。volumeMounts:
- name: jprofiler
mountPath: /jprofiler
-agentpath:/jprofiler/bin/linux-x64/libjprofilerti.so=port=8849
请注意,没有“nowait”参数。这将导致 JVM 在启动时阻塞并等待 JProfiler GUI 连接。原因是使用此配置,分析代理将从 JProfiler GUI 接收其分析设置。
将应用程序部署更改为仅从一个副本开始。或者,从零副本开始,并在准备开始分析时扩展到一。
从 JProfiler 的 GUI 连接到远程 JVM:
kubectl -n <namespace> get pods
)并为其设置端口转发:kubectl -n <namespace> <pod-name> port-forward 8849:8849
如果本地端口 8849(
:
左侧的数字)不可用,请更改它;然后,将 JProfiler 指向该不同的端口。
关于kubernetes - 如何在 Kubernetes 容器中安装 JProfiler 代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55647743/