<p>I am testing stateful sets with replicas, is there a way to force a service on each replica? For example, if I refer to the following note:</p>
<p><a href="https://itnext.io/introduction-to-stateful-services-kubernetes-6018fd99338d" rel="nofollow noreferrer">https://itnext.io/introduction-to-stateful-services-kubernetes-6018fd99338d</a></p>
<p>It shows headless service is created on top of pods. I do not have a way to force the connection to the first pod or the pod-0 or the 2nd pod i.e. pod-1.</p>

drifter
<p>You can access the pods directly, or you can create headless services as you write. This headless service is not created automatically, it is up to you to create it.</p>
<blockquote>
<p>you are responsible for creating the Headless Service responsible for the network identity of the pods.</p>
</blockquote>
<p>From <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id" rel="nofollow noreferrer">StatefulSet - Stable Network Identity</a></p>
<p>Also see <a href="https://kubernetes.io/docs/concepts/services-networking/service/#headless-services" rel="nofollow noreferrer">StatefulSet Basics - Headless Services</a> on how to create headless services, by setting <code>clusterIP: &quot;None&quot;</code></p>
