Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • DSA
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps
    • Software and Tools
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Go Premium
  • DevOps Lifecycle
  • DevOps Roadmap
  • Docker Tutorial
  • Kubernetes Tutorials
  • Amazon Web Services [AWS] Tutorial
  • AZURE Tutorials
  • GCP Tutorials
  • Docker Cheat sheet
  • Kubernetes cheat sheet
  • AWS interview questions
  • Docker Interview Questions
  • Ansible Interview Questions
  • Jenkins Interview Questions
Open In App

Kubernetes - Service DNS

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

An open-source container orchestration system called Kubernetes is primarily employed for the automated deployment, scaling, and management of software. Another name for Kubernetes is K8s. Initially created by Google, Kubernetes is currently maintained by the Cloud Native Computing Foundation. Although it now supports both containers and CRI-O in addition to the Docker runtime with which it was first intended to communicate.

Automating the operational chores of container management is Kubernetes' primary goal. It has built-in commands for application deployment and rolling out necessary modifications to the application. Companies like Google, Spotify, and Capital One are now using it.

Table of Content

  • What is DNS?
  • What is Kubernetes Services DNS?
  • Namespaces of Services
  • DNS Records
  • What Is CoreDNS?
  • Difference Between Kube-DNS And CoreDNS
  • Confguration Files: Corefile
  • DNS For Services And Pods
  • Kubernetes Service DNS
  • Types of DNS Services
  • Pods
  • Features of DNS services
  • DNS search Domain List Limits
  • Customizing DNS Service
  • Using CoreDNS for Service Discovery
  • How to Configure DNS for A Cluster? A Step-By-Step Guide
  • Pod's DNS Policy
  • Trouble Shooting Issues of Kubernetes DNS
  • Best Practices of Kubernetes External DNS

What is DNS?

DNS stands for Domain Name System. It is a system for giving different types of information with unique easy to remember names. It is useful to give a lightweight mechanism for service discoveries. Due to the built-in service discovery, it is easy for applications to communicate with each other in Kubernetes clusters. 

What is Kubernetes Services DNS?

In Kubernetes DNS record is created for both Services and Pods. we can use consistent DNS names instead of IP addresses to contact services. After scheduling a DNS Pod and Service on the cluster, Kubernetes DNS instructs the kubelets to tell the individual containers to use the DNS Service's IP to resolve DNS names. Every service that is defined in a cluster is given a DNS name, this includes the DNS server itself. The client Pod's search list will include the Pod's own name and cluster definition by default. 

Namespaces of Services

A DNS query may return different results. The returned value is based on the namespace of the Pod that is making it. It is not specified by DNS queries that the namespace is limited to DNS queries. Think of a data service in the prod namespace and a pod in the test namespace. Due to the usage of the pod's test name case, a query for data yields no results, while a query for data does. Prod produces the desired outcome because the namespace is provided there.

k8s-namespaces

DNS Records

DNS records are just like a address book for the internet, it translatesd the domain names into the IP address that computer can be understandable. It includes various types of records such as A records that used for pointing a domain to a specific IP address, MX records that used for email servers, and CNAME records that used for aliasing one domain to another. Proper management of DNS records is crucial for establishing smooth internet connectivity and service accesibility.

What Is CoreDNS?

CoreDNS is a flexible DNS server that is developed in go language. It is designed for modern cloud native environements that comes with modular architecture. It supports various plugins and will be supportive for customizing for different usecases. Its gaining popularity with diverse platforms beyond the kuberentes.

Difference Between Kube-DNS And CoreDNS

The following are the difference between kube-DNS and CoreDNS:

Features

Kube DNS

CoreDNS

Architecture

kube-DNS is based on skyDNS that is mainly trained for kubernetes cluster

CoreDNS is a general purpose DNS server that comes with modular design

Extensibility

It has limited extensibility and cusomization options

It is highly extensible through using middleware plugins

Performance

It's performance has optimized for kubernetes workloads for having efficient service discovery

It has efficient performance with configurable caching.

Flexibility

It is mainly designed for k8s environments only.

It can be suitable for the various environments and usecases.

Adoption

It is widely adoptable within the kubernetes ecosystem.

It has gaining the popular outside the k8s as well.

Confguration Files: Corefile

The Corefile is a configuration file that is used for DNS servers. It contains the definition and configurations regarding how CoreDNS should operates. It includes which plugins to use, their order and configuraiton parameters. Its simple syntax and modular design facilitates users to use coreDNS to their specific needs.

DNS For Services And Pods

DNS for services and pods are vital for communication within the cluster for having communication with their names.

  • DNS For Services: It enables the support of establishing communication between the services through their names. It will map the name of service with respecitve their IP address and lets to have communication with names instead of IP addresses.
  • DNS For Pods: It facilitatest intra-cluster communication of pods with their hostnames instead of having with their IP addresses. It lets pods can communicate with each other using these hostnames without the needing to known their IP addresses directly with providing abstraction in networking.

Kubernetes Service DNS

we can set up a DNS system with two well-supported add-ons namely CoreDNS and KubeDNS. The CoreDNS feature is one of the best and latest add on and it acts as a default DNS server. Both the add-ons can schedule a DNS pod or pods or services with a static IO on the cluster and both are named as kube dns in the metadata. name field. 

Types of DNS Services

The types of DNS Services are listed as follows:

1. A/AAAA Records

2. SRV Records

A/AAAA Records

Normal services are assigned to a DNS A or AAAA record. For a name of the type my-svc.my-namespace.svc.cluster-domain.example, this will resolve to the cluster IP of the Service. This relies on the IP family of the Services.

Additionally, dependent on the IP family of the service, headless services are given a DNS A or AAAA record with the name of the format my-svc.my-namespace.svc.cluster-domain.example. This will resolve to the collection of pod IPs that the service has chosen.

Corefile configuration

SRV Records

They were primarily developed for named ports that were essential to Headless Services or regular services. Every named port will have an SRV record of the format _my-port-name. my-port-protocol.my-svc.my-namespace.svc.cluster-domain.example. This resolves to the port number and, in the case of a typical service, the domain name my-svc.my-namespace.svc.cluster-domain.example.

SRV records

Pods

A/AAAA Records

A/AAAA records are essential components in DNS server. It helps in mapping the domain names to IPV4 addres ( A records ) and IPv6 ( AAAA records ) addresses. In the context of kubernetes pods, these records plays a vital role in enabling the communication within the cluster and with external services. A records handles the IPv4 addresses and AAAA records handles the IPV6 addresses facilitates in ensuring a seamless connectivity for pods across different network environments. Proper management of A/AAAA records is vital for maintaining a robust networking and ensurin a smooth operation of kubernetes workloads.

Features of DNS services

The main features of DNS services are:

  • It can be used to map to a new IP address if the host's IP address is ever changed.
  • It is easier to remember when compared to the IP address.
  • It allows organizations to use a domain name hierarchy that is independent of any IP address provided.

DNS search Domain List Limits

The DNS search Domain List Limits refers to the maximum number of domains that be included in the search domain list configuration. This list will be used by DNS resolvers to expand the short, unqualified names into fully qualified domain names by appending each domain in the list in order. Exceeding this limit will raise the issues with the DNS resolvers in correctly searching the domain names.

Customizing DNS Service

Customization of DNS service in a network involves in configuring the DNS servers that will be suitable for specific needs. It may include in setting up the custom domain names, integrating with external DNS providers. By implementing DNS based security measures like DNS filtering facilitates with optimizing the performance of the DNS resolution. It facilitates with ensuring effiicient and secure resolutions of domain names across the network infrastructure.

Using CoreDNS for Service Discovery

CoreDNS is a powerful service discovery in kubernetes environment. By configuring CoreDNS as the DNS server in kubernetes we can efficiently establish the communication with services names resolving the IP challenges. In behind it maps the name of the services with respective their IP addresses. Using coreDNS we can simplify the networking and can it be abstracted within the kubernetes cluster. It will enhances the reliability and scalability of the infrastructure.

How to Configure DNS for A Cluster? A Step-By-Step Guide

The following are the steps for configuring DNS for a Kubernetes Cluster:

Step 1 : Choose DNS Solution

  • Select the DNS solution like CoreDNS or kube-DNS on considering its comptability with the kuberentes version and the specific reqirements.

Step 2: Install DNS Add-on

  • Deploy the chosen DNS add-on to the kubernetes cluster using appropriate deployment method such as YAML manifests or package managers like Helm.

Step 3: Customize Configuration

  • Try to modify the configuration file of the DNS server as per the requirements that suits for the cluster's requirements. It involves in adjusting the DNS policies, specifying the custom DNS providers or configuring additional plugins.

Step 4: Update CoreDNS/Corefile

  • If the using the DNS server is CoreDNS then update the corefile for defining the DNS zones, plugins, and upstream resolvers as per needed. Make ensure that the desired changes are reflected on DNS behaviour for the cluster.

Step 5: Verify Configuration

  • Now, test the configurations by resolving its domain names from within the cluster and ensuring that the DNS querires are properly routed to the DNS service.

Step 6: Monitor and Maintain

  • By regularly maintaining the DNS performances, we can resolve any issues promptly. Maintaince of DNS configurations by updating it respective to the cluster evolves is recommended practice.

Pod's DNS Policy

