gpt4 book ai didi

kubernetes - 如何在 Kubernetes 容器中安装 JProfiler 代理?

转载 作者:行者123 更新时间:2023-12-02 11:39:44 33 4
gpt4 key购买 nike

我必须在容器中放入什么才能让代理运行?只是 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
  • 添加到 JVM 启动参数 JProfiler 作为代理:
  • -agentpath:/jprofiler/bin/linux-x64/libjprofilerti.so=port=8849

    请注意,没有“nowait”参数。这将导致 JVM 在启动时阻塞并等待 JProfiler GUI 连接。原因是使用此配置,分析代理将从 JProfiler GUI 接收其分析设置。

    将应用程序部署更改为仅从一个副本开始。或者,从零副本开始,并在准备开始分析时扩展到一。

    从 JProfiler 的 GUI 连接到远程 JVM:
  • 找出 pod 的名称(例如 kubectl -n <namespace> get pods )并为其设置端口转发:
  • kubectl -n <namespace> <pod-name> port-forward 8849:8849
  • 在本地启动 JProfiler 并将其指向 127.0.0.1,端口 8849。

  • 如果本地端口 8849( : 左侧的数字)不可用,请更改它;然后,将 JProfiler 指向该不同的端口。

    关于kubernetes - 如何在 Kubernetes 容器中安装 JProfiler 代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55647743/

    33 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com