<p>I have a JVM applicaiton running in kubernetes. When I run <code>kubectl top pod</code> I can see the following</p>

<pre><code>mypod1                    12m          6035Mi
mypod2                    11m          6129Mi
mypod3                    11m          6334Mi
</code></pre>

<p>I would like to find out whether that 6GB memory is good or bad. My kubernetes deployment yaml does not specify any resources </p>

<p><strong>Questions</strong> </p>

<ul>
<li>How can I find out the maximum number that it can get to?</li>
<li>How can I find out whether jvm is performing well?</li>
<li>Is there a profiler I can connect to the jvm running in the pods?</li>
</ul>

Anthony
<p>Question #1: "How can I find out the maximum number that it can get to?" 
A: Without <code>resources</code> configured in the deployment, a pod will have QoS class of BestEffort and can use as much memory as it is available on the node where it is running. See also my answer to this question: <a href="https://stackoverflow.com/questions/53812196/how-can-i-tell-how-much-ram-my-kubernetes-pod-has/53826135#53826135">How can I tell how much RAM my Kubernetes pod has?</a></p>

<p>It is always a good practice, IMHO, to at least specify the min (<code>-Xms</code>) and max (<code>-Xmx</code>) JVM heap...</p>

<p>Question #2: "How can I find out whether jvm is performing well?"
A: You can start with enabling JMX and then using it to collect JVM and application metrics. Besides the JMX-to-HTTP bridges like <a href="https://jolokia.org/" rel="nofollow noreferrer">Jolokia</a> and <a href="https://github.com/prometheus/jmx_exporter" rel="nofollow noreferrer">Prometheus JMX Exporter</a>, it is also an option to connect directly over JMX. One way is to:</p>

<ul>
<li><p>Expose JMX by configuring these JVM startup arguments:</p>

<pre><code>-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=4444 -Djava.rmi.server.hostname=127.0.0.1
</code></pre></li>
</ul>

<p>Notice that this affixes the otherwise dynamic RMI port and sets hostname for the RMI server. </p>

<ul>
<li><p>Forward local ports to these ports on the pod:</p>

<pre><code>kubectl --namespace=&lt;namespace&gt; port-forward &lt;pod-name&gt; 4444:4444 1099:1099
</code></pre></li>
<li><p>Start locally a tool that can connect to the JVM in the pod over JMX (jconsole, jvisualvm, jmc...based on what's available to you). The JMX URL would be:</p>

<pre><code>service:jmx:rmi://127.0.0.1:4444/jndi/rmi://127.0.0.1:1099/jmxrmi
</code></pre></li>
</ul>

<p>Question #3: "Is there a profiler I can connect to the jvm running in the pods?"
A: The short answer is "yes". I have used JProfiler to remotely profile Java apps running on k8s through port forwarding. (I am not affiliated with JProfiler nor am promoting it - it was simply the tool the team I was helping had a license for) </p>
