Skip to content

Instantly share code, notes, and snippets.

@ThomasObenaus
Last active January 24, 2019 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasObenaus/c52e85d8f774e29ae46d85389d2aedef to your computer and use it in GitHub Desktop.
Save ThomasObenaus/c52e85d8f774e29ae46d85389d2aedef to your computer and use it in GitHub Desktop.
# -*- mode: snippet -*-
# name: Nomad job file
# key: nomad
# Generation of a basic nomad job file
# --
# https://www.nomadproject.io/docs/job-specification/job.html
job "$1" {
datacenters = ["${2:public-services}"]
type = "service"
# https://www.nomadproject.io/docs/job-specification/reschedule.html
reschedule {
delay = "30s"
delay_function = "constant"
unlimited = true
}
# https://www.nomadproject.io/docs/job-specification/update.html
update {
max_parallel = 1
health_check = "checks"
min_healthy_time = "10s"
healthy_deadline = "5m"
progress_deadline = "10m"
auto_revert = true
canary = 0
stagger = "30s"
}
# https://www.nomadproject.io/docs/job-specification/group.html
group "$1" {
count = ${3:1}
# https://www.nomadproject.io/docs/job-specification/restart.html
restart {
interval = "10m"
attempts = 2
delay = "15s"
mode = "fail"
}
# https://www.nomadproject.io/docs/job-specification/task.html
task "$1" {
driver = "docker"
config {
image = "{{ecr_url}}/service/$4/$1:{{version}}"
port_map = {
http = ${5:8080}
}
}
# https://www.nomadproject.io/docs/job-specification/env.html
env {}
# https://www.nomadproject.io/docs/job-specification/service.html
service {
name = "$1"
port = "http"
tags = ["urlprefix-/$1 strip=/$1"]
check {
name = "$1 health using http endpoint '/health'"
port = "http"
type = "http"
path = "/health"
method = "GET"
interval = "10s"
timeout = "2s"
}
# https://www.nomadproject.io/docs/job-specification/check_restart.html
check_restart {
limit = 3
grace = "10s"
ignore_warnings = false
}
}
# https://www.nomadproject.io/docs/job-specification/resources.html
resources {
cpu = 100 # MHz
memory = 256 # MB
# https://www.nomadproject.io/docs/job-specification/network.html
network {
mbits = 10
port "http" {}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment