SlideShare ist ein Scribd-Unternehmen logo
1 von 86
Downloaden Sie, um offline zu lesen
To the cloud and beyond...
Doner Hub
The best doner marketplace
Doner Hub
Marketplace for doners
Ratings and reviews
Search by dietary preferences
Social network
Old-school monolith
Internet DBShop app
Old-school monolith with LB
Internet DB
Shop app
Shop appLoadbalancer
Monolithic architecture problems
● Large codebase
● Hard to scale
● Redeploy the entire application on each update
● Bug in any module can potentially bring down the entire process
● Has a barrier to adopting new technologies
● Continuous deployment is difficult
NEED
TO SCALE!!!
Service oriented architecture
Internet DBShop app
Loadbalancer
Orders
Search
Reviews
Service oriented architecture
Internet
DB
Shop app
Loadbalancer
Orders
Search
Reviews
DB
DB
success?
Service dependency graph
Available
Unstable
Down
SOA
architecture
support
SOA architecture problems
● Adds a complexity to the project
● Partitioned database architecture
● Difficult to implement changes that span multiple services
● Complex testing process
● Service discovery
● Configuration
● Deployment
SOA architecture problems
● Adds a complexity to the project
● Partitioned database architecture
● Difficult to implement changes that span multiple services
● Complex testing process
● Service discovery
● Configuration
● Deployment
Problem: Load Balancing
Shop app
Node 1
Node 2
Node 3
Orders service
Ensure that requests are balanced across instances
Solution: Load Balancer for internal services
Shop app
Node 1
Node 2
Node 3
Orders service
Loadbalancer
Problem: health checking
Shop app
Node 1
Node 2
Node 3
Services
Loadbalancer
Route traffic only to alive instances
Problem: add new nodes
Shop app
Node 1
Node 2
Node 3
Services
Loadbalancer
Dynamically add new nodes Node 4
Problems with internal load balancers
Yet another infrastructure to run and maintain
Load grows with the numbers of service instances
Single point of failure
LB configuration management and reload
Require health probing
Solution: Consul
Consul is a distributed service mesh
to connect, secure, and configure
services across any runtime platform
and public or private cloud
Consul features
Service discovery
Distributed locks and semaphores
Distributed key-value storage
Cross DC sync
Consul service registration
Register services (IP + port + checks) via config file or HTTP
Discover services via DNS or HTTP
Load balancing
Service registration
$ curl -x PUT -d 
'{
"name": "orders",
"port": 8000,
"Tags": [
"V1"
],
"checks": [{
"HTTP": "http://localhost:8000/health",
"Interval": "10s",
"TTL": "15s"
}]
}' http://localhost:8500/v1/agent/service/register
Consul: DNS interface
$ dig @127.0.0.1 -p 8600 orders.service.consul
...
;; QUESTION SECTION:
;orders.service.consul. IN A
;; ANSWER SECTION:
orders.service.consul. 0 IN A 172.20.20.10
orders.service.consul. 0 IN A 172.20.20.11
orders.service.consul. 0 IN A 172.20.20.12
Consul: DNS interface
$ dig @127.0.0.1 -p 8600 orders.service.consul SRV
...
;; QUESTION SECTION:
;orders.service.consul. IN SRV
;; ANSWER SECTION:
orders.service.consul. SRV 1 1 8000 foobar-0.node.dc1.consul.
orders.service.consul. SRV 1 1 8001 foobar-2.node.dc1.consul.
orders.service.consul. SRV 1 1 8002 foobar-3.node.dc1.consul.
;; ADDITIONAL SECTION:
foobar-0.node.dc1.consul. 0 IN A 172.20.20.10
foobar-1.node.dc1.consul. 0 IN A 172.20.20.11
foobar-2.node.dc1.consul. 0 IN A 172.20.20.12
Consul: HTTP API
$ curl http://localhost:8500/v1/catalog/service/orders
[{
"ID": "1a6010e0-518c-2338-89f5-d7b8e4031a67",
"Node": "node-1",
"Address": "172.20.20.10",
"Datacenter": "dc1",
"TaggedAddresses": {
"lan": "172.20.20.10",
"wan": "10.0.10.10"
},
"NodeMeta": {
"consul-network-segment": ""
},
"ServiceID": "orders-node-1-8000",
"ServiceName": "orders",
"ServiceTags": [],
"ServiceAddress": "172.20.20.10",
"ServiceMeta": {},
"ServicePort": 8000,
"ServiceEnableTagOverride": false,
"CreateIndex": 580989,
"ModifyIndex": 580989
}]
Service discovery and DNS
Zero touch integration with nearly any existing software
Look up as “orders.service.consul”
Shuffled results - ditch the load balancer
Failure detection
State of the world is as fresh as possible
Automatically pull failed instances out of service
Immediately put healthy new instances into service
Service oriented architecture
Shop app
Orders
Search
Reviews
Loadbalancer
Consul
Get service IP:port
/orders
/reviews
/search
Fabio
Zero configuration TCP/HTTP(S) reverse proxy
First class integration with Consul
Weighted routing
Manual overrides
Fabio tag registration
$ curl -x PUT -d 
'{
"name": "orders",
"port": 8000,
"Tags": [
"V1",
"utlprefix-donerhub.com/orders"
],
"checks": [{
"HTTP": "http://localhost:8000/health",
"Interval": "10s",
"TTL": "15s"
}]
}' http://localhost:8500/v1/agent/service/register
Load balancing with Fabio
Fabio
Orders
Search
Reviews
Consul
Get IP:port
/orders
/reviews
/search
Internet
Risky features
Large refactoring
Switch storage layer
New payment API
Consul KV as a feature toggle
Write flag value to consul
$ consul kv put search/elastic true
Consul KV as a feature toggle
Read flag value from application
if consul.Get("search/elastic") == "true" {
// use elastic search
}
Consul KV as a feature toggle
Enables “dark mode” features
Easy way to disable without needing a code deploy
Solution: Consul template
Retrieves keys and services from Consul and renders them into a template
$ consul-template -template "in.tpl:out.txt:command"
Consul template
CONSUL
key = {{ key “keyName” }}
CONSUL TEMPLATE
key = value
FILE.CONF
1
2
3
How it works
Consul template performs blocking query against the KV store
Stores the value in the file when key is updated
Runs the specified command after the update
Availability around the world
frontend
orders reviews
frontend
orders reviews
Availability around the world
frontend
orders reviews
frontend
orders reviews
Availability around the world
frontend
orders reviews
frontend
orders reviews
Manual overrides
Override service address to “orders.service.eu.consul” or “172.30.20.10”
Not transparent
Need config fiddling and may need app restarts
Consul prepared queries
Centrally managed policies that allow dynamic behaviour for service lookups
without any knowledge from applications
Define which service to look up, and rules for what to do if none are not
available in the local datacenter
Can be executed via DNS or HTTP
Consul prepared query
$ curl -x POST -d 
'{
"Name": "",
"Template": {
"Type": "name_prefix_match",
},
"Service": {
"Service": "${name.full}",
"OnlyPassing": true,
"Failover": {
"Datacenters": ["US", "EU"]
}
}
}' http://localhost:8500/v1/query
Consul prepared query
$ dig @127.0.0.1 -p 8600 orders.query.consul
...
;; QUESTION SECTION:
;orders.query.consul. IN A
;; ANSWER SECTION:
orders.query.consul. 0 IN A 172.20.20.10
orders.query.consul. 0 IN A 172.20.20.11
orders.query.consul. 0 IN A 172.20.20.12
Consul prepared query: Name + tags
$ curl -x POST -d 
'{
"Name": "",
"Template": {
"Type": "name_prefix_match",
"Regexp": "^(([^.]+).)?([^.]+)$",
"RemoveEmptyTags": true
},
"Service": {
"Service": "${match(3)}",
"Tags": ["${match(2)}"],
"OnlyPassing": true,
"Failover": {
"NearestN": 3
}
}
}' http://localhost:8500/v1/query
Consul prepared query: Name + tags
$ dig @127.0.0.1 -p 8600 master.db.query.consul
...
;; QUESTION SECTION:
;master.db.query.consul. IN A
;; ANSWER SECTION:
master.db.query.consul. 0 IN A 172.30.30.10
Single line config for geo failover
Local service discovery: “orders.service.consul”
Local + geo failover: “orders.query.consul”
Availability around the world
frontend
orders reviews
frontend
orders reviews
Deployment
Deployment
Manual ?!
Bash script
System package managers (apt, rpm, yum, etc...)
Ansible, Puppet, Salt
Deployment problems
Complex deployment scripts
Infrastructure configuration and maintenance
Rollback to stable version
Resources utilization
Scalability
Solution: Nomad
Nomad is a single binary tool for schedule and
run applications on Linux, Windows, and Mac
across multiple datacenters
Nomad
● Declarative
Nomad
● Declarative
● Scalable
Nomad
● Declarative
● Scalable
● Predictable
Nomad
● Declarative
● Scalable
● Predictable
● Infrastructure agnostic
Nomad features
Docker Support
Operationally Simple
Built for Scale
Canary deployments
Handle server failures gracefully
UI interface
Nomad architecture
Nomad: multi DC architecture
Scheduler Types
Service - long running jobs
Batch - short lived and periodic jobs
System - runs on all nodes (logs collector, metrics, etc...)
job "orders" {
datacenters = ["eu1", "eu2"]
type = "service"
group "orders" {
count = 3
task "orders" {
driver = "docker"
config {
image = "registry.cloud/orders"
port_map { http = 80 }
}
resources {
cpu = 500
memory = 100
network { port "http" {} }
}
service {
name = "orders"
tags = ["urlprefix-donerhub.com/orders", "urlprefix-www.donerhub.com/orders"]
port = "http"
check {
name = "alive"
type = "http"
interval = "10s"
timeout = "2s"
path = "/health-check"
}
}
}
}
}
Nomad job scheduling
Schedule the job contained in the file job1.nomad, monitoring placement:
$ nomad job run job1.nomad
==> Monitoring evaluation "52dee78a"
Evaluation triggered by job "example"
Evaluation within deployment: "62eb607c"
Allocation "5e0b39f0" created: node "3e84d3d2", group "group1"
Allocation "5e0b39f0" status changed: "pending" -> "running"
Evaluation status changed: "pending" -> "complete"
==> Evaluation "52dee78a" finished with status "complete"
Solved issues
Service discovery
Configuration management
Deployment
Problem: Infrastructure management
Service discovery
Configuration management
Deployment
Infrastructure management
Solution: Terraform
Terraform enables you to safely and
predictably create, change, and
improve infrastructure as code to
increase operator productivity and
transparency.
Terraform features
Infrastructure as Code
Execution Plans
Resource Graph
Change Automation
Multi-vendor api
Terraform features
Configuration can be stored in version control, shared, and collaborated on by
teams of operators
Track the complete history of infrastructure versions
Manage resources across all major infrastructure providers (AWS, GCP, Azure,
DigitalOcean, OpenStack, VMware, and more)
Terraform
Typical terraform project files:
$ ls
main.tf variables.tf output.tf terraform.tfstate
main.tf
provider "aws" {
access_key = "${var.access_token}"
secret_key = "${var.secret_key}"
region = "us-east-1"
}
resource "aws_instance" "web" {
count = ${var.backend_count}
ami = "ami-2757f631"
instance_type = "t2.micro"
}
variables.tf
variable "access_token" {
description = "AWS access token"
default = "123456789ABCDEF"
}
variable "secret_key" {
description = "AWS secret key"
default = "123456789ABCDEF"
}
variable "backend_count" {
description = "Backend instances count"
default = 5
}
output.tf
output "web servers IPs" {
value = ["${aws_instance.web.*.public_ip}"]
description = "Web servers public IPs"
}
$ terraform apply
# ...
+ aws_instance.web
ami: "ami-2757f631"
availability_zone: "<computed>"
instance_state: "<computed>"
instance_type: "t2.micro"
key_name: "<computed>"
placement_group: "<computed>"
private_dns: "<computed>"
private_ip: "<computed>"
public_dns: "<computed>"
public_ip: "<computed>"
source_dest_check: "true"
subnet_id: "<computed>"
tenancy: "<computed>"
# ...
aws_instance.web: Creation complete
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
# ...
$ terraform show
aws_instance.web:
id = i-32cf65a8
ami = ami-2757f631
availability_zone = us-east-1a
instance_state = running
instance_type = t2.micro
private_ip = 172.31.30.244
public_dns = ec2-52-90-212-55.compute-1.amazonaws.com
public_ip = 52.90.212.55
subnet_id = subnet-1497024d
vpc_security_group_ids.# = 1
vpc_security_group_ids.3348721628 = sg-67652003
Thank you!
Oleg Lobanov
eBay
@o1egl
https://github.com/o1egl
HashiCorp Tools

Weitere ähnliche Inhalte

Was ist angesagt?

Pm ix tutorial-june2019-pub (1)
Pm ix tutorial-june2019-pub (1)Pm ix tutorial-june2019-pub (1)
Pm ix tutorial-june2019-pub (1)
ewerkboy
 

Was ist angesagt? (20)

Automation intro
Automation introAutomation intro
Automation intro
 
Into The Box 2018 Ortus Keynote
Into The Box 2018 Ortus KeynoteInto The Box 2018 Ortus Keynote
Into The Box 2018 Ortus Keynote
 
Fixing Domino Server Sickness
Fixing Domino Server SicknessFixing Domino Server Sickness
Fixing Domino Server Sickness
 
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
OSGi for real in the enterprise: Apache Karaf - NLJUG J-FALL 2010
 
Slaying Monoliths with Node and Docker
Slaying Monoliths with Node and DockerSlaying Monoliths with Node and Docker
Slaying Monoliths with Node and Docker
 
Developing Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12c
Developing Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12cDeveloping Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12c
Developing Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12c
 
Modular Architectures using Micro Services
Modular Architectures using Micro ServicesModular Architectures using Micro Services
Modular Architectures using Micro Services
 
Liberty management
Liberty managementLiberty management
Liberty management
 
Pm ix tutorial-june2019-pub (1)
Pm ix tutorial-june2019-pub (1)Pm ix tutorial-june2019-pub (1)
Pm ix tutorial-june2019-pub (1)
 
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
 
