SlideShare a Scribd company logo
Presented By: Shubhrank Rastogi & Azmat Hasan
Service Discovery
in Kubernetes
Agenda
01
● A little about K8
● Service Overview
○ Why do we need them?
○ What is a service?
○ Types of services
● Communication is important - Service Discovery
○ The Scenario
○ Ways to discover services
● Demo
Quick Overview - About K8
● Kubernetes (commonly stylized as k8) is an open-source container-
orchestration engine for automating application deployment, scaling,
and management
● It provides features like deployment, scaling, load balancing, logging,
and monitoring
● Designed by Google, and is now maintained by the Cloud Native
Computing Foundation (CNCF)
● Master-Slave Architecture
● Kubernetes Objects
Why do we need services?
● How does this frontend application is exposed to
outside world?
● How does frontend application is connected to
backend ?
● How do we resolve Pod IP changes, when they die?
What is a service?
● A Service in Kubernetes is an object, similar to a Pod
● A service can be defined as a logical set of pods
● It acts as the intermediary for Pods to talk to each other
● Selectors are used for accessing all the Pods that match a specific
Label
● Each Service exposes one of more ports and targetPorts
● The targetPort is mapped to the port exposed by matching Pods
Important Features provided by service:
● Load Balancing
● Service Discovery
Types of services:
Node Port:
● Exposes the service on each Node’s IP at a static port
(the NodePort)
● You’ll be able to contact the NodePort service, from
outside the cluster, by requesting
<NodeIP>:<NodePort>
How does this frontend application is exposed to outside world?
Cluster IP
● Exposes the service on a
cluster-internal IP
● Choosing this value makes
the service only reachable
from within the cluster
● This is the default
ServiceType
How does frontend application is connected to backend
Load Balancer
● Exposes the service externally using a cloud
provider’s load balancer
● NodePort and ClusterIP services, to which the
external load balancer will route, are
automatically created
● It will give you a single IP address that will
forward all traffic to your service
The Scenario
Components of Service Discovery
● Kube-DNS
○ It is also a DNS server which was default cluster DNS, prior to K8s version 1.11
○ Several containers are used within a single pod: kubedns, dnsmasq, and sidecar.
■kubedns container watches the Kubernetes API and serves DNS records
■dnsmasq provides caching and stub domain support
■sidecar provides metrics and health checks
● CoreDNS
○ It is a flexible, extensible DNS server that can serve as the Kubernetes cluster DNS
○ Maintained by CNCF
○ Written in GOLang
○ Introduce in K8s version 1.11 as a replacement for KubeDNS
Service Discovery
● For internal service discovery, Kubernetes provides two options:
○ Environment variable: When a new Pod is created, environment variables from older services can be imported.
This allows services to talk to each other.
○ DNS: Every service registers to the DNS server, using this, new services can find and talk to other services.
Kubernetes provides the kube-DNS and CoreDNS server for this as an add-on resource.
● For external service discovery, Kubernetes provides two options:
○ NodePort: Kubernetes exposes the service through special ports (30000-32767) of the node IP address.
○ Loadbalancer: Kubernetes interacts with the cloud provider to create a load balancer that redirects the traffic to
the Pods.
Service Discovery - DNS
● Kubernetes has a coreDNS addon that exposes the service’s name as a DNS entry
● The DNS server watches Kubernetes API for new Services
● The DNS server creates a set of DNS records for each Service
○ service.namespace.svc.cluster.local
● Similarly it also creates a set of DNS records for each pod in the cluster
○ 10.32.0.125.namespace.pod.cluster.local
● Services can be resolved by the name within the same namespace
○ phpmyadmin.default.svc.cluster.local
● Pods in other namespaces can access the Service by adding the
○ namespace to the DNS path
■phpmyadmin.my-namespace.svc.cluster.local
Service Discovery - Environment Variables
● Kubernetes injects environment variables for each service and each port exposed by the service
● Major limitation of this approach is that the service should always be created before then any pods
● Containers can use the environment variable to talk to the service endpoint
● For example, if we are exposing a nginx-service, we can locate it using the
NGINX_SERVICE_SERVICE_HOST and NGINX_SERVICE_SERVICE_PORT variables
● The easiest way to find out what environment variables are exposed are to exec the env command within
a pod:
REFERENCES:
● https://kubernetes.io/docs/concepts/
● https://www.youtube.com/user/srinathrchalla1/
● https://www.digitalocean.com/community/tutorials/an-introduction-to-the-kubernetes-dns-service
● https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/
● http://kubernetesbyexample.com/sd/
● https://fredjean.net/kubernetes-discovery/
Thank You :)
ANY Questions?

