Cloud Malaya Lab
  • Home Cloud Lab
    • Architecture
    • DNS Server
  • DevOps & DevSecOps
    • Kubernetes
      • Fundamental
        • Taints in Kubernetes
        • Kubernetes Observability (Monitoring) Guide
        • DNS in Kubernetes (CoreDNS)
        • Storage in Kubernetes
          • Container Storage Interface - CSI
          • Ephemeral Storage Explain
        • Cluster CPU & Memory Inspections
        • Open Source and Free Storage Solution Kubernetes
      • PoC Lab
        • Configure Access to Multiple Cluster using KUBE_CONFIG
        • High Availability Portable Mini Kubernetes Data Center with K3s
          • Lab 1: Build the K3s Infrastructure
          • Lab 2: Automate the K3s clusters deployment with Ansible
          • Lab 3: Multi Master K3s kubeconfig files for smooth accessibility
          • Lab 4: Network Configurations & Tools
        • AWX/Ansible Tower Deployment on Kubernetes
          • Lab 1 - Understanding Requirements
          • Lab 2 - AWX,AWX Operator Configurations & Deployments
          • Lab 3 - Ingress Networking & Connectivity via Nginx
          • Lab 4: AWX Web Console & accessibility on LAN
        • Troubleshooting: Ansible Tower - Reset admin password
    • Monitoring & Observability
      • Splunk
        • Splunk Deployment for SME (Malay Version)
    • System Administration - Linux
      • RedHat Derivatives
        • Add User to Sudoers
        • Yum Update vs Yum Upgrade
        • DNF update vs upgrade
        • SMP PREEMPT_DYNAMIC Definitions
      • Virtualization
        • KVM
      • Storage
  • Digital Infrastructure & Cloud Solutions
    • Solution & System Design
      • Public Cloud
        • Fundamental
          • AWS
          • Azure
          • GCP
        • Lab
          • Simple CD menggunakan Github Action
      • Private Cloud & On-Premise
      • On-Premise to Cloud Design
        • AWS Direct Connect
      • High Availability & Fault Tolerance Design
      • Disaster Recovery
Powered by GitBook
On this page
  1. DevOps & DevSecOps
  2. Kubernetes
  3. Fundamental

DNS in Kubernetes (CoreDNS)

This article will explain how the DNS works in K8s cluster

PreviousKubernetes Observability (Monitoring) GuideNextStorage in Kubernetes

Last updated 1 year ago

Kubernetes DNS (Domain Name System) provides service discovery and name resolution capabilities within a Kubernetes cluster. It allows applications and services running on the cluster to communicate with each other using their respective names instead of hardcoding IP addresses, which makes the cluster more scalable, maintainable, and dynamic.

Here's a step-by-step explanation of how Kubernetes DNS works:

  1. Pod and Service Creation: When you create a Pod or a Service in Kubernetes, each of them gets assigned a unique DNS name.

  2. DNS Naming Format:

    • Pods: The DNS name of a Pod takes the form: <pod-name>.<namespace>.pod.cluster.local

    • Services: The DNS name of a Service takes the form: <service-name>.<namespace>.svc.cluster.local

    Here, <pod-name> is the name of the Pod, <namespace> is the namespace where the Pod or Service is located, and cluster.local is the default DNS suffix for the cluster.

  3. DNS Resolution for Pods: When one Pod needs to communicate with another Pod within the same cluster, it can do so using the Pod's DNS name. The DNS resolution process starts with the Pod querying the Kubernetes DNS service (typically running on kube-dns or coredns pods). The DNS service has access to the cluster's Service and Pod IP addresses.

  4. DNS Resolution for Services: When a Pod needs to communicate with a Service, it can use the Service's DNS name. Kubernetes DNS resolves the Service DNS name to the corresponding set of IP addresses of the Service endpoints. These endpoints are typically the IP addresses of the Pods backing the Service.

  5. Load Balancing: Kubernetes DNS provides a level of load balancing for Services. When multiple Pods back a Service, the DNS resolution returns multiple IP addresses. The client (calling Pod) can use one of these IP addresses to communicate with the Service. Kubernetes handles load balancing across the selected Pods.

  6. Automatic Updates: Kubernetes DNS automatically updates the DNS records whenever Pods or Services are created, deleted, or scaled. This ensures that the DNS system stays in sync with the current state of the cluster.

  7. Custom DNS Configurations: Kubernetes allows you to configure custom DNS options for your cluster. For example, you can set up additional DNS nameservers or search domains to resolve external DNS queries or utilize other DNS services.

In summary, Kubernetes DNS simplifies the process of service discovery and communication between Pods and Services within a Kubernetes cluster by providing a dynamic and scalable naming system. This abstraction helps maintain the decoupling between services and enables smooth scaling and management of applications within the cluster.

How CoreDNS query works