1

I have a statefulset that I need to run using the host network, purely for performance reasons. But I also want to be able to reference service-name endpoints. Is it possible to do this? ClusterFirstWithHostNet does not work because it doesn't prioritize using the host's network. The dnsConfig configuration might be promising, but I don't know how I would configure it to do what I'm asking about.

Mike
  • 961
  • 6
  • 19
  • 43
  • Hi, could you please tell more about the use case that you are having? What exactly you mean by `But I also want to be able to reference service-name endpoints` Could you please provide any example for it for better understanding? Also, I'd reckon you could run into issues when trying to run multiple replicas with a `hostNetwork` when they will be scheduled on the same `Node` (port assignment). – Dawid Kruk Jun 30 '21 at 15:52
  • I need to use hostNetwork purely for performance reasons. I also need to be able to reach a service internal to the cluster and due to AWS limitations, an internal NLB will not work. I could use the service static IP, but would prefer not to. These pods run background jobs so is it possible to have K8s assign it a random port on the node? – Mike Jul 02 '21 at 01:06
  • Unfortunately I did not find a good solution. I had to work around it by referencing the services by their IP instead of name. – Mike Jul 31 '21 at 18:23

1 Answers1

0

This is a community wiki answer. Feel free to expand it.

It might be possible if the app can select random port to listen during start and change if port is busy. However, Kubernetes is not involved in the selecting port for the application.

Statefulset requires a headless service, so it doesn't have an IP and works as a set of DNS records in coredns. A record would probably contain the same IP for the replicas on the same node, but SRV record may actually provide a proper endpoint.

For further reference, please take a look at the below sources:

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37