More Related Content

PPTX
Kubernetes presentation
PDF
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
PDF
Devops - Microservice and Kubernetes
PDF
Kubernetes Architecture - beyond a black box - Part 1
PDF
Kubernetes a comprehensive overview
PDF
NGINX Ingress Controller for Kubernetes
PDF
Autoscaling Kubernetes
PDF
(Draft) Kubernetes - A Comprehensive Overview
Kubernetes presentation
Kubernetes Networking | Kubernetes Services, Pods & Ingress Networks | Kubern...
Devops - Microservice and Kubernetes
Kubernetes Architecture - beyond a black box - Part 1
Kubernetes a comprehensive overview
NGINX Ingress Controller for Kubernetes
Autoscaling Kubernetes
(Draft) Kubernetes - A Comprehensive Overview

What's hot (20)

PPTX
Kubernetes Introduction
PDF
Kubernetes 101
PPTX
Introduction to kubernetes
PDF
Deep dive into Kubernetes Networking
PDF
Introduction to kubernetes
PDF
Kubernetes Introduction
PDF
Introduction to Kubernetes Workshop
PDF
Designing a complete ci cd pipeline using argo events, workflow and cd products
PDF
Introduction to Kubernetes and Google Container Engine (GKE)
PDF
Kubernetes Basics
PDF
Kubernetes - A Comprehensive Overview
ODP
Kubernetes Architecture
PPTX
Kubernetes 101 for Beginners
PPTX
Introduction to Kubernetes
PDF
Open shift 4 infra deep dive
PDF
Hands-On Introduction to Kubernetes at LISA17
PDF
Kubernetes - introduction
PDF
Gitops: the kubernetes way
PDF
Kubernetes Networking with Cilium - Deep Dive
PPTX
Kubernetes Basics
Kubernetes Introduction
Kubernetes 101
Introduction to kubernetes
Deep dive into Kubernetes Networking
Introduction to kubernetes
Kubernetes Introduction
Introduction to Kubernetes Workshop
Designing a complete ci cd pipeline using argo events, workflow and cd products
Introduction to Kubernetes and Google Container Engine (GKE)
Kubernetes Basics
Kubernetes - A Comprehensive Overview
Kubernetes Architecture
Kubernetes 101 for Beginners
Introduction to Kubernetes
Open shift 4 infra deep dive
Hands-On Introduction to Kubernetes at LISA17
Kubernetes - introduction
Gitops: the kubernetes way
Kubernetes Networking with Cilium - Deep Dive
Kubernetes Basics
Ad

Similar to Service Discovery In Kubernetes (20)

PDF
Kubernetes Webinar Series - Understanding Service Discovery
PPTX
Kubernetes #1 intro
PDF
Services in kubernetes-KnolX .pdf
PDF
Getting started with kubernetes
PDF
Micro-services meetup
PPTX
Introduction to Kubernetes
PPTX
KubernetSADASDASDASDSADASDASDASDASDes.pptx
PDF
Kubernetes Networking 101 kubecon EU 2022
PPTX
Kubernetes
PDF
Scaling Microservices with Kubernetes
PPTX
A brief study on Kubernetes and its components
PPTX
Container Orchestration using kubernetes
PDF
Kubernetes Basics - ICP Workshop Batch II
PPTX
KubernetesPPT.pptx
PPTX
K8s in 3h - Kubernetes Fundamentals Training
PPTX
Containers and Kubernetes -Notes Leo
PDF
Scaling docker with kubernetes
PPTX
Kubernetes Introduction
PDF
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
PDF
Builders' Day- Mastering Kubernetes on AWS
Kubernetes Webinar Series - Understanding Service Discovery
Kubernetes #1 intro
Services in kubernetes-KnolX .pdf
Getting started with kubernetes
Micro-services meetup
Introduction to Kubernetes
KubernetSADASDASDASDSADASDASDASDASDes.pptx
Kubernetes Networking 101 kubecon EU 2022
Kubernetes
Scaling Microservices with Kubernetes
A brief study on Kubernetes and its components
Container Orchestration using kubernetes
Kubernetes Basics - ICP Workshop Batch II
KubernetesPPT.pptx
K8s in 3h - Kubernetes Fundamentals Training
Containers and Kubernetes -Notes Leo
Scaling docker with kubernetes
Kubernetes Introduction
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Builders' Day- Mastering Kubernetes on AWS
Ad

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
PPTX
Self-Healing Test Automation Framework - Healenium
PPTX
Kanban Metrics Presentation (Project Management)
PPTX
Java 17 features and implementation.pptx
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
PPTX
GraalVM - A Step Ahead of JVM Presentation
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
DAPR - Distributed Application Runtime Presentation
PPTX
Introduction to Azure Virtual WAN Presentation
PPTX
Introduction to Argo Rollouts Presentation
PPTX
Intro to Azure Container App Presentation
PPTX
Insights Unveiled Test Reporting and Observability Excellence
PPTX
Introduction to Splunk Presentation (DevOps)
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
PPTX
AWS: Messaging Services in AWS Presentation
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
PPTX
Managing State & HTTP Requests In Ionic.
Angular Hydration Presentation (FrontEnd)
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Self-Healing Test Automation Framework - Healenium
Kanban Metrics Presentation (Project Management)
Java 17 features and implementation.pptx
Chaos Mesh Introducing Chaos in Kubernetes
GraalVM - A Step Ahead of JVM Presentation
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
DAPR - Distributed Application Runtime Presentation
Introduction to Azure Virtual WAN Presentation
Introduction to Argo Rollouts Presentation
Intro to Azure Container App Presentation
Insights Unveiled Test Reporting and Observability Excellence
Introduction to Splunk Presentation (DevOps)
Code Camp - Data Profiling and Quality Analysis Framework
AWS: Messaging Services in AWS Presentation
Amazon Cognito: A Primer on Authentication and Authorization
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Managing State & HTTP Requests In Ionic.

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
System and Network Administration Chapter 2
PDF
Complete React Javascript Course Syllabus.pdf
PPTX
Essential Infomation Tech presentation.pptx
DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
PTS Company Brochure 2025 (1).pdf.......
PPT
Introduction Database Management System for Course Database
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Introduction to Artificial Intelligence
PDF
AI in Product Development-omnex systems
PPTX
history of c programming in notes for students .pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
Understanding Forklifts - TECH EHS Solution
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
System and Network Administration Chapter 2
Complete React Javascript Course Syllabus.pdf
Essential Infomation Tech presentation.pptx
The Five Best AI Cover Tools in 2025.docx
PTS Company Brochure 2025 (1).pdf.......
Introduction Database Management System for Course Database
Online Work Permit System for Fast Permit Processing
Introduction to Artificial Intelligence
AI in Product Development-omnex systems
history of c programming in notes for students .pptx
ai tools demonstartion for schools and inter college
How to Migrate SBCGlobal Email to Yahoo Easily
ISO 45001 Occupational Health and Safety Management System
Adobe Illustrator 28.6 Crack My Vision of Vector Design
How to Choose the Right IT Partner for Your Business in Malaysia

Service Discovery In Kubernetes

  • 1. Presented By: Shubhrank Rastogi & Azmat Hasan Service Discovery in Kubernetes
  • 2. Agenda 01 ● A little about K8 ● Service Overview ○ Why do we need them? ○ What is a service? ○ Types of services ● Communication is important - Service Discovery ○ The Scenario ○ Ways to discover services ● Demo
  • 3. Quick Overview - About K8 ● Kubernetes (commonly stylized as k8) is an open-source container- orchestration engine for automating application deployment, scaling, and management ● It provides features like deployment, scaling, load balancing, logging, and monitoring ● Designed by Google, and is now maintained by the Cloud Native Computing Foundation (CNCF) ● Master-Slave Architecture ● Kubernetes Objects
  • 4. Why do we need services? ● How does this frontend application is exposed to outside world? ● How does frontend application is connected to backend ? ● How do we resolve Pod IP changes, when they die?
  • 5. What is a service? ● A Service in Kubernetes is an object, similar to a Pod ● A service can be defined as a logical set of pods ● It acts as the intermediary for Pods to talk to each other ● Selectors are used for accessing all the Pods that match a specific Label ● Each Service exposes one of more ports and targetPorts ● The targetPort is mapped to the port exposed by matching Pods Important Features provided by service: ● Load Balancing ● Service Discovery
  • 7. Node Port: ● Exposes the service on each Node’s IP at a static port (the NodePort) ● You’ll be able to contact the NodePort service, from outside the cluster, by requesting <NodeIP>:<NodePort> How does this frontend application is exposed to outside world?
  • 8. Cluster IP ● Exposes the service on a cluster-internal IP ● Choosing this value makes the service only reachable from within the cluster ● This is the default ServiceType How does frontend application is connected to backend
  • 9. Load Balancer ● Exposes the service externally using a cloud provider’s load balancer ● NodePort and ClusterIP services, to which the external load balancer will route, are automatically created ● It will give you a single IP address that will forward all traffic to your service
  • 11. Components of Service Discovery ● Kube-DNS ○ It is also a DNS server which was default cluster DNS, prior to K8s version 1.11 ○ Several containers are used within a single pod: kubedns, dnsmasq, and sidecar. ■kubedns container watches the Kubernetes API and serves DNS records ■dnsmasq provides caching and stub domain support ■sidecar provides metrics and health checks ● CoreDNS ○ It is a flexible, extensible DNS server that can serve as the Kubernetes cluster DNS ○ Maintained by CNCF ○ Written in GOLang ○ Introduce in K8s version 1.11 as a replacement for KubeDNS
  • 12. Service Discovery ● For internal service discovery, Kubernetes provides two options: ○ Environment variable: When a new Pod is created, environment variables from older services can be imported. This allows services to talk to each other. ○ DNS: Every service registers to the DNS server, using this, new services can find and talk to other services. Kubernetes provides the kube-DNS and CoreDNS server for this as an add-on resource. ● For external service discovery, Kubernetes provides two options: ○ NodePort: Kubernetes exposes the service through special ports (30000-32767) of the node IP address. ○ Loadbalancer: Kubernetes interacts with the cloud provider to create a load balancer that redirects the traffic to the Pods.
  • 13. Service Discovery - DNS ● Kubernetes has a coreDNS addon that exposes the service’s name as a DNS entry ● The DNS server watches Kubernetes API for new Services ● The DNS server creates a set of DNS records for each Service ○ service.namespace.svc.cluster.local ● Similarly it also creates a set of DNS records for each pod in the cluster ○ 10.32.0.125.namespace.pod.cluster.local ● Services can be resolved by the name within the same namespace ○ phpmyadmin.default.svc.cluster.local ● Pods in other namespaces can access the Service by adding the ○ namespace to the DNS path ■phpmyadmin.my-namespace.svc.cluster.local
  • 14. Service Discovery - Environment Variables ● Kubernetes injects environment variables for each service and each port exposed by the service ● Major limitation of this approach is that the service should always be created before then any pods ● Containers can use the environment variable to talk to the service endpoint ● For example, if we are exposing a nginx-service, we can locate it using the NGINX_SERVICE_SERVICE_HOST and NGINX_SERVICE_SERVICE_PORT variables ● The easiest way to find out what environment variables are exposed are to exec the env command within a pod:
  • 15. REFERENCES: ● https://kubernetes.io/docs/concepts/ ● https://www.youtube.com/user/srinathrchalla1/ ● https://www.digitalocean.com/community/tutorials/an-introduction-to-the-kubernetes-dns-service ● https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/ ● http://kubernetesbyexample.com/sd/ ● https://fredjean.net/kubernetes-discovery/
  • 16. Thank You :) ANY Questions?