June OpenNTF Webinar - Domino V12 Certification Manager
June OpenNTF Webinar - Domino V12 Certification ManagerJune OpenNTF Webinar - Domino V12 Certification Manager
June OpenNTF Webinar - Domino V12 Certification Manager
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stack
 
Testing Ansible
Testing AnsibleTesting Ansible
Testing Ansible
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
 
Becoming A Connections Administrator
Becoming A Connections AdministratorBecoming A Connections Administrator
Becoming A Connections Administrator
 
Hidden gems in cf2016
Hidden gems in cf2016Hidden gems in cf2016
Hidden gems in cf2016
 
January OpenNTF Webinar - Backup your Domino Server - New Options in V12
January OpenNTF Webinar - Backup your Domino Server - New Options in V12January OpenNTF Webinar - Backup your Domino Server - New Options in V12
January OpenNTF Webinar - Backup your Domino Server - New Options in V12
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014
 
Hidden Gems in ColdFusion 2016
Hidden Gems in ColdFusion 2016Hidden Gems in ColdFusion 2016
Hidden Gems in ColdFusion 2016
 
W-JAX 2011: OSGi with Apache Karaf
W-JAX 2011: OSGi with Apache KarafW-JAX 2011: OSGi with Apache Karaf
W-JAX 2011: OSGi with Apache Karaf
 

Ähnlich wie HashiStack. To the cloud and beyond...

Ähnlich wie HashiStack. To the cloud and beyond... (20)

Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClass
 
Infrastructure development using Consul
Infrastructure development using ConsulInfrastructure development using Consul
Infrastructure development using Consul
 
Developer Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve ParityDeveloper Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve Parity
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for Government
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for Government
 
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
 
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
 
56k.cloud training
56k.cloud training56k.cloud training
56k.cloud training
 
JAX London 2019 "Cloud Native Communication: Using an API Gateway and Service...
JAX London 2019 "Cloud Native Communication: Using an API Gateway and Service...JAX London 2019 "Cloud Native Communication: Using an API Gateway and Service...
JAX London 2019 "Cloud Native Communication: Using an API Gateway and Service...
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"
 
Twelve Factor App
Twelve Factor AppTwelve Factor App
Twelve Factor App
 
Tech Talk: DevOps at LeanIX @ Startup Camp Berlin
Tech Talk: DevOps at LeanIX @ Startup Camp BerlinTech Talk: DevOps at LeanIX @ Startup Camp Berlin
Tech Talk: DevOps at LeanIX @ Startup Camp Berlin
 
Server Farms and XML Web Services
Server Farms and XML Web ServicesServer Farms and XML Web Services
Server Farms and XML Web Services
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
[Capitole du Libre] #serverless -  mettez-le en oeuvre dans votre entreprise...
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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?
 
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...
 

