Search code examples
kubernetesopenshiftkubernetes-statefulset

Implementing statefulset with normal and headless svc


This is first time I am using statefulsets in openshift and would like to understand how do you expose the services to outside world? Do you create two services headless and another normal one? How to get this working?


Solution

  • It depends on your use case and what you are planning for.

    If you are expecting your service to forward a request to any of the available POD of statefulset you can create a normal clusterIP service.

    You have the requirement of getting specific DNS records or You need the IP of each available POD headless (with selector) service will do it for you.

    There is also headless service without selector could be used with Endpointslice to forward traffic to other or External thrid party services.

    Ref : https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors