Skip to content

Instantly share code, notes, and snippets.

@ThomasObenaus
Created January 6, 2019 17:13
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/e79e56814d90b755123a9194272f8131 to your computer and use it in GitHub Desktop.
Save ThomasObenaus/e79e56814d90b755123a9194272f8131 to your computer and use it in GitHub Desktop.
'.source.hcl':
'NomadDockerJobSrv':
'prefix': 'nomad-docker-service'
'body': """
# https://www.nomadproject.io/docs/job-specification/job.html
job \"${1:service-name}\" {
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:service-name}\" {
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:service-name}\" {
driver = \"docker\"
config {
image = \"${4:reponame}:latest\"
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:service-name}\"
port = \"http\"
tags = [\"urlprefix-/${1:service-name} strip=/${1:service-name}\"] # fabio
check {
name = \"${1:service-name} 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