Running profiler on k8s

Questions about YourKit Java Profiler
Post Reply
oali
Posts: 2
Joined: Thu Feb 18, 2021 3:47 pm

Running profiler on k8s

Post by oali »

So I'm having issues running the profiler on k8s. I was able to setup the profiler locally in a docker container and it works but I wanted to run it in the k8s cluster. I start the agent with my jar by using

Code: Select all

-agentpath:/usr/local/YourKit-JavaProfiler-2020.9/bin/linux-x86-64/libyjpagent.so=port=10002,listen=all -jar ...
I have a service that exposed the port 10002. The port of the service that is externally facing is different because k8s creates a random port. When I try and access the endpoint of the node the app is running on using the port that k8s creates I am able to see the summary page.
When I try and connect from the GUI I provide the node name in the k8s cluster where the app is running as the hostname and the profiler agent port is the port that is provided by my service. I see that the connection is green so when I click on it I see it says remote application is being profiled. After a couple of seconds it terminates and says the application was terminated or connection is lost. My app hasn't restarted at all so I don't know why the connection terminated. In the logs in k8s for the Yourkit I see the following:

Code: Select all

 error: Exception in dispatchRequest(): java.io.EOFException
        at java.base/java.io.DataInputStream.readFully(DataInputStream.java:202)
        at java.base/java.io.DataInputStream.readLong(DataInputStream.java:421)
        at com.yourkit.f.au.a(a:50)
        at com.yourkit.runtime.RequestProcessing.dispatchRequest(a:30)
        at com.yourkit.runtime.Core$5.run(a:646)
        at java.base/java.lang.Thread.run(Unknown Source)
Any idea? The connection does work but it doesn't stay connected for more than a few seconds. Am I supposed to add liveness probes to keep it connected?
oali
Posts: 2
Joined: Thu Feb 18, 2021 3:47 pm

Re: Running profiler on k8s

Post by oali »

If someone else runs into this issue I found the solution which was silly. I was running 2 replicas of the app in k8s and didn't think it was a big deal. I decided to take one of the replicas down thinking that even though I was connecting to one node and the other replica was on a different node that it wouldn't cause an issue. Guess I was wrong and it seems running the app with two or more replicas would confuse the profiler and cause it to terminate the connection.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Running profiler on k8s

Post by Anton Katilin »

Perhaps it was a problem with a fixed port you specified for the agent with the option "port=10002". When you use this option please be sure that the port is not opened by another process. The option allows to specify a port range instead to choose a free port from, e.g. "port=10001-10010", see https://www.yourkit.com/docs/java/help/ ... s.jsp#port
jkpanda555
Posts: 2
Joined: Mon Dec 06, 2021 2:48 pm

Re: Running profiler on k8s

Post by jkpanda555 »

Hi Team,

I have an application running on k8s, in 2 PODS.

Before starting the application I have made required changes to copy the yourkit library to the host and changed the java class path and added the yourkit agent path details to start the yourkit only pod when my application stats.

Then I have created 2 NodePorrts based on the lebel details from my pod.

So now I have the Nodeports as below.

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cba-214d-499e-aecb-1d952865e154--1-dbbddddddt NodePort 1.1.1.1. <none> 80:31830/TCP 3d20h
cba935ae-21-499e-aecb-1d952865e154--2-1kjd7777-9x4z7 NodePort 1.1.1.1. <none> 80:32613/TCP 3d20h


And 2 of my PODs are up and running.
I have a yourkit client present in my mac with license, I can not attach the services running in my POD to the yourkit client in my mac, I have tried all the possibilities.


Can you please help me in this regard, will be highly appreciable.

Thank You.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Running profiler on k8s

Post by Anton Katilin »

jkpanda555
Posts: 2
Joined: Mon Dec 06, 2021 2:48 pm

Re: Running profiler on k8s

Post by jkpanda555 »

I already have that added :

-agentpath:/usr/YourKit-JavaProfiler-2021.11/bin/linux-x86-64/libyjpagent.so=port=10010,listen=all
Vladimir Kondratyev
Posts: 1619
Joined: Tue Aug 10, 2004 7:52 pm

Re: Running profiler on k8s

Post by Vladimir Kondratyev »

Before starting the application I have made required changes to copy the yourkit library to the host and changed the java class path and added the yourkit agent path details to start the yourkit only pod when my application stats.
Do agents create logs, which indicates that they are really loaded?
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Running profiler on k8s

Post by Anton Katilin »

Please consider these troubleshooting instructions:
https://www.yourkit.com/docs/java/help/ ... ection.jsp

In particular, do you see the agent status in the web browser (see "Check agent status in a web browser")?

Do you use a proxy? Please check the "Settings | Proxy" configuration in the profiler.
Post Reply