<p>I am configuring a statefulset deploying 2 Jira DataCenter nodes. The statefulset results in 2 pods. Everything seems fine until the 2 pods try to connect to eachother. They do this with their <strong>short hostname</strong> being <em>jira-0</em> and <em>jira-1</em>.</p>
<p>The jira-1 pod reports <em>UnknownHostException</em> when connecting to jira-0. The hostname can not be resolved.</p>
<p>I read about adding a <strong>headless service</strong> which I didn't have yet. After adding that I can resolve the FQDN but still no luck for the short name.</p>
<p>Then I read this page: <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">DNS for Services and Pods</a> and added:</p>
<pre><code>      dnsConfig:
        searches:
          - jira.default.svc.cluster.local
</code></pre>
<p>That solves my issue but I think it shouldn't be necessary to add this?</p>
<p>Some extra info:</p>
<ul>
<li>Cluster on AKS with CoreDNS</li>
<li>Kubernetes v1.19.9</li>
<li>Network plugin: Kubenet</li>
<li>Network policy: none</li>
</ul>
<p>My full yaml file:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: jira
  labels:
    app: jira
spec:
  clusterIP: None
  selector:
    app: jira
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: jira
spec:
  serviceName: jira
  replicas: 0
  selector:
    matchLabels:
      app: jira
  template:
    metadata:
      labels:
        app: jira
    spec:
      containers:
      - name: jira
        image: atlassian/jira-software:8.12.2-jdk11
        readinessProbe:
          httpGet:
            path: /jira/status
            port: 8080
          initialDelaySeconds: 120
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /jira/
            port: 8080
          initialDelaySeconds: 600
          periodSeconds: 10
        envFrom:
          – configMapRef:
              name: jira-config
        ports:
        - containerPort: 8080
      dnsConfig:
        searches:
          - jira.default.svc.cluster.local
</code></pre>

<blockquote>
<p>That solves my issue but I think it shouldn't be necessary to add this?</p>
</blockquote>
<p>From the <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSet documentation</a>:</p>
<blockquote>
<p>StatefulSets currently require a Headless Service to be responsible for the network identity of the Pods. <strong>You are responsible for creating this Service.</strong></p>
</blockquote>
<blockquote>
<p>The example above will create three Pods named web-0,web-1,web-2. A StatefulSet can use a Headless Service to control the domain of its Pods.</p>
</blockquote>
<p>The pod-identity is will be subdomain to the <em>governing service</em>, eg. in your case it will be e.g:</p>
<pre><code>jira-0.jira.default.svc.cluster.local
jira-1.jira.default.svc.cluster.local
</code></pre>
