【发布时间】:2017-06-02 21:02:31
【问题描述】:
我想在我的 Kubernetes 集群上分析我的 play 应用程序。
我正在使用VisualVM,我采取的步骤如下:
- 图像基于最新的 ubuntu 构建
-
使用以下参数运行我的 play 应用程序:
"-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.port=1098" 我的图片有
apt-get install -y visualvm- 我愿意
kubectl port-forward <Container> 1098 - 打开 VisualVM,我看不到进程。
我不确定我在这里做错了什么。在 localhost 上运行应用程序时(不是通过 IDE,直接从启动脚本),一切正常。
更新 1、部署和服务
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: myApp labels: name: myApp spec: replicas: 1 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: metadata: name: myApp labels: name: myApp spec: containers: - name: myApp image: ... args: ["-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.port=1098"] ports: - containerPort: 9000 env: ...
apiVersion: v1
kind: Service
metadata:
name: myApp
labels:
name: myApp
spec:
selector:
name: myApp
ports:
- port: 80
targetPort: 9000
更新 2 @marcospereira
文件->添加JMX连接-> localhost:1098
无法使用服务 jmx:rmi 连接到 localhost:1098...
【问题讨论】:
-
你能添加你的部署和服务定义吗?
-
那是因为,当你在本地运行时,visualvm 知道如何识别本地 Java 进程。您需要添加一个“JMX 连接”(文件 -> 添加 JMX 连接)。
标签: java docker profiling kubernetes