Autoscaling with hashi_corp_nomad

Bram Vogelaar
Bram VogelaarCloud Engineer at Seaplane.io
Autoscaling your
Nomad jobs
a
HashiTalks 2021
➔Used to be a Molecular Biologist,
Used to be a Molecular Biologist,
➔Then became a Dev,
Then became a Dev,
➔Now an Ops.
Now an Ops.
➔Currently
Currently CTO @ Hot Potatoes
CTO @ Hot Potatoes
➔Today Proud Dad
Today Proud Dad
Scaling applications, the hardware way
Moving it all to the cloud
Nomad
my overengineered personal website
job "blog" {
datacenters = ["aws"]
type = "service"
group "hugo" {
count = 1
network {
port "http" {
to = 80
}
}
task "nginx" {
driver = "docker"
config {
image = "private.dkr.ecr.us-east-1.amazonaws.com/blog:11"
ports = ["http"]
}
}
Deploy the blog
Nomad status
●
Introduced in/with Nomad 0.11
●
(Currently) independently release cycle
●
Gaining new functionality every release
●
Build in Functionality for horizontal and vertical scaling
●
But extendable by your own (community) plugins
Nomad autoscaler
●
Makes decisions based on a checks
●
Checks are a combination of
– Data queried from an APM
– Defined STRATEGY
– Attempt to approach TARGET value
●
Multiple Checks can be combined
– Answer with the most resources will win!
●
ScaleOut and ScaleIn => ScaleOut
●
ScaleOut and ScaleNone => ScaleOut
●
ScaleIn and ScaleNone => ScaleNone
●
ScaleOut(10) and ScaleOut(9) => ScaleOut(10)
●
ScaleIn(3) and ScaleIn(4) => ScaleIn(4)
Auto-scaling TLDR
job "autoscaler" {
type = "service"
datacenters = ["aws"]
group "autoscaler" {
count = 1
task "autoscaler" {
driver = "docker"
config {
image = "hashicorp/nomad-autoscaler:0.2.1"
command = "nomad-autoscaler"
args = [
"agent",
"-config",
"${NOMAD_TASK_DIR}/config.hcl",
"-http-bind-address",
"0.0.0.0",
]
Deploy the autoscaler
nomad {
address = "http://{{env "attr.unique.network.ip-address" }}:4646"
}
apm "prometheus" {
driver = "prometheus"
config = {
address = "http://prometheus.service.consul:9090"
}
}
strategy "target-value" {
driver = "target-value"
}
Config for the autoscaler
Metrics
https://prometheus.io/
job "blog" {
datacenters = ["aws"]
type = "service"
group "hugo" {
count = 3
scaling {
enabled = true
min = 1
max = 20
policy {
cooldown = "20s"
check "avg_instance_sessions" {
source = "prometheus"
query = "scalar(avg(traefik_service_open_connections{service="blog@consulcatalog"}))"
strategy "target-value" {
target = 5
}
Enable autoscaling for the blog
Dashboards
https://grafana.com/oss/grafana/
Enable autoscaling
Observe scaling down event
Observe the autoscaler
agent: querying APM: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus
strategy=target-value target=local-nomad
agent: calculating new count: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus
strategy=target-value target=local-nomad
agent: next count outside limits: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus
strategy=target-value target=local-nomad from=3 to=0 min=1 max=10
agent: updated count to be within limits: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d
source=prometheus strategy=target-value target=local-nomad from=3 to=1 min=1 max=10
agent: scaling target: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus
strategy=target-value target=local-nomad target_config="map[group:demo job_id:webapp]" from=3 to=1
reason="capping count to min value of 1"
Apply load
Remove load
Logs
https://grafana.com/oss/loki/
group "autoscaler" {
count = 1
task "autoscaler" {
driver = "docker"
config {
image = "hashicorp/nomad-autoscaler:0.2.1"
command = "nomad-autoscaler"
logging {
type = "loki"
config {
loki-url = 'http://loki.service.consul:3100/api/prom/push'
tag = "loki"
}
}
Direct to loki
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
task "promtail" {
driver = "docker"
lifecycle {
hook = "prestart"
sidecar = true
}
config {
image = "grafana/promtail:1.5.0"
args = [
"-config.file",
"local/promtail.yaml",
]
Promtail sidecar
scrape_configs:
- job_name: system
entry_parser: raw
static_configs:
- targets:
- localhost
labels:
task: autoscaler
__path__: /alloc/logs/autoscaler*
pipeline_stages:
- match:
selector: '{task="autoscaler"}'
stages:
- regex:
expression: '.*policy_id=(?P<policy_id>[a-zA-Z0-9_-]+).*source=(?P<source>[a-zA-Z0-9_-]+).*strategy=(?P<strategy>[a-zA-Z0-9_-]+).*target=(?P<target>[a-
zA-Z0-9_-]+).*Group:(?P<group>[a-zA-Z0-9]+).*Job:(?P<job>[a-zA-Z0-9_-]+).*Namespace:(?P<namespace>[a-zA-Z0-9_-]+)'
Promtail sidecar
https://grafana.com/docs/loki/latest/clients/promtail/
Annotate your graphs
Correlate events with metrics
https://learn.hashicorp.com/tutorials/nomad/
autoscaler-vagrant-demo?in=nomad/ecosystem
Try it yourself
Moving it all to the cloud *
nomad {
address = "http://{{env "attr.unique.network.ip-address" }}:4646"
}
apm "prometheus" {
driver = "prometheus"
config = {
address = "http://prometheus.service.consul:9090"
}
}
target "aws-asg" {
driver = "aws-asg"
config = {
aws_region = "{{ $x := env "attr.platform.aws.placement.availability-zone" }}{{ $length := len $x |subtract 1 }}{{ slice $x 0 $length}}"
}
}
Grow into your platform
scaling "cluster_policy" {
policy {
cooldown = "2m"
evaluation_interval = "1m"
check "cpu_allocated_percentage" {
source = "prometheus"
query = "scalar(sum(nomad_client_allocated_cpu{node_class="hashistack"}*100/(nomad_client_unallocated_cpu{node_class="hashistack"}
+nomad_client_allocated_cpu{node_class="hashistack"}))/count(nomad_client_allocated_cpu{node_class="hashistack"}))"
strategy "target-value" {
target = 70
}
}
target "aws-asg" {
dry-run = "false"
aws_asg_name = "${client_asg_name}"
node_class = "hashistack"
node_drain_deadline = "5m"
}
Grow into your platform
https://github.com/hashicorp/nomad-autoscaler/
tree/master/demo/remote
Try it yourself
Moving it all to the cloud – QED
bram@attachmentgenie.com
@attachmentgenie
slideshare.net/attachmentgenie
Thank You
1 of 33

Recommended

Observability with Consul Connect by
Observability with Consul ConnectObservability with Consul Connect
Observability with Consul ConnectBram Vogelaar
377 views38 slides
Complete Guide for Linux shell programming by
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programmingsudhir singh yadav
1.2K views142 slides
How to add system calls to OS/161 by
How to add system calls to OS/161How to add system calls to OS/161
How to add system calls to OS/161Xiao Qin
9.8K views25 slides
Linux basic commands with examples by
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examplesabclearnn
2K views39 slides
Shell scripting by
Shell scriptingShell scripting
Shell scriptingManav Prasad
3.6K views90 slides
Manipulators by
ManipulatorsManipulators
ManipulatorsKamal Acharya
4K views7 slides

More Related Content

What's hot

SHELL PROGRAMMING by
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMINGjinal thakrar
2.3K views20 slides
Shell and its types in LINUX by
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUXSHUBHA CHATURVEDI
1.8K views21 slides
Input output streams by
Input output streamsInput output streams
Input output streamsParthipan Parthi
2.6K views22 slides
PHP array 1 by
PHP array 1PHP array 1
PHP array 1Mudasir Syed
1.4K views28 slides
C++ string by
C++ stringC++ string
C++ stringDheenadayalan18
340 views7 slides

What's hot(20)

Operator overloading by Burhan Ahmed
Operator overloadingOperator overloading
Operator overloading
Burhan Ahmed349 views
Web html table tags by Kainat Ilyas
Web html  table tagsWeb html  table tags
Web html table tags
Kainat Ilyas7.7K views
Arrays in python by moazamali28
Arrays in pythonArrays in python
Arrays in python
moazamali283.3K views
Polymorphism in C# Function overloading in C# by Abid Kohistani
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#
Abid Kohistani180 views
Regular Expressions grep and egrep by Tri Truong
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
Tri Truong10.8K views

Similar to Autoscaling with hashi_corp_nomad

Easy Cloud Native Transformation using HashiCorp Nomad by
Easy Cloud Native Transformation using HashiCorp NomadEasy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp NomadBram Vogelaar
165 views56 slides
Burn down the silos! Helping dev and ops gel on high availability websites by
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
1.6K views177 slides
Modern Scheduling for Modern Applications with Nomad by
Modern Scheduling for Modern Applications with NomadModern Scheduling for Modern Applications with Nomad
Modern Scheduling for Modern Applications with NomadMitchell Pronschinske
800 views38 slides
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre... by
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...Amazon Web Services
7K views102 slides
Cutting through the fog of cloud by
Cutting through the fog of cloudCutting through the fog of cloud
Cutting through the fog of cloudKyle Rames
1.5K views94 slides
Apache Ambari: Simplified Hadoop Cluster Operation & Troubleshooting by
Apache Ambari: Simplified Hadoop Cluster Operation & TroubleshootingApache Ambari: Simplified Hadoop Cluster Operation & Troubleshooting
Apache Ambari: Simplified Hadoop Cluster Operation & TroubleshootingJayush Luniya
673 views34 slides

Similar to Autoscaling with hashi_corp_nomad(20)

Easy Cloud Native Transformation using HashiCorp Nomad by Bram Vogelaar
Easy Cloud Native Transformation using HashiCorp NomadEasy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp Nomad
Bram Vogelaar165 views
Burn down the silos! Helping dev and ops gel on high availability websites by Lindsay Holmwood
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
Lindsay Holmwood1.6K views
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre... by Amazon Web Services
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
Cutting through the fog of cloud by Kyle Rames
Cutting through the fog of cloudCutting through the fog of cloud
Cutting through the fog of cloud
Kyle Rames1.5K views
Apache Ambari: Simplified Hadoop Cluster Operation & Troubleshooting by Jayush Luniya
Apache Ambari: Simplified Hadoop Cluster Operation & TroubleshootingApache Ambari: Simplified Hadoop Cluster Operation & Troubleshooting
Apache Ambari: Simplified Hadoop Cluster Operation & Troubleshooting
Jayush Luniya673 views
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky... by Big Data Spain
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Big Data Spain1.4K views
Deploying configurable frontend web application containers by José Moreira
Deploying configurable frontend web application containersDeploying configurable frontend web application containers
Deploying configurable frontend web application containers
José Moreira88 views
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development... by NETWAYS
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
NETWAYS187 views
Railsconf2011 deployment tips_for_slideshare by tomcopeland
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
tomcopeland1.4K views
Automatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS Summit by Amazon Web Services
Automatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS SummitAutomatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS Summit
Automatically Scaling Your Kubernetes Workloads - SVC209-S - Anaheim AWS Summit
Amazon Web Services1.2K views
LinuxCon 2013 Steven Dake on Using Heat for autoscaling OpenShift on Openstack by OpenShift Origin
LinuxCon 2013 Steven Dake on Using Heat for autoscaling OpenShift on OpenstackLinuxCon 2013 Steven Dake on Using Heat for autoscaling OpenShift on Openstack
LinuxCon 2013 Steven Dake on Using Heat for autoscaling OpenShift on Openstack
OpenShift Origin1.4K views
Build Fast WordPress Site With Gatsby by Imran Sayed
Build Fast WordPress Site With GatsbyBuild Fast WordPress Site With Gatsby
Build Fast WordPress Site With Gatsby
Imran Sayed1.3K views
Control your deployments with Capistrano by Ramazan K
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
Ramazan K2.6K views
Incrementalism: An Industrial Strategy For Adopting Modern Automation by Sean Chittenden
Incrementalism: An Industrial Strategy For Adopting Modern AutomationIncrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern Automation
Sean Chittenden652 views
Web applications with Catalyst by svilen.ivanov
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
svilen.ivanov2.1K views
Rally - Benchmarking_as_a_service - Openstack meetup by Ananth Padmanabhan
Rally - Benchmarking_as_a_service - Openstack meetupRally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetup

More from Bram Vogelaar

10 things i learned building nomad-packs by
10 things i learned building nomad-packs10 things i learned building nomad-packs
10 things i learned building nomad-packsBram Vogelaar
126 views26 slides
10 things I learned building Nomad packs by
10 things I learned building Nomad packs10 things I learned building Nomad packs
10 things I learned building Nomad packsBram Vogelaar
167 views25 slides
Easy Cloud Native Transformation with Nomad by
Easy Cloud Native Transformation with NomadEasy Cloud Native Transformation with Nomad
Easy Cloud Native Transformation with NomadBram Vogelaar
49 views34 slides
Uncomplicated Nomad by
Uncomplicated NomadUncomplicated Nomad
Uncomplicated NomadBram Vogelaar
106 views18 slides
Observability; a gentle introduction by
Observability; a gentle introductionObservability; a gentle introduction
Observability; a gentle introductionBram Vogelaar
75 views28 slides
Running Trusted Payload with Nomad and Waypoint by
Running Trusted Payload with Nomad and WaypointRunning Trusted Payload with Nomad and Waypoint
Running Trusted Payload with Nomad and WaypointBram Vogelaar
28 views32 slides

More from Bram Vogelaar(20)

10 things i learned building nomad-packs by Bram Vogelaar
10 things i learned building nomad-packs10 things i learned building nomad-packs
10 things i learned building nomad-packs
Bram Vogelaar126 views
10 things I learned building Nomad packs by Bram Vogelaar
10 things I learned building Nomad packs10 things I learned building Nomad packs
10 things I learned building Nomad packs
Bram Vogelaar167 views
Easy Cloud Native Transformation with Nomad by Bram Vogelaar
Easy Cloud Native Transformation with NomadEasy Cloud Native Transformation with Nomad
Easy Cloud Native Transformation with Nomad
Bram Vogelaar49 views
Observability; a gentle introduction by Bram Vogelaar
Observability; a gentle introductionObservability; a gentle introduction
Observability; a gentle introduction
Bram Vogelaar75 views
Running Trusted Payload with Nomad and Waypoint by Bram Vogelaar
Running Trusted Payload with Nomad and WaypointRunning Trusted Payload with Nomad and Waypoint
Running Trusted Payload with Nomad and Waypoint
Bram Vogelaar28 views
Securing Prometheus exporters using HashiCorp Vault by Bram Vogelaar
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp Vault
Bram Vogelaar398 views
CICD using jenkins and Nomad by Bram Vogelaar
CICD using jenkins and NomadCICD using jenkins and Nomad
CICD using jenkins and Nomad
Bram Vogelaar230 views
Bootstrapping multidc observability stack by Bram Vogelaar
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar190 views
Running trusted payloads with Nomad and Waypoint by Bram Vogelaar
Running trusted payloads with Nomad and WaypointRunning trusted payloads with Nomad and Waypoint
Running trusted payloads with Nomad and Waypoint
Bram Vogelaar144 views
Gamification of Chaos Testing by Bram Vogelaar
Gamification of Chaos TestingGamification of Chaos Testing
Gamification of Chaos Testing
Bram Vogelaar75 views
Puppet and the HashiStack by Bram Vogelaar
Puppet and the HashiStackPuppet and the HashiStack
Puppet and the HashiStack
Bram Vogelaar203 views
Bootstrapping multidc observability stack by Bram Vogelaar
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar125 views
Creating Reusable Puppet Profiles by Bram Vogelaar
Creating Reusable Puppet ProfilesCreating Reusable Puppet Profiles
Creating Reusable Puppet Profiles
Bram Vogelaar58 views
Gamification of Chaos Testing by Bram Vogelaar
Gamification of Chaos TestingGamification of Chaos Testing
Gamification of Chaos Testing
Bram Vogelaar108 views
Testing your infrastructure with litmus by Bram Vogelaar
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
Bram Vogelaar78 views
Devops its not about the tooling by Bram Vogelaar
Devops its not about the toolingDevops its not about the tooling
Devops its not about the tooling
Bram Vogelaar53 views
Over engineering your personal website by Bram Vogelaar
Over engineering your personal websiteOver engineering your personal website
Over engineering your personal website
Bram Vogelaar170 views
Integrating icinga2 and the HashiCorp suite by Bram Vogelaar
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
Bram Vogelaar534 views

Recently uploaded

NTGapps NTG LowCode Platform by
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform Mustafa Kuğu
287 views30 slides
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
113 views18 slides
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveNetwork Automation Forum
49 views35 slides
Data Integrity for Banking and Financial Services by
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial ServicesPrecisely
76 views26 slides
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...ShapeBlue
74 views17 slides
State of the Union - Rohit Yadav - Apache CloudStack by
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStackShapeBlue
218 views53 slides

Recently uploaded(20)

NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu287 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue113 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely76 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue74 views
State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue218 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE67 views
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool by ShapeBlue
Extending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPoolExtending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPool
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool
ShapeBlue56 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue114 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson142 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue120 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue86 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10110 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue75 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays49 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc130 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue93 views

Autoscaling with hashi_corp_nomad

  • 2. ➔Used to be a Molecular Biologist, Used to be a Molecular Biologist, ➔Then became a Dev, Then became a Dev, ➔Now an Ops. Now an Ops. ➔Currently Currently CTO @ Hot Potatoes CTO @ Hot Potatoes ➔Today Proud Dad Today Proud Dad
  • 4. Moving it all to the cloud
  • 7. job "blog" { datacenters = ["aws"] type = "service" group "hugo" { count = 1 network { port "http" { to = 80 } } task "nginx" { driver = "docker" config { image = "private.dkr.ecr.us-east-1.amazonaws.com/blog:11" ports = ["http"] } } Deploy the blog
  • 9. ● Introduced in/with Nomad 0.11 ● (Currently) independently release cycle ● Gaining new functionality every release ● Build in Functionality for horizontal and vertical scaling ● But extendable by your own (community) plugins Nomad autoscaler
  • 10. ● Makes decisions based on a checks ● Checks are a combination of – Data queried from an APM – Defined STRATEGY – Attempt to approach TARGET value ● Multiple Checks can be combined – Answer with the most resources will win! ● ScaleOut and ScaleIn => ScaleOut ● ScaleOut and ScaleNone => ScaleOut ● ScaleIn and ScaleNone => ScaleNone ● ScaleOut(10) and ScaleOut(9) => ScaleOut(10) ● ScaleIn(3) and ScaleIn(4) => ScaleIn(4) Auto-scaling TLDR
  • 11. job "autoscaler" { type = "service" datacenters = ["aws"] group "autoscaler" { count = 1 task "autoscaler" { driver = "docker" config { image = "hashicorp/nomad-autoscaler:0.2.1" command = "nomad-autoscaler" args = [ "agent", "-config", "${NOMAD_TASK_DIR}/config.hcl", "-http-bind-address", "0.0.0.0", ] Deploy the autoscaler
  • 12. nomad { address = "http://{{env "attr.unique.network.ip-address" }}:4646" } apm "prometheus" { driver = "prometheus" config = { address = "http://prometheus.service.consul:9090" } } strategy "target-value" { driver = "target-value" } Config for the autoscaler
  • 14. job "blog" { datacenters = ["aws"] type = "service" group "hugo" { count = 3 scaling { enabled = true min = 1 max = 20 policy { cooldown = "20s" check "avg_instance_sessions" { source = "prometheus" query = "scalar(avg(traefik_service_open_connections{service="blog@consulcatalog"}))" strategy "target-value" { target = 5 } Enable autoscaling for the blog
  • 18. Observe the autoscaler agent: querying APM: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus strategy=target-value target=local-nomad agent: calculating new count: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus strategy=target-value target=local-nomad agent: next count outside limits: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus strategy=target-value target=local-nomad from=3 to=0 min=1 max=10 agent: updated count to be within limits: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus strategy=target-value target=local-nomad from=3 to=1 min=1 max=10 agent: scaling target: policy_id=248f6157-ca37-f868-a0ab-cabbc67fec1d source=prometheus strategy=target-value target=local-nomad target_config="map[group:demo job_id:webapp]" from=3 to=1 reason="capping count to min value of 1"
  • 22. group "autoscaler" { count = 1 task "autoscaler" { driver = "docker" config { image = "hashicorp/nomad-autoscaler:0.2.1" command = "nomad-autoscaler" logging { type = "loki" config { loki-url = 'http://loki.service.consul:3100/api/prom/push' tag = "loki" } } Direct to loki docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
  • 23. task "promtail" { driver = "docker" lifecycle { hook = "prestart" sidecar = true } config { image = "grafana/promtail:1.5.0" args = [ "-config.file", "local/promtail.yaml", ] Promtail sidecar
  • 24. scrape_configs: - job_name: system entry_parser: raw static_configs: - targets: - localhost labels: task: autoscaler __path__: /alloc/logs/autoscaler* pipeline_stages: - match: selector: '{task="autoscaler"}' stages: - regex: expression: '.*policy_id=(?P<policy_id>[a-zA-Z0-9_-]+).*source=(?P<source>[a-zA-Z0-9_-]+).*strategy=(?P<strategy>[a-zA-Z0-9_-]+).*target=(?P<target>[a- zA-Z0-9_-]+).*Group:(?P<group>[a-zA-Z0-9]+).*Job:(?P<job>[a-zA-Z0-9_-]+).*Namespace:(?P<namespace>[a-zA-Z0-9_-]+)' Promtail sidecar https://grafana.com/docs/loki/latest/clients/promtail/
  • 28. Moving it all to the cloud *
  • 29. nomad { address = "http://{{env "attr.unique.network.ip-address" }}:4646" } apm "prometheus" { driver = "prometheus" config = { address = "http://prometheus.service.consul:9090" } } target "aws-asg" { driver = "aws-asg" config = { aws_region = "{{ $x := env "attr.platform.aws.placement.availability-zone" }}{{ $length := len $x |subtract 1 }}{{ slice $x 0 $length}}" } } Grow into your platform
  • 30. scaling "cluster_policy" { policy { cooldown = "2m" evaluation_interval = "1m" check "cpu_allocated_percentage" { source = "prometheus" query = "scalar(sum(nomad_client_allocated_cpu{node_class="hashistack"}*100/(nomad_client_unallocated_cpu{node_class="hashistack"} +nomad_client_allocated_cpu{node_class="hashistack"}))/count(nomad_client_allocated_cpu{node_class="hashistack"}))" strategy "target-value" { target = 70 } } target "aws-asg" { dry-run = "false" aws_asg_name = "${client_asg_name}" node_class = "hashistack" node_drain_deadline = "5m" } Grow into your platform
  • 32. Moving it all to the cloud – QED