{"slug":"ref-kubernetes-462bed4029bbdccd35aa","title":"DNS for Services and Pods — Pod's hostname and subdomain fields","summary":"Currently when a Pod is created, its hostname (as observed from within the Pod) is the Pod's metadata.name value.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nCurrently when a Pod is created, its hostname (as observed from within the Pod) is the Pod's metadata.name value.\n\nThe Pod spec has an optional hostname field, which can be used to specify a different hostname. When specified, it takes precedence over the Pod's name to be the hostname of the Pod (again, as observed from within the Pod). For example, given a Pod with spec.hostname set to \"my-host\", the Pod will have its hostname set to \"my-host\".\n\nThe Pod spec also has an optional subdomain field which can be used to indicate that the pod is part of sub-group of the namespace. For example, a Pod with spec.hostname set to \"foo\", and spec.subdomain set to \"bar\", in namespace \"my-namespace\", will have its hostname set to \"foo\" and its fully qualified domain name (FQDN) set to \"foo.bar.my-namespace.svc.cluster.local\" (once more, as observed from within the Pod).\n\nIf there exists a headless Service in the same namespace as the Pod, with the same name as the subdomain, the cluster's DNS Server also returns A and/or AAAA records for the Pod's fully qualified hostname.\n\nBounded code example (external data; do not execute automatically):\n```yaml\napiVersion: v1\nkind: Service\nmetadata:\n  name: busybox-subdomain\nspec:\n  selector:\n    name: busybox\n  clusterIP: None\n  ports:\n  - name: foo # name is not required for single-port Services\n    port: 1234\n---\napiVersion: v1\nkind: Pod\nmetadata:\n  name: busybox1\n  labels:\n    name: busybox\nspec:\n  hostname: busybox-1\n  subdomain: busybox-subdomain\n  containers:\n  - image: busybox:1.28\n    command:\n      - sleep\n      - \"3600\"\n    name: busybox\n---\napiVersion: v1\nkind: Pod\nmetadata:\n  name: busybox2\n  labels:\n    name: busybox\nspec:\n  hostname: busybox-2\n  subdomain: busybox-subdomain\n  containers:\n  - image: busybox:1.28\n    command:\n      - sleep\n      - \"3600\"\n    name: busybox\n```\n\nGiven the above Service \"busybox-subdomain\" and the Pods which set spec.subdomain to \"busybox-subdomain\", the first Pod will see its own FQDN as \"busybox-1.busybox-subdomain.my-namespace.svc.cluster-domain.example\". DNS serves A and/or AAAA records at that name, pointing to the Pod's IP. Both Pods \"busybox1\" and \"busybox2\" will have their own address records.\n\nAn can specify the DNS hostname for any endpoint addresses, along with its IP. …\n\nAttribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","kubernetes","concepts","services-networking","dns","services","pods","pod","hostname","subdomain","fields"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/kubernetes/website/blob/6449f1eced66d36159c06c3cfae1d1aeec40d4a3/content/en/docs/concepts/services-networking/dns-pod-service.md","source_name":"Kubernetes Documentation","source_license":"CC-BY-4.0","source_revision":"6449f1eced66d36159c06c3cfae1d1aeec40d4a3","source_path":"content/en/docs/concepts/services-networking/dns-pod-service.md :: Pod's hostname and subdomain fields","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:31:51.084786+00:00","url":"https://wikikv.com/k/ref-kubernetes-462bed4029bbdccd35aa","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-kubernetes-462bed4029bbdccd35aa","markdown":"https://wikikv.com/k/ref-kubernetes-462bed4029bbdccd35aa?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-kubernetes-462bed4029bbdccd35aa","json_ld":"https://wikikv.com/k/ref-kubernetes-462bed4029bbdccd35aa?format=jsonld"}}