title: How do I get individual pod hostnames in a Deployment registered and looked up in Kubernetes?
body: <p>I need to know all the hostnames for all the pods in a Deployment in Kubernetes. </p>
  
  <p>Based on <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a>, I tried: </p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: default-subdomain
  spec:
    selector:
      name: busybox
    clusterIP: None
    ports:
    - name: foo
      port: 1234
      targetPort: 1234
  ---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: busybox1
    labels:
      name: busybox
  spec:
    replicas: 2
    selector:
      matchLabels:
        name: busybox
    template:
      metadata:
        labels:
          name: busybox
      spec:
        hostname: dummy &lt;---- effect of this line 
        subdomain: default-subdomain
        containers:
        - image: busybox
          command:
            - sleep
            - "99999"
          name: busybox
          stdin: true
          tty: true
  </code></pre>
  
  <ol>
  <li>If I don't add the hostname, no pods are registered with DNS</li>
  <li>If I do add the hostname value, there is only one entry in the DNS</li>
  </ol>
  
  <p>How can I get every pod in a deployment to be registered, preferably using the pod name, and looked up by fqdn of the pod - e.g. pod_name.subdomin.namespace.svc.cluster.local?</p>