Nomad is an open source tool for dynamic workload scheduling that can be used to easily transform applications to be cloud native. The document discusses how Nomad was used to deploy a personal blog to AWS, including writing a Nomad job file and using features like spreading tasks across hosts and auto-scaling. It also covers integrating Nomad with other HashiCorp tools like Consul for service discovery, Vault for access control, and the Nomad autoscaler for auto-scaling. Examples are provided of monitoring metrics with Prometheus and visualizing with Grafana.
2. $ whoami
⢠Used to be a Molecular Biologist
⢠Then became a Dev
⢠Now an Ops
⢠Currently Cloud Engineer @ The Factory
⢠Amsterdam HUG organizer
8. Nomad
l Open Source tool for dynamic workload scheduling
l Batch, containerized, and non-containerized applications.
l Has native Consul and Vault integrations.
l Has token based access setup.
l Jobs written in (H)ashiCorp (C)onfiguration (L)anguage
https://www.nomadproject.io/
9. job "blog" {
datacenters = ["aws"]
type = "service"
group "hugo" {
network {
port "http" {
to = 80
}
}
task "nginx" {
driver = "docker"
config {
image = "${PRIVATE}.dkr.ecr.us-east-1.amazonaws.com/blog:19"
ports = ["http"]
Deploy the blog
10. 1 == None
job "blog" {
datacenters = ["aws"]
type = "service"
group "hugo" {
count = 2
11. job "blog" {
datacenters = ["aws"]
type = "service"
group "hugo" {
count = 2
constraint {
operator = "distinct_hosts"
value = "true"
}
Force onto different hardware
12. job "blog" {
datacenters = ["aws"]
type = "service"
group "hugo" {
count = 2
Spread {
attribute = "${node.datacenter}"
}
Suggest onto different hardware
14. job "blog" {
datacenters = ["aws"]
type = "service"
group "hugo" {
count = 2
Spread {
attribute = "${meta.rack}"
target "his" {
percent = 50
}
target "her" {
percent = 50
}
}
Based on custom meta-data
15. service {
name = âblog"
provider = "nomad"
port = âhttp"
}
Service Definition
16. template {
data = <<EOH
http {
server {
listen 80;
location / {
{{ range nomadService âblog" }}
proxy_pass http://{{ .Address }}:{{ .Port }};
{{ end }}
}
}
}
EOH
destination = "local/api-servers"
Service Usage
17. Nomad Pack
⢠Levant
⢠Templating and packaging tool
⢠Easily deploy popular applications to Nomad
⢠Re-use common patterns across internal applications
⢠Find and share job specifications with the Nomad community
⢠Nightlies only right now!
https://github.com/hashicorp/nomad-pack-community-registry
18. Nomad Pack
⢠nomad-pack registry list
⢠nomad-pack run hello_world
⢠nomad-pack run hello_world --var message=hola
https://github.com/hashicorp/nomad-pack
31. kind = "service-router"
name = "blog"
routes = [
{
match {
http {
header = [
{
name = "group"
exact = "test"
}, ] } }
destination {
service = "blog"
service_subset = "v2"
} },]
Consul to the rescue
32. â 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
33. â 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