title: how to get SRV DNS address for statefulset headless service
body: <h3><strong>Issue in dns lookup for statefulsets srv records</strong></h3>
  
  <p><strong><em>My yaml file</em></strong></p>
  
  <pre><code>kind: List
  apiVersion: v1
  items:
  - apiVersion: v1
    kind: Service
    metadata:
      name: sfs-svc
      labels:
        app: sfs-app
    spec:
      ports:
      - port: 80
        name: web
      clusterIP: None
      selector:
        app: sfs-app
  - apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: web
    spec:
      selector:
        matchLabels:
          app: sfs-app # has to match .spec.template.metadata.labels
      serviceName: "sfs-svc"
      replicas: 3 
      template:
        metadata:
          labels:
            app: sfs-app # has to match .spec.selector.matchLabels
        spec:
          terminationGracePeriodSeconds: 10
          containers:
          - name: test-container
            image: nginx
            imagePullPolicy: IfNotPresent
            command: [ "sh", "-c"]
            args:
            - while true; do
                printenv MY_NODE_NAME MY_POD_NAME MY_POD_NAMESPACE &gt;&gt; /var/sl/output.txt;
                printenv MY_POD_IP &gt;&gt; /var/sl/output.txt;
                date &gt;&gt; var/sl/output.txt; 
                cat /var/sl/output.txt;
                sleep 999999;
              done;
            env:
              - name: MY_NODE_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: spec.nodeName
              - name: MY_POD_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.name
              - name: MY_POD_NAMESPACE
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.namespace
              - name: MY_POD_IP
                valueFrom:
                  fieldRef:
                    fieldPath: status.podIP
            volumeMounts:
            - name: www
              mountPath: /var/sl
      volumeClaimTemplates:
      - metadata:
          name: www
        spec:
          accessModes: [ "ReadWriteOnce" ]
          #storageClassName: classNameIfAny
          resources:
            requests:
              storage: 1Mi
  
  </code></pre>
  
  <p><strong>$ Kubectl cluster-info</strong></p>
  
  <blockquote>
    <p>Kubernetes master is running at <a href="https://192.168.99.100:8443" rel="nofollow noreferrer">https://192.168.99.100:8443</a>
    KubeDNS is running at <a href="https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy" rel="nofollow noreferrer">https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy</a></p>
  </blockquote>
  
  <p><strong>$ kubectl version</strong></p>
  
  <blockquote>
    <p>Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.3", GitCommit:"721bfa751924da8d1680787490c54b9179b1fed0", GitTreeState:"clean", BuildDate:"2019-02-01T20:08:12Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:02:58Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}</p>
  </blockquote>
  
  <p><strong>$ kubectl get po,svc,statefulset</strong></p>
  
  <pre><code>&gt; NAME        READY   STATUS    RESTARTS   AGE
  &gt; pod/web-0   1/1     Running   0          45m
  &gt; pod/web-1   1/1     Running   0          45m
  &gt; pod/web-2   1/1     Running   0          45m
  &gt; 
  &gt; NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
  &gt; service/kubernetes   ClusterIP   10.96.0.1    &lt;none&gt;        443/TCP   46m
  &gt; service/sfs-svc      ClusterIP   None         &lt;none&gt;        80/TCP    45m
  &gt; 
  &gt; NAME                   READY   AGE
  &gt; statefulset.apps/web   3/3     45m
  &gt; 
  </code></pre>
  
  <h3><strong>PROBLEM: I am not getting DNS address for statefulset headless service</strong></h3>
  
  <p><strong>When I try $ nslookup sfs-svc.default.svc.cluster.local</strong> </p>
  
  <pre><code>&gt; Server:       127.0.0.53
  &gt; Address:  127.0.0.53#53
  &gt; 
  **&gt; ** server can't find sfs-svc.default.svc.cluster.local: SERVFAIL**
  &gt; 
  </code></pre>