Created
October 22, 2019 09:49
-
-
Save electric380v/ed2630cb95d7880a59050e12ed4a448a to your computer and use it in GitHub Desktop.
nomad_sample_job.sublime-snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<tabTrigger>nomad-docker-service</tabTrigger> | |
<content><![CDATA[ | |
# 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" {} | |
} | |
} | |
} | |
} | |
} | |
]]></content> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment