SlideShare a Scribd company logo
1 of 53
Service Registration
and Discovery with
Michael Richardson @m_richo
$whoami
• Michael Richardson
• Engineer @ odecee
• @m_richo
• http://www.mricho.com
• I like DevOps*
• Docker has grown on me in the last 6 months
* My definition of DevOps is likely different from yours
Agenda
• What is Service Registration & Discovery?
• Consul
– tool to store information about services
• Registrator
– tool to register Docker services
• Consul-template
– tool to query registered services and apply
configuration.
• Demo
Service Registration and Discovery
What is it?
Service Registration and Discovery
What is it?
“Service Discovery Protocols (SDP) are
network protocols which allow automatic
detection of devices and services offered by
these devices on a computer network.”
Source: http://en.wikipedia.org/wiki/Service_discovery
Service Registration and Discovery
What is it?
Basically… how do clients determine the
network details of desired services.
Service Registration and Discovery
Existing techniques?
• DNS (perhaps Dynamic DNS)
• Puppet exported resources
• Chef Search
• many others
Service Registration and Discovery
These approaches can struggle in a docker world
Image source: http://www.ideachampions.com/weblogs/archives/2011/09/the_top_100_lam.shtml
Service Registration and Discovery
These approaches can struggle in a docker world
• DNS
Service Registration and Discovery
These approaches can struggle in a docker world
• DNS
– TTL and caching can often be an issue
Service Registration and Discovery
These approaches can struggle in a docker world
• DNS
– TTL and caching can often be an issue
– Just try doing interesting DNS things in an enterprise. 
Service Registration and Discovery
These approaches can struggle in a docker world
• DNS
– TTL and caching can often be an issue
– Just try doing interesting DNS things in an enterprise. 
– Containers don’t have a unique IP address. Simple IP
based DNS isn’t sufficient. *
* SRV records can be an option
Service Registration and Discovery
These approaches can struggle in a docker world
• DNS
– TTL and caching can often be an issue
– Just try doing interesting DNS things in an enterprise. 
– Containers don’t have a unique IP address. Simple IP
based DNS isn’t sufficient. *
• Config Management agents
* SRV records can be an option
Service Registration and Discovery
These approaches can struggle in a docker world
• DNS
– TTL and caching can often be an issue
– Just try doing interesting DNS things in an enterprise. 
– Containers don’t have a unique IP address. Simple IP
based DNS isn’t sufficient. *
• Config Management agents
– I’m resistant to running agents within a container.
– CM agent run intervals are probably not frequent enough.
* SRV records can be an option
Service Registration and Discovery
Are there any new tools for Services Discovery?
Service Registration and Discovery
• Zookeeper
• Doozer
• Etcd
• SmartStack
• Eureka
• SkyDNS
• consul
Yep. Quite a few…
Service Registration and Discovery
• Zookeeper
• Doozer
• Etcd
• SmartStack
• Eureka
• SkyDNS
• consul
Yep. Quite a few…
Consul
“Service Discovery and
configuration made easy.
Distributed, highly available
and datacenter aware.”
Consul
Key features…
• Service Discovery
• Health Checking
• Key/Value Storage
• Multi Datacenter
Consul
Key features…
• Service Discovery
• Health Checking
• Key/Value Storage
• Multi Datacenter
Consul - example
Consul - example
Consul service definition for nginx web server
Consul + Docker
How should I use consul with docker?
Consul + Docker
How should I use consul with docker?
Option 1: run 1 Consul client agent in every
container to register its service
Or
Option 2: run 1 consul client agent per Docker
host that is responsible for all the containers on it
Consul + Docker
How should I use consul with docker?
Option 1: run 1 Consul client agent in every
container to register its service
Or
Option 2: run 1 consul client agent per Docker
host that is responsible for all the containers on it
Option 2 makes more sense to me
Consul + Docker
Docker host running some containers
Consul + Docker
Add a Consul Agent as a container
Consul + Docker
Which talks to the consul cluster
Consul + Docker
Next Question?
How do we register the
container services with the
consul agent?
Consul + Docker
Question?
How do we register the
container services with the
consul agent?
Use
Registrator!
Registrator
• https://github.com/gliderlabs/registrator
• Automatically registers/deregisters services for docker
containers
• Supported Registry services include consul, etcd and SkyDNS
2
• Reads events from Docker Socket (/var/run/docker.sock)
• Run on each Docker host*
* Ideally run it as a container
Registrator
Installation instructions
Registrator
Installation instructions
Registrator
Starting Registrator
Registrator
Starting Registrator
Registrator
Starting Registrator
pass docker socket to container
Specify service registry endpoint (eg consul)
How does it work
How does it work
• Start containers for consul
and registrator
How does it work
• Start containers for consul
and registrator
• Registrator watches for
container start and die
events
How does it work
• Start containers for consul
and registrator
• Registrator watches for
container start and die
events
• Start new container
How does it work
• Start containers for consul
and registrator
• Registrator watches for
container start and die
events
• Start new container
• Registrator informs consul
of service A’s metadata
(IP/port/name/tag)
Service information is now in
Consul. How can we access it?
• Consul’s HTTP API
• Consul’s DNS API
• Consul-template (via HTTP
API)
Consul Access
• Consul’s HTTP API
• Consul’s DNS API
• Consul-template (via HTTP
API)
Consul Access
Consul-template
What does it do?
Consul-template
What does it do?
• Populate template files with data from
Consul.
• Optionally run commands when consul
data changes.
Consul-template – example 1
Consul-template – example 1
Consul-template – example 2
Consul-template – example 2
Time for a Demo
links
• https://consul.io/
• https://github.com/hashicorp/consul-template
• https://github.com/gliderlabs/registrator
• https://github.com/CiscoCloud/microservices-
infrastructure
• http://jasonwilder.com/blog/2014/02/04/service-
discovery-in-the-cloud/
Questions?
Thanks for listening
@m_richo

More Related Content

What's hot

What's hot (20)

Getting Started with Consul
Getting Started with ConsulGetting Started with Consul
Getting Started with Consul
 
Introduction to service discovery and self-organizing cluster orchestration. ...
Introduction to service discovery and self-organizing cluster orchestration. ...Introduction to service discovery and self-organizing cluster orchestration. ...
Introduction to service discovery and self-organizing cluster orchestration. ...
 
Consul First Steps
Consul First StepsConsul First Steps
Consul First Steps
 
Consul and Complex Networks
Consul and Complex NetworksConsul and Complex Networks
Consul and Complex Networks
 
Infrastructure development using Consul
Infrastructure development using ConsulInfrastructure development using Consul
Infrastructure development using Consul
 
Service discovery in mesos miguel, Angel Guillen
Service discovery in mesos miguel, Angel GuillenService discovery in mesos miguel, Angel Guillen
Service discovery in mesos miguel, Angel Guillen
 
Openstack Overview
Openstack OverviewOpenstack Overview
Openstack Overview
 
Orchestrating Least Privilege by Diogo Monica
Orchestrating Least Privilege by Diogo Monica Orchestrating Least Privilege by Diogo Monica
Orchestrating Least Privilege by Diogo Monica
 
Consul in 5 minutes
Consul in 5 minutesConsul in 5 minutes
Consul in 5 minutes
 
Kubernetes intro public - kubernetes user group 4-21-2015
Kubernetes intro   public - kubernetes user group 4-21-2015Kubernetes intro   public - kubernetes user group 4-21-2015
Kubernetes intro public - kubernetes user group 4-21-2015
 
Service discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring CloudService discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring Cloud
 
Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and Kubernetes
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST Microservice
 
Sf bay area Kubernetes meetup dec8 2016 - deployment models
Sf bay area Kubernetes meetup dec8 2016 - deployment modelsSf bay area Kubernetes meetup dec8 2016 - deployment models
Sf bay area Kubernetes meetup dec8 2016 - deployment models
 
Heart of the SwarmKit: Store, Topology & Object Model
Heart of the SwarmKit: Store, Topology & Object ModelHeart of the SwarmKit: Store, Topology & Object Model
Heart of the SwarmKit: Store, Topology & Object Model
 
Real-Time Data Processing Pipeline & Visualization with Docker, Spark, Kafka ...
Real-Time Data Processing Pipeline & Visualization with Docker, Spark, Kafka ...Real-Time Data Processing Pipeline & Visualization with Docker, Spark, Kafka ...
Real-Time Data Processing Pipeline & Visualization with Docker, Spark, Kafka ...
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
Container Orchestration with Docker Swarm and Kubernetes
Container Orchestration with Docker Swarm and KubernetesContainer Orchestration with Docker Swarm and Kubernetes
Container Orchestration with Docker Swarm and Kubernetes
 
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overview
 

Similar to Docker Service Registration and Discovery

Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
dotCloud
 

Similar to Docker Service Registration and Discovery (20)

ApacheCon Core: Service Discovery in OSGi: Beyond the JVM using Docker and Co...
ApacheCon Core: Service Discovery in OSGi: Beyond the JVM using Docker and Co...ApacheCon Core: Service Discovery in OSGi: Beyond the JVM using Docker and Co...
ApacheCon Core: Service Discovery in OSGi: Beyond the JVM using Docker and Co...
 
DevNexus 2015: Kubernetes & Container Engine
DevNexus 2015: Kubernetes & Container EngineDevNexus 2015: Kubernetes & Container Engine
DevNexus 2015: Kubernetes & Container Engine
 
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
JavaCro'15 - Service Discovery in OSGi Beyond the JVM using Docker and Consul...
 
Service Discovery in OSGi: Beyond the JVM using Docker and Consul
Service Discovery in OSGi: Beyond the JVM using Docker and ConsulService Discovery in OSGi: Beyond the JVM using Docker and Consul
Service Discovery in OSGi: Beyond the JVM using Docker and Consul
 
Greenfields tech decisions
Greenfields tech decisionsGreenfields tech decisions
Greenfields tech decisions
 
Introduction to Microservices with Docker and Kubernetes
Introduction to Microservices with Docker and KubernetesIntroduction to Microservices with Docker and Kubernetes
Introduction to Microservices with Docker and Kubernetes
 
Docker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsDocker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and tools
 
Microservices
MicroservicesMicroservices
Microservices
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
 
99cloud Docker Training module 2
99cloud Docker Training module 299cloud Docker Training module 2
99cloud Docker Training module 2
 
Sysdig Monitorama Slides
Sysdig Monitorama SlidesSysdig Monitorama Slides
Sysdig Monitorama Slides
 
Consuming Cinder from Docker
Consuming Cinder from DockerConsuming Cinder from Docker
Consuming Cinder from Docker
 
Kuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails AppsKuby, ActiveDeployment for Rails Apps
Kuby, ActiveDeployment for Rails Apps
 
Pablo Chico de Guzman | Introducción a Docker y Kubernetes | Codemotion Madri...
Pablo Chico de Guzman | Introducción a Docker y Kubernetes | Codemotion Madri...Pablo Chico de Guzman | Introducción a Docker y Kubernetes | Codemotion Madri...
Pablo Chico de Guzman | Introducción a Docker y Kubernetes | Codemotion Madri...
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
OpenStack Summit
OpenStack SummitOpenStack Summit
OpenStack Summit
 
Containers, microservices and serverless for realists
Containers, microservices and serverless for realistsContainers, microservices and serverless for realists
Containers, microservices and serverless for realists
 
Introduction to rocket and its usability
Introduction to rocket and its usabilityIntroduction to rocket and its usability
Introduction to rocket and its usability
 

More from m_richardson

Open Source Monitoring Tools
Open Source Monitoring ToolsOpen Source Monitoring Tools
Open Source Monitoring Tools
m_richardson
 

More from m_richardson (9)

Persistence in the cloud with bosh
Persistence in the cloud with boshPersistence in the cloud with bosh
Persistence in the cloud with bosh
 
bootstrapping containers with confd
bootstrapping containers with confdbootstrapping containers with confd
bootstrapping containers with confd
 
Puppetcamp Melbourne - puppetdb
Puppetcamp Melbourne - puppetdbPuppetcamp Melbourne - puppetdb
Puppetcamp Melbourne - puppetdb
 
Node collaboration - sharing information between your systems
Node collaboration - sharing information between your systemsNode collaboration - sharing information between your systems
Node collaboration - sharing information between your systems
 
Node collaboration - Exported Resources and PuppetDB
Node collaboration - Exported Resources and PuppetDBNode collaboration - Exported Resources and PuppetDB
Node collaboration - Exported Resources and PuppetDB
 
Serverspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collideServerspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collide
 
System Availability Talk
System Availability TalkSystem Availability Talk
System Availability Talk
 
Chef - managing yours servers with Code
Chef - managing yours servers with CodeChef - managing yours servers with Code
Chef - managing yours servers with Code
 
Open Source Monitoring Tools
Open Source Monitoring ToolsOpen Source Monitoring Tools
Open Source Monitoring Tools
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Docker Service Registration and Discovery

Editor's Notes

  1. What is the IP and port of a service
  2. Smartstack from Airbnb Eureka from Netflix
  3. Smartstack from Airbnb Eureka from Netflix
  4. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  5. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  6. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  7. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  8. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  9. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  10. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  11. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  12. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader
  13. Consul cluster is distributed, highly available. Consul agent talks to 1 or more consul servers. Data is stored and replicated between consul servers Consul servers elect a leader