Service Discovery w/
Consul
Ali Demirsoy @kloia
“Digital Transition Accelerator“
33 Queen St, London EC4R
1AP, United Kingdom
blog.kloia.com
@kloia_com
AND Binası 10-12, 34752
Kozyatagi/Istanbul, Turkey
kloia.com
Cloud
DevOps
Test Automation
Microservices
• History
• Microservices & Service Discovery
• Consul
• Demo
Agenda
• Physical Servers & DNS
History
• Load balancer & Many Physical Servers
History
• Virtualization
• Web/App/Db layers
• Create/Destroy in minutes
• Scale up/down dynamically
• Manually configure?
History
• Containerization & Microservices
• Create/Destroy in ms
• Hundreds of Services
• Impossible to manage manually
History
• Monolith: Hard to maintain,
troubleshoot, evolve
• Microservice: Independent,
scalable, simple
Monolith to Microservices
Challenges:
o Monitoring
o Logging
o Version and Configuration Management
o Distributed Transactions
o Service Discovery
o …
Microservices not a free lunch
• Start services in any order
• Destroy services with confidence
• Restart servers safely
• Reconfigure services easily
Practical Goals
• Can find services
• Can avoid and handle unhealthy services
• Can be configured externally
Robust Systems
• Database of available service instances
• Two approaches:
o Self Registration
o Third Party Registration
• Heartbeat vs Polling
Service Registry
• Straightforward
• Smart clients
• Clients and Service Registry
coupled
Client Side Discovery
• Dumb clients
• Load balancer: SPOF
Server Side Discovery
• High Available, Distributed K/V store
• Service Discovery. DNS and HTTP Interface
• Flexible Health Checking
• Multi Datacenter
• Open Source
Consul
Architecture
• Leader Election
• Replicated Logs
• Quorum
• http://thesecretlivesofdata.com/raft
Raft Consensus Algorithm
• Rest  /v1/catalog/services
• DNS  dig @127.0.0.1 -p 8600 testConsulApp.service.consul SRV
• CLI  consul kv get myAppConfig
• Web UI 
Consul Interface
• Register a service: PUT /agent/service/register
• List services : GET /agent/services
• Maintenance mode: /agent/service/maintenance/:service_id
• Health: GET /health/node/:node
• K/V store: /kv/:key
Consul Rest API
Defining Watches
Defining Locks
• host1 $ consul lock service/redis/lock redis-server
• host2 $ consul lock service/redis/lock redis-server
• Active/Passive Architecture
Defining Locks
• Zookeeper
• Etcd
• Netflix Eureka
• Marathon-lb
Other Tools
Demo
Istanbul HashiCorp Meetup
https://www.meetup.com/Istanbul-
HashiCorp-Meetup/
20, September 2018
Radisson, Sisli
http://devopsdays.istanbul

Service Discovery with Consul

Editor's Notes

  • #3 Kloia introduction
  • #6 Manual configuration of load balancer, it didn’t change much because it was physical. So it was manageable.
  • #7 We don’t know where our servers are, not even physically.
  • #8 Lightweight, faster to start stop, efficient.
  • #9 Divide and Conquer
  • #10 Reconfigure: feature on/off, maintenance
  • #11 Reconfigure: feature on/off, maintenance
  • #12 Avoid unhealthy: Load birinde cok fazla olabilir, dead degildir ama hasta olabilir. Oluyse de gracefully handle et.
  • #16 dynamic configuration, feature flagging, coordination, leader election
  • #19 DNS: legacy friendly, no application required
  • #26 Kloia introduction