Route to a given replica of a statefulset in Openshift/Kubernetes

9/11/2017

Do you know if there is a way with the statefulset feature in kubernetes/openshift to create 1 route per replica (ie 1 route that will allow me to access from the outside 1 specific replica of my statefulset).

The context is the following.

I am currently trying to deploy spark masters in HA mode in Openshift through statefulsets.
My statefulset "spark" is "linked" to an headless service "spark".

Everything is working fine when I am staying at the service levels for the inter-cluster communication.

I mean:

  • I have n pods named "spark-0", "spark-1", ...., "spark-n"
  • All those PODs are accessible within my openshift cluster through the DNS names "spark-0.spark", "spar-1.spark", ...., "spark-n.spark"

The issue I have is when I start creating the routes to make them accessible from the outside.
I can easily create a route "spark-route" that will be "linked" to the "spark" service on the port 8080 for example.
By doing so, I will have 1 route that will load balance to my "n" pods.

But what I would like to have is rather to have n routes (spark-route-1, ..., spark-route-n), each of those route redirecting to a specific replica within my statefulsets.
Indeed, from the outside, I need to explicity see the web ui of spark-1, spark-2, ..., spark-n.
I don't want to have my request load-balanced in such a case.

-- Julien
kubernetes
openshift
statefulset

0 Answers