DNS in Kubernetes - Simplified Learning

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Home Tutorials Contact About Testimonials Search Service In this tutorial, we discuss about DNS resolution

 Us
Networking within the cluster between the different
DNS in components in the cluster such as PODs and
Introduction 
DNS in Kubernetes Kubernetes
services.
Core Concepts
 Core DNS in
In this tutorial, we are going to discuss about
 Kubernetes Kubernetes deploys a built-in DNS server by
Scheduling DNS in the Kubernetes cluster. If you are new to
 Ingress in default when you setup a cluster. If you setup
Monitoring DNS make sure you go through the prerequisite
Kubernetes Kubernetes manually, then you do it by yourself.
Application section on DNS where we discuss what DNS is,
Lifecycle what are the tools used for working with DNS We will see how that is done and how it is
Management 
such as host, NS Lookup and dig utility and the configured in the next tutorial. As far as this
Cluster
different types of DNS records like A, CNAME tutorial is concerned we will see how it helps
Maintenance 
etc. pods resolve other pods and services within the
Security 
cluster.
Kubernetes We also discussed how to setup our own DNS
Storage 
server using CoreDNS. In this tutorial we will
So we don’t really care about nodes. We focus
Networking  see what names are assigned to what objects,
purely on PODs and services within the cluster.
Switching and what our service DNS records, POD DNS
As long as our cluster networking is set up
Routing records, What are the different ways you can
correctly, following the best practices we
DNS reach one part from another.
discussed so far in this section, and all pods and
Network services can get their own IP address and can
In the next tutorial, we will see how Kubernetes
Namespaces
reach each other.
implements DNS in the cluster.
About Docker
Networking Let’s start with just two PODs and a service. I
So we have a 3 node Kubernetes cluster with
Container have a test POD with the IP set to 10.244.1.5.
some PODs and services deployed on them.
Network And I have a web POD with the IP set to
Interface Each node has a node name and IP address
10.244.2.5.
assigned to it.
Cluster
Networking
The node names and IP addresses of the
POD
cluster are probably registered in a DNS server
Networking
in your organization. Now how that is managed
CNI in
Kubernetes
who accesses them are not of concern in this
tutorial.
Looking at their IPs, you can guess that they are same namespace, the default namespace.

probably hosted on two different nodes. But that


You were able to simply reach the web-service
doesn’t matter, as far as DNS is concerned.
from the test pod using just the service name

We assume that all PODs and services can web service.

reach other using their IP addresses. To make


Let’s assume the web service was in a separate
the web server accessible to the test POD, we
namespace named apps. Then to refer to it from
create a service. We name it web service.
the default namespace. You would have to say

web-service.apps. The last name of the service


is now the name of the namespace.

So here web service is the name of the service


and apps is the name of the namespace.

$ curl http://web-service.apps
The service gets an IP 10.107.37.188.
Welcome to NGINX!
Whenever a service is created, the Kubernetes

DNS service creates a record for the service. It For each namespace, The DNS server creates

maps the service name to the IP address. a subdomain. All the services are grouped

together into another subdomain called SVC. So


So within the cluster any POD can now reach what was that about?
the service using its service name.

$ curl http://web-service
Welcome to NGINX!

Remember we discussed about name spaces

earlier. That everyone within the namespace Let’s take a closer look. web-service is the
address each other just with their first names name of the service and apps is the name of the
and to address anyone in another namespace namespace. For each namespace the DNS
you use their full names. server creates a subdomain with its name.

In this case since the test POD and the web All pods and services for a namespace are thus
POD and its associated service are all in the grouped together within a subdomain in the
name of the namespace. 244-1-5 and namespace set to default, type is

POD and root is cluster.local. This resolve to the


All the services are grouped together into
IP address of the POD.
another subdomain called svc. So you can
reach your application with the name web-
service.apps.svc.

Finally, all the services and PODs are grouped


 Prev Next 
together into a root domain for the cluster, which
is set to cluster.local by default. So you can
access the service using the URL web-

service.apps.svc.cluster.local.

So that’s how services are resolved within the


cluster. What about PODs? Records for PODs
are not created by default. But we can enable

that explicitly, We will see that in the next


tutorial. Once enabled, Records are created for
pods as well.

It does not use the POD name though. For each

POD Kubernetes generates a name by


replacing the dots in the IP address with
dashes. The namespace remains the same and

type is set to pod. The root domain is always


cluster.local.
Quick Links Tutorials Contact Info

Home Core Java Address: 2nd Floor,


$ curl http://10-244-2-5.apps.pod.clus Bachupally, Hyderabad,
About Us Kubernetes
Welcome to NGINX! Telangana 500090
Testimonials Docker

Privacy Policy SQL Website:

Similarly the test POD in the default waytoeasylearn.com


Our Mission Authors PL/SQL

namespace, gets a record in the DNS server, Suggestions Spring


Our mission is to deliver
with its IP converted to a dashed hostname 10- simply easy learning with Contact Us Hibernate
clear and in depth content
on a wide range of See More…
technical stuff.

Copyright © 2021 Waytoeasylearn.     

Automated page speed optimizations for fast site performance

You might also like