工作負載也會使用 DNS 名稱存取外部服務,例如 example.net。如要進一步瞭解 Kubernetes 中的 DNS 行為,請參閱「服務和 Pod 的 DNS」。
CoreDNS
Azure 上的 GKE 會使用 CoreDNS 解析叢集內的 DNS 名稱。CoreDNS 會以冗餘的調整式部署形式,在 kube-system 命名空間中執行。CoreDNS 部署作業會建立 Service,將 CoreDNS Pod 分組,並為這些 Pod 指派單一 IP 位址。CoreDNS 部署會根據叢集大小和用量進行擴充。
NodeLocal DNSCache
Azure 上的 GKE 會使用 NodeLocal DNSCache 提升 DNS 查詢效能。NodeLocal DNSCache 會在叢集的每個節點上以 DaemonSet 形式執行。當 Pod 發出 DNS 要求時,要求會先傳送至同一節點上的 DNS 快取。如果快取無法解析 DNS 要求,就會將要求轉送至下列其中一個位置:
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-31 (世界標準時間)。"],[],[],null,["# Service discovery and DNS overview\n==================================\n\nThis topic describes how GKE on Azure interacts with Domain\nName Services (DNS).\n\nService discovery\n-----------------\n\nService discovery is the process where workloads discover services without\nknowing the service's IP address. This section describes how\nGKE on Azure implements service discovery and managed DNS.\n\nKubernetes automatically generates service names that use the following\n[specification](https://github.com/kubernetes/dns/blob/master/docs/specification.md):\n\n\u003cvar translate=\"no\"\u003eservice\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003enamespace\u003c/var\u003e`.svc.cluster.local`\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eservice\u003c/var\u003e: your service's name\n- \u003cvar translate=\"no\"\u003enamespace\u003c/var\u003e: your service's Namespace\n\nWorkloads also access external services--- for example `example.net`---\nusing DNS names. For more information on the behavior of DNS in Kubernetes, see\n[DNS for Services and Pods](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/).\n\n### CoreDNS\n\nGKE on Azure uses\n[CoreDNS](https://kubernetes.io/blog/2018/07/10/coredns-ga-for-kubernetes-cluster-dns/)\nto resolve DNS names within clusters. CoreDNS runs as a redundant, scaled\n[Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)\nin the `kube-system`\nnamespace. The CoreDNS deployment has a\n[Service](/kubernetes-engine/docs/concepts/service) that groups the CoreDNS Pods\nand gives them a single IP address. The CoreDNS Deployment scales with the\ncluster's size and usage.\n\n### NodeLocal DNSCache\n\nGKE on Azure uses\n[NodeLocal DNSCache](https://kubernetes.io/docs/tasks/administer-cluster/nodelocaldns/)\nto improve DNS lookup performance. NodeLocal DNSCache runs as a\n[DaemonSet](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/)\non each node in your cluster. When a Pod makes a DNS request, the request first\ngoes to the DNS cache on the same node. If the cache can't resolve the DNS\nrequest, the cache forwards the request to either:\n\n- CoreDNS for an internal name--- for example `foo.bar.svc.cluster.local`\n\nWhat's next\n-----------\n\n- For an overview of how DNS is used in Kubernetes clusters, see [DNS for Services and Pods](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/)."]]