Pod's policy in kubernetes facilitates in ensuring how DNS resolution should be conducted within the cluster. By default pods inherit the DNS settings from the node. They are facilitating the resolution through node's DNS configuration. Alternatively administrators can specify the policies like ClusterFirst or Default provides the consistency across pods and optimizes the network reliability and communication efficiency.

Trouble Shooting Issues of Kubernetes DNS

The following are the some of the trouble shooting issues of kubernetes DNS:

  • Check Pod Network: Ensure that pod networking is correctly configured and functioning. DNS resolution relies on network connectivity between pods and DNS services.
  • Verify DNS Service: Confirm that the DNS service is running and healthy within the Kubernetes cluster. Check for any errors or warnings in the DNS service logs.
  • DNS Configurations: Review DNS configurations, such as ConfigMaps and CoreDNS settings, for any misconfigurations or conflicts. Ensure that DNS policies align with the cluster's requirements.
  • Pod Resolvability: Verify that pods can resolve DNS names both within and outside the cluster. Test DNS resolution from various pods to ensure consistency and correctness.

Best Practices of Kubernetes External DNS

The following are the best practices of Kubernetes External DNS:

  • Automate DNS Management: Utilize tools like ExternalDNS to automate the creation and management of DNS records for Kubernetes resources, ensuring consistency and reducing manual errors.
  • Secure DNS Configuration: Implement proper access controls and authentication mechanisms for interacting with the external DNS provider to prevent unauthorized changes and ensure the security of DNS configurations.
  • Use Consistent DNS Naming: Leverage Kubernetes DNS capabilities to provide consistent DNS names for Services and Pods, enabling seamless communication between components without relying on IP addresses.
  • Monitor DNS Health: Regularly monitor the health and performance of External DNS services to detect and address any issues promptly. Monitoring can include checking DNS resolution latency, error rates, and overall service availability.

P

pvklokesh
Improve
Article Tags :
  • Technical Scripter
  • Kubernetes
  • DevOps
  • Technical Scripter 2022
  • azure-kubernetes-services

Similar Reads

    DevOps Tutorial
    DevOps is a combination of two words: "Development" and "Operations." It’s a modern approach where software developers and software operations teams work together throughout the entire software life cycle.The goals of DevOps are:Faster and continuous software releases.Reduces manual errors through a
    7 min read

    Introduction

    What is DevOps ?
    DevOps is all about automating and streamlining the software development lifecycle so that code moves from development to production quickly, reliably, and securely.Here is how the DevOps model flow works:Stages of DevOps are:Build Stage1. Developers write and organize code, using version control to
    6 min read
    DevOps Lifecycle
    The DevOps lifecycle is a structured approach that integrates development (Dev) and operations (Ops) teams to streamline software delivery. It focuses on collaboration, automation, and continuous feedback across key phases planning, coding, building, testing, releasing, deploying, operating, and mon
    10 min read
    The Evolution of DevOps - 3 Major Trends for Future
    DevOps is a software engineering culture and practice that aims to unify software development and operations. It is an approach to software development that emphasizes collaboration, communication, and integration between software developers and IT operations. DevOps has come a long way since its in
    7 min read

    Version Control

    Version Control Systems
    A Version Control System (VCS) is a tool used in software development and collaborative projects to track and manage changes to source code, documents, and other files. Whether you are working alone or in a team, version control helps ensure your work is safe, organized, and easy to collaborate on.
    5 min read
    Merge Strategies in Git
    In Git, merging is the process of taking the changes from one branch and combining them into another. The merge command in Git will compare the two branches and merge them if there are no conflicts. If conflicts arise, Git will ask the user to resolve them before completing the merge.Merge keeps all
    4 min read
    Which Version Control System Should I Choose?
    While building a project, you need a system wherein you can track the modifications made. That's where Version Control System comes into the picture. It came into existence in 1972 at Bell Labs. The very first VCS made was SCCS (Source Code Control System) and was available only for UNIX. When any p
    5 min read

    Continuous Integration (CI) & Continuous Deployment (CD)

    What is CI/CD?
    CI/CD stands for Continuous Integration and Continuous Delivery/Deployment. With CI/CD, we automate the integration of code changes from multiple developers into a single codebase. It is a software development practice where the developers commit their work frequently to the central code repository
    7 min read
    Understanding Deployment Automation
    In this article we will discuss deployment automation, categories in Automated Deployment, how automation can be implemented in deployment, how it is assisting DevOps and finally the benefits and drawbacks of Deployment Automation. So, let's start exploring the topic in detail. Deployment Automation
    4 min read

    Containerization

    What is Docker?
    Have you ever wondered about the reason for creating Docker Containers in the market? Before Docker, there was a big issue faced by most developers whenever they created any code that code was working on that developer computer, but when they try to run that particular code on the server, that code
    12 min read
    What is Dockerfile Syntax?
    Pre-requsites: Docker,DockerfileA Dockerfile is a script that uses the Docker platform to generate containers automatically. It is essentially a text document that contains all the instructions that a user may use to create an image from the command line. The Docker platform is a Linux-based platfor
    5 min read
    Kubernetes - Introduction to Container Orchestration
    In this article, we will look into Container Orchestration in Kubernetes. But first, let's explore the trends that gave rise to containers, the need for container orchestration, and how that it has created the space for Kubernetes to rise to dominance and growth. The growth of technology into every
    4 min read

    Orchestration

    Kubernetes - Introduction to Container Orchestration
    In this article, we will look into Container Orchestration in Kubernetes. But first, let's explore the trends that gave rise to containers, the need for container orchestration, and how that it has created the space for Kubernetes to rise to dominance and growth. The growth of technology into every
    4 min read
    Fundamental Kubernetes Components and their role in Container Orchestration
    Kubernetes or K8s is an open-sourced container orchestration technology that is used for automating the manual processes of deploying, managing and scaling applications by the help of containers. Kubernetes was originally developed by engineers at Google and In 2015, it was donated to CNCF (Cloud Na
    12 min read
    How to Use AWS ECS to Deploy and Manage Containerized Applications?
    Containers can be deployed for applications on the AWS cloud platform. AWS has a special application for managing containerized applications. Elastic Container Service (ECS) serves this purpose. ECS is AWS's container orchestration tool which simplifies the management of containers. All the containe
    4 min read

    Infrastructure as Code (IaC)

    Infrastructure as Code (IaC)
    Infrastructure as Code (IaC) is a method of managing and provisioning IT infrastructure using code rather than manual configuration. It allows teams to automate the setup and management of their infrastructure, making it more efficient and consistent. This is particularly useful in the DevOps enviro
    6 min read
    Introduction to Terraform
    Many people wonder why we use Terraform when there are already so many Infrastructure as Code (IaC) tools out there. So, before learning Terraform, let’s understand why it was created.Terraform was made to solve some common problems with existing IaC tools. Some tools, like AWS CloudFormation, only
    15 min read
    What is AWS Cloudformation?
    Amazon Web Services(AWS) offers cloud formation as a service by which you can provision and manage complicated services offered by AWS by using the code. CloudFormation will help you to manage the infrastructure and the services in the form of a declarative way. Table of ContentIntroduction to AWS C
    14 min read

    Monitoring and Logging

    Working with Prometheus and Grafana Using Helm
    Pre-requisite: HELM Package Manager Helm is a package manager for Kubernetes that allows you to install, upgrade, and manage applications on your Kubernetes cluster. With Helm, you can define, install, and upgrade your application using a single configuration file, called a Chart. Charts are easy to
    5 min read
    Working with Monitoring and Logging Services
    Pre-requisite: Google Cloud Platform Monitoring and Logging services are essential tools for any organization that wants to ensure the reliability, performance, and security of its systems. These services allow organizations to collect and analyze data about the health and behavior of their systems,
    5 min read
    Microsoft Teams vs Slack
    Both Microsoft Teams and Slack are the communication channels used by organizations to communicate with their employees. Microsoft Teams was developed in 2017 whereas Slack was created in 2013. Microsoft Teams is mainly used in large organizations and is integrated with Office 365 enhancing the feat
    4 min read

    Security in DevOps

    What is DevSecOps: Overview and Tools
    DevSecOps methodology is an extension of the DevOps model that helps development teams to integrate security objectives very early into the lifecycle of the software development process, giving developers the team confidence to carry out several security tasks independently to protect code from adva
    10 min read
    DevOps Best Practices for Kubernetes
    DevOps is the hot topic in the market these days. DevOps is a vague term used for wide number of operations, most agreeable defination of DevOps would be that DevOps is an intersection of development and operations. Certain practices need to be followed during the application release process in DevO
    11 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Campus Training Program
  • Explore
  • POTD
  • Job-A-Thon
  • Community
  • Videos
  • Blogs
  • Nation Skill Up
  • Tutorials
  • Programming Languages
  • DSA
  • Web Technology
  • AI, ML & Data Science
  • DevOps
  • CS Core Subjects
  • Interview Preparation
  • GATE
  • Software and Tools
  • Courses
  • IBM Certification
  • DSA and Placements
  • Web Development
  • Programming Languages
  • DevOps & Cloud
  • GATE
  • Trending Technologies
  • Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
  • Preparation Corner
  • Aptitude
  • Puzzles
  • GfG 160
  • DSA 360
  • System Design
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences