在kubernetes中分析Java应用程序

我想在我的Kubernetes集群上剖析我的应用程序。

我正在使用VisualVM,我采取的步骤如下所示:

  1. 图像是build立在最新的Ubuntu的
  2. 使用以下参数运行我的游戏应用程序:

    "-Dcom.sun.management.jmxremote", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false", "-Dcom.sun.management.jmxremote.port=1098" 
  3. 我的图像有apt-get install -y visualvm

  4. 我做kubectl port-forward <Container> 1098
  5. 打开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

无法连接到本地:1098使用服务jmx:rmi …