<p>I wanted to know if there is any way that I can set a DNS for the Pod in the StatefulSet, so I can call them directly.</p>
<p>I have read the Kubernetes documentation, but I haven't seen anything useful.</p>

ali heydarabadii
<p>You can directly hit the POD if using the statefulset with <strong>headless</strong> service</p>
<p>So if you have three replicas running web-0, web-1, web-2 you can use curl</p>
<pre><code>web-0.&lt;service-name&gt;.&lt;namespace-name&gt;.svc.cluster.local
</code></pre>
<p>POD name</p>
<pre><code>&lt;pod-name&gt;.&lt;service-name&gt;.&lt;namespace-name&gt;.svc.cluster.local
</code></pre>
<p>But the important part is your service should be <strong>headless</strong></p>
<p><strong>Example</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: &quot;nginx&quot;
  replicas: 3 
  minReadySeconds: 10 
  template:
    metadata:
      labels:
        app: nginx 
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: registry.k8s.io/nginx
        ports:
        - containerPort: 80
          name: web
</code></pre>
<p>Official doc ref : <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id</a></p>
