title: Profiling Java application in kubernetes
body: <p>I want to profile my play application on my Kubernetes cluster.</p>
  
  <p>I am using VisualVM, and the steps that I have taken are as follows:</p>
  
  <ol>
  <li>Image is built on ubuntu latest</li>
  <li><p>Running my play application with the following args:</p>
  
  <pre><code>"-Dcom.sun.management.jmxremote",
  "-Dcom.sun.management.jmxremote.ssl=false",
  "-Dcom.sun.management.jmxremote.authenticate=false",
  "-Dcom.sun.management.jmxremote.port=1098"
  </code></pre></li>
  <li><p>My Image has <code>apt-get install -y visualvm</code> </p></li>
  <li>I do <code>kubectl port-forward &lt;Container&gt; 1098</code></li>
  <li>Open VisualVM, And I don't see the process. </li>
  </ol>
  
  <p>I am not sure what I am doing wrong here. When running the application on localhost (not via IDE, straight from the startup script) everything works fine.</p>
  
  <p><strong>Update 1, deployment and service</strong></p>
  
  <blockquote>
  <pre><code>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:
          ...
  </code></pre>
  </blockquote>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: myApp
    labels:
      name: myApp
  spec:
    selector:
      name: myApp
    ports:
      - port: 80
        targetPort: 9000
  </code></pre>
  
  <p><strong>Update 2 @marcospereira</strong></p>
  
  <p>File->Add JMX connection-> localhost:1098</p>
  
  <p>Cannot connect to localhost:1098 using service jmx:rmi...</p>