Kubernetes Job running a Cross Language Java class

Hello. I’m doing some experiments to run Java code within a Python driver in a Ray Kubernetes cluster.

I already have the cluster up using the Kubernetes operator, and I’ve successfully tested the run on head strategy:

  • I’ve built my own custom Ray Docker image with Java Installed, and with my fat jar. I use that image for the head/workers pods.

  • I can run the application on the head node running the driver. Driver code

That run on head strategy works fine.

My problem is when I’ve tried to test the Kubernetes job strategy. In that case, the example driver connects to the cluster using the Ray Client:

if __name__ == "__main__":
    head_service_ip = os.environ[HEAD_SERVICE_IP_ENV]
    client_port = os.environ[HEAD_SERVICE_CLIENT_PORT_ENV]
    ray.util.connect(f"{head_service_ip}:{client_port}")
    main()

What’s the right way to set the code search path for my .jar in the job driver code?

Since the code example isn’t using ray.init(), I haven’t been able to find it.

Thank you !

Hey Marco,

thanks for your post! Using Java with the Ray client is very bleeding edge, I’m not sure if anybody has done that yet :slight_smile:

You can try to use the env_vars field of the runtime_env parameter to ray.util.connect, see ray/runtime_env.py at 268409b6ad29822e5a30aee90772615bc4c23247 · ray-project/ray · GitHub to set an environment variable so the JVM can pick up your JAR, but the details would need to be worked out. If you get it working please report back, this might also be interesting for other users :slight_smile:

Best regards,
Philipp.

1 Like

Hi Phillip !

I’ll give a try to that. If it works, I’ll report back.

Thank you.