0

For statefulsets, I am wondering if it's possible to put each replica behind a virtual ip, perhaps using a Service, so that we have the same connection and DNS behavior for per replica host names as we do for ClusterIP hostname that we get for a non-headless service.

When we use replica hostnames, we seem to lose the load balancing and connection management provided by virtual ip, and that causes problems for our app.

Leo
  • 695
  • 3
  • 11
corsair
  • 347
  • 3
  • 13
  • What exactly is your current scenario. Don't forget, ip address changes, network issues can always happen, no matter which type of services or environment you're using. Better approach is to harden you app, that it is not sensitive to changes. – Manuel Mar 12 '22 at 16:46

1 Answers1

0

You can improve your DNS request by deploying a NodeLocal DNS Cache. This could help to reduce the average DNS lookup time. The local DNS cache can be used with kube dns ConfigMAP to automatically pick up stub domains and upstream nameservers.

You can enable this feature in an existing cluster adding the –update-addons with the argument NodeLocalDNS=ENABLED like it is shown in the following example:

gcloud container clusters update CLUSTER_NAME \
    --update-addons=NodeLocalDNS=ENABLED

You can find more information regarding this feature in this link:

Also to setup a service when you are using a StatefulSet you can use the Pod label, this label allows you to attach a Service to a specific Pod.

In addition you can deploy a Health check to review if your backend responds to traffic, If the backend fails to respond will be marked as unhealthy and the traffic will be attended by the healthy backend

Leo
  • 695
  • 3
  • 11