HashiStack. To the cloud and beyond...

  • 1. To the cloud and beyond...
  • 2. Doner Hub The best doner marketplace
  • 3. Doner Hub Marketplace for doners Ratings and reviews Search by dietary preferences Social network
  • 5. Old-school monolith with LB Internet DB Shop app Shop appLoadbalancer
  • 6. Monolithic architecture problems ● Large codebase ● Hard to scale ● Redeploy the entire application on each update ● Bug in any module can potentially bring down the entire process ● Has a barrier to adopting new technologies ● Continuous deployment is difficult
  • 7.
  • 9. Service oriented architecture Internet DBShop app Loadbalancer Orders Search Reviews
  • 10. Service oriented architecture Internet DB Shop app Loadbalancer Orders Search Reviews DB DB
  • 14. SOA architecture problems ● Adds a complexity to the project ● Partitioned database architecture ● Difficult to implement changes that span multiple services ● Complex testing process ● Service discovery ● Configuration ● Deployment
  • 15. SOA architecture problems ● Adds a complexity to the project ● Partitioned database architecture ● Difficult to implement changes that span multiple services ● Complex testing process ● Service discovery ● Configuration ● Deployment
  • 16. Problem: Load Balancing Shop app Node 1 Node 2 Node 3 Orders service Ensure that requests are balanced across instances
  • 17. Solution: Load Balancer for internal services Shop app Node 1 Node 2 Node 3 Orders service Loadbalancer
  • 18. Problem: health checking Shop app Node 1 Node 2 Node 3 Services Loadbalancer Route traffic only to alive instances
  • 19. Problem: add new nodes Shop app Node 1 Node 2 Node 3 Services Loadbalancer Dynamically add new nodes Node 4
  • 20. Problems with internal load balancers Yet another infrastructure to run and maintain Load grows with the numbers of service instances Single point of failure LB configuration management and reload Require health probing
  • 21. Solution: Consul Consul is a distributed service mesh to connect, secure, and configure services across any runtime platform and public or private cloud
  • 22. Consul features Service discovery Distributed locks and semaphores Distributed key-value storage Cross DC sync
  • 23.
  • 24. Consul service registration Register services (IP + port + checks) via config file or HTTP Discover services via DNS or HTTP Load balancing
  • 25. Service registration $ curl -x PUT -d '{ "name": "orders", "port": 8000, "Tags": [ "V1" ], "checks": [{ "HTTP": "http://localhost:8000/health", "Interval": "10s", "TTL": "15s" }] }' http://localhost:8500/v1/agent/service/register
  • 26. Consul: DNS interface $ dig @127.0.0.1 -p 8600 orders.service.consul ... ;; QUESTION SECTION: ;orders.service.consul. IN A ;; ANSWER SECTION: orders.service.consul. 0 IN A 172.20.20.10 orders.service.consul. 0 IN A 172.20.20.11 orders.service.consul. 0 IN A 172.20.20.12
  • 27. Consul: DNS interface $ dig @127.0.0.1 -p 8600 orders.service.consul SRV ... ;; QUESTION SECTION: ;orders.service.consul. IN SRV ;; ANSWER SECTION: orders.service.consul. SRV 1 1 8000 foobar-0.node.dc1.consul. orders.service.consul. SRV 1 1 8001 foobar-2.node.dc1.consul. orders.service.consul. SRV 1 1 8002 foobar-3.node.dc1.consul. ;; ADDITIONAL SECTION: foobar-0.node.dc1.consul. 0 IN A 172.20.20.10 foobar-1.node.dc1.consul. 0 IN A 172.20.20.11 foobar-2.node.dc1.consul. 0 IN A 172.20.20.12
  • 28. Consul: HTTP API $ curl http://localhost:8500/v1/catalog/service/orders [{ "ID": "1a6010e0-518c-2338-89f5-d7b8e4031a67", "Node": "node-1", "Address": "172.20.20.10", "Datacenter": "dc1", "TaggedAddresses": { "lan": "172.20.20.10", "wan": "10.0.10.10" }, "NodeMeta": { "consul-network-segment": "" }, "ServiceID": "orders-node-1-8000", "ServiceName": "orders", "ServiceTags": [], "ServiceAddress": "172.20.20.10", "ServiceMeta": {}, "ServicePort": 8000, "ServiceEnableTagOverride": false, "CreateIndex": 580989, "ModifyIndex": 580989 }]
  • 29. Service discovery and DNS Zero touch integration with nearly any existing software Look up as “orders.service.consul” Shuffled results - ditch the load balancer
  • 30. Failure detection State of the world is as fresh as possible Automatically pull failed instances out of service Immediately put healthy new instances into service
  • 31. Service oriented architecture Shop app Orders Search Reviews Loadbalancer Consul Get service IP:port /orders /reviews /search
  • 32. Fabio Zero configuration TCP/HTTP(S) reverse proxy First class integration with Consul Weighted routing Manual overrides
  • 33. Fabio tag registration $ curl -x PUT -d '{ "name": "orders", "port": 8000, "Tags": [ "V1", "utlprefix-donerhub.com/orders" ], "checks": [{ "HTTP": "http://localhost:8000/health", "Interval": "10s", "TTL": "15s" }] }' http://localhost:8500/v1/agent/service/register
  • 34. Load balancing with Fabio Fabio Orders Search Reviews Consul Get IP:port /orders /reviews /search Internet
  • 35.
  • 36. Risky features Large refactoring Switch storage layer New payment API
  • 37. Consul KV as a feature toggle Write flag value to consul $ consul kv put search/elastic true
  • 38. Consul KV as a feature toggle Read flag value from application if consul.Get("search/elastic") == "true" { // use elastic search }
  • 39. Consul KV as a feature toggle Enables “dark mode” features Easy way to disable without needing a code deploy
  • 40.
  • 41. Solution: Consul template Retrieves keys and services from Consul and renders them into a template $ consul-template -template "in.tpl:out.txt:command"
  • 42. Consul template CONSUL key = {{ key “keyName” }} CONSUL TEMPLATE key = value FILE.CONF 1 2 3
  • 43. How it works Consul template performs blocking query against the KV store Stores the value in the file when key is updated Runs the specified command after the update
  • 44. Availability around the world frontend orders reviews frontend orders reviews
  • 45. Availability around the world frontend orders reviews frontend orders reviews
  • 46.
  • 47.
  • 48. Availability around the world frontend orders reviews frontend orders reviews
  • 49. Manual overrides Override service address to “orders.service.eu.consul” or “172.30.20.10” Not transparent Need config fiddling and may need app restarts
  • 50. Consul prepared queries Centrally managed policies that allow dynamic behaviour for service lookups without any knowledge from applications Define which service to look up, and rules for what to do if none are not available in the local datacenter Can be executed via DNS or HTTP
  • 51. Consul prepared query $ curl -x POST -d '{ "Name": "", "Template": { "Type": "name_prefix_match", }, "Service": { "Service": "${name.full}", "OnlyPassing": true, "Failover": { "Datacenters": ["US", "EU"] } } }' http://localhost:8500/v1/query
  • 52. Consul prepared query $ dig @127.0.0.1 -p 8600 orders.query.consul ... ;; QUESTION SECTION: ;orders.query.consul. IN A ;; ANSWER SECTION: orders.query.consul. 0 IN A 172.20.20.10 orders.query.consul. 0 IN A 172.20.20.11 orders.query.consul. 0 IN A 172.20.20.12
  • 53. Consul prepared query: Name + tags $ curl -x POST -d '{ "Name": "", "Template": { "Type": "name_prefix_match", "Regexp": "^(([^.]+).)?([^.]+)$", "RemoveEmptyTags": true }, "Service": { "Service": "${match(3)}", "Tags": ["${match(2)}"], "OnlyPassing": true, "Failover": { "NearestN": 3 } } }' http://localhost:8500/v1/query
  • 54. Consul prepared query: Name + tags $ dig @127.0.0.1 -p 8600 master.db.query.consul ... ;; QUESTION SECTION: ;master.db.query.consul. IN A ;; ANSWER SECTION: master.db.query.consul. 0 IN A 172.30.30.10
  • 55. Single line config for geo failover Local service discovery: “orders.service.consul” Local + geo failover: “orders.query.consul”
  • 56. Availability around the world frontend orders reviews frontend orders reviews
  • 58. Deployment Manual ?! Bash script System package managers (apt, rpm, yum, etc...) Ansible, Puppet, Salt
  • 59. Deployment problems Complex deployment scripts Infrastructure configuration and maintenance Rollback to stable version Resources utilization Scalability
  • 60.
  • 61. Solution: Nomad Nomad is a single binary tool for schedule and run applications on Linux, Windows, and Mac across multiple datacenters
  • 65. Nomad ● Declarative ● Scalable ● Predictable ● Infrastructure agnostic
  • 66. Nomad features Docker Support Operationally Simple Built for Scale Canary deployments Handle server failures gracefully UI interface
  • 68. Nomad: multi DC architecture
  • 69. Scheduler Types Service - long running jobs Batch - short lived and periodic jobs System - runs on all nodes (logs collector, metrics, etc...)
  • 70. job "orders" { datacenters = ["eu1", "eu2"] type = "service" group "orders" { count = 3 task "orders" { driver = "docker" config { image = "registry.cloud/orders" port_map { http = 80 } } resources { cpu = 500 memory = 100 network { port "http" {} } } service { name = "orders" tags = ["urlprefix-donerhub.com/orders", "urlprefix-www.donerhub.com/orders"] port = "http" check { name = "alive" type = "http" interval = "10s" timeout = "2s" path = "/health-check" } } } } }
  • 71. Nomad job scheduling Schedule the job contained in the file job1.nomad, monitoring placement: $ nomad job run job1.nomad ==> Monitoring evaluation "52dee78a" Evaluation triggered by job "example" Evaluation within deployment: "62eb607c" Allocation "5e0b39f0" created: node "3e84d3d2", group "group1" Allocation "5e0b39f0" status changed: "pending" -> "running" Evaluation status changed: "pending" -> "complete" ==> Evaluation "52dee78a" finished with status "complete"
  • 72.
  • 74. Problem: Infrastructure management Service discovery Configuration management Deployment Infrastructure management
  • 75. Solution: Terraform Terraform enables you to safely and predictably create, change, and improve infrastructure as code to increase operator productivity and transparency.
  • 76. Terraform features Infrastructure as Code Execution Plans Resource Graph Change Automation Multi-vendor api
  • 77. Terraform features Configuration can be stored in version control, shared, and collaborated on by teams of operators Track the complete history of infrastructure versions Manage resources across all major infrastructure providers (AWS, GCP, Azure, DigitalOcean, OpenStack, VMware, and more)
  • 78. Terraform Typical terraform project files: $ ls main.tf variables.tf output.tf terraform.tfstate
  • 79. main.tf provider "aws" { access_key = "${var.access_token}" secret_key = "${var.secret_key}" region = "us-east-1" } resource "aws_instance" "web" { count = ${var.backend_count} ami = "ami-2757f631" instance_type = "t2.micro" }
  • 80. variables.tf variable "access_token" { description = "AWS access token" default = "123456789ABCDEF" } variable "secret_key" { description = "AWS secret key" default = "123456789ABCDEF" } variable "backend_count" { description = "Backend instances count" default = 5 }
  • 81. output.tf output "web servers IPs" { value = ["${aws_instance.web.*.public_ip}"] description = "Web servers public IPs" }
  • 82. $ terraform apply # ... + aws_instance.web ami: "ami-2757f631" availability_zone: "<computed>" instance_state: "<computed>" instance_type: "t2.micro" key_name: "<computed>" placement_group: "<computed>" private_dns: "<computed>" private_ip: "<computed>" public_dns: "<computed>" public_ip: "<computed>" source_dest_check: "true" subnet_id: "<computed>" tenancy: "<computed>" # ... aws_instance.web: Creation complete Apply complete! Resources: 1 added, 0 changed, 0 destroyed. # ...
  • 83. $ terraform show aws_instance.web: id = i-32cf65a8 ami = ami-2757f631 availability_zone = us-east-1a instance_state = running instance_type = t2.micro private_ip = 172.31.30.244 public_dns = ec2-52-90-212-55.compute-1.amazonaws.com public_ip = 52.90.212.55 subnet_id = subnet-1497024d vpc_security_group_ids.# = 1 vpc_security_group_ids.3348721628 = sg-67652003
  • 84.
  • 85.