Support Online
Skip to main content

What is Kubernetes DNS Service?

What will you learn in this guide?

This guide explains how the DNS service built into Kubernetes clusters works.
Service discovery, automatic DNS records and CoreDNS and kube-DNS differences are explained simply.

Technical Summary

Main Topic:
Kubernetes DNS service and service discovery mechanism.

Solved Problem:
Services can find each other by name even if Pod IPs change.

Path Followed:
DNS logic → Record formats → Short name resolution → CoreDNS architecture.


What Does Kubernetes DNS Service Provide?

Kubernetes automatically sets up a DNS service within the cluster.
This service allows applications to access each other by name.

Connections remain intact even if pods are deleted or moved.
Service names are always valid.


How Does Kubernetes DNS Work?

A service named kube-dns is created in the cluster.
This service listens for Kubernetes API events.

nameserver 10.32.0.10
search namespace.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
  • This structure determines the DNS resolution behavior within the Pod.

Auto-Generated Kubernetes DNS Records

  • Kubernetes generates specific DNS records for services and Pods.
Resource TypeDNS Record TypeDNS Record FormatExample
ServiceAservis.namespace.svc.cluster.localapi.dev.svc.cluster.local
PodAip-tireli.namespace.pod.cluster.local10-32-0-125.dev.pod.cluster.local
ServiceSRV_port._protokol.servis.namespace.svc.cluster.local_http._tcp.web.prod.svc.cluster.local
  • This structure makes service discovery DNS-based.

Using Short Hostname

  1. Thanks to the search fields in resolv.conf, the full DNS name is not required.

Same namespace:


baska-servis

Different namespace:


baska-servis.baska-namespace

  1. If targeting pod:

ip-tireli.namespace.pod
  • The .pod extension is not autocompleted.

Kubernetes DNS Applications

1. kube-dns (Legacy) Used prior to Kubernetes 1.11.

  • Consists of three containers:

kube-dns (SkyDNS): DNS resolution

dnsmasq: Caching

sidecar: Health and metrics

  • There were security and scale problems.

CoreDNS (Current System)

It is the default after Kubernetes 1.11.

  • Uses single process, single container architecture.

Advantages:

  1. Safer

  2. Faster

  3. Less resource consumption

  4. Performs real Pod verification

  5. Non-existent Pod IPs are no longer resolved.


Advanced DNS Configuration (dnsConfig)

  • Special DNS settings can be made on a per-pod basis.

apiVersion: v1
kind: Pod
metadata:
name: ozel-dns
namespace: genixnode-dev
spec:
containers:
- name: ornek
image: nginx
dnsPolicy: None
dnsConfig:
nameservers:
- 203.0.113.44
searches:
- ozel.dns.local
  • This build directly modifies the Pod's resolv.conf file.

Frequently Asked Questions (FAQ)

1. Why is service discovery critical? It hides IP changes and keeps microservice communication stable.

2. Why did CoreDNS replace kube-dns? For security, performance and scalability.

3. Does Kubernetes work without DNS? It works, but service communication becomes difficult.

4. When to use dnsConfig? When a dedicated or external DNS server is required.


Result

The Kubernetes DNS service is the foundation of intra-cluster communication. With CoreDNS, this structure is now safer and faster.

You can try this architecture immediately on the GenixNode Kubernetes infrastructure.