Last active
October 31, 2020 16:56
-
-
Save tcassaert/eb28c2e3e9869969a5e3721bc2b5f909 to your computer and use it in GitHub Desktop.
Template with common options needed in a Nomad job file
This file contains 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
job "" { | |
datacenters = ["global"] | |
type = "service" | |
group "" { | |
vault { | |
policies = [""] | |
} | |
constraint { | |
attribute = "" | |
value = "" | |
} | |
count = 1 | |
reschedule { | |
attempts = 10 // Attempt x times to reschedule | |
delay = "5s" // Wait x seconds to attempt rescheduling | |
delay_function = "fibonacci" // Increase the delay time with the fibonacci scale | |
interval = "24h" // Only try to reschedule for x time | |
max_delay = "1h" // Max time between attempts to reschedule | |
unlimited = false // Don't retry to reschedule an unlimited time | |
} | |
restart { | |
attempts = 3 // Maximum of x restarts | |
interval = "10m" // Maximum of x restarts in the past x minutes | |
delay = "15s" // Wait x seconds between each restart | |
mode = "fail" // Set as failed after x restarts | |
} | |
network { | |
port "" { to = } | |
} | |
task "" { | |
driver = "docker" | |
template { | |
data = <<EOF | |
EOF | |
destination = "local/env" | |
env = true | |
} | |
config { | |
image = "" | |
ports = [""] | |
volumes = [ | |
"", | |
] | |
} | |
resources { | |
cpu = 50 | |
memory = 50 | |
} | |
} | |
service { | |
address_mode = "host" | |
name = "" | |
port = "" | |
tags = [ | |
] | |
check { | |
name = "" | |
port = "" | |
type = "tcp" | |
interval = "10s" | |
timeout = "2s" | |
} | |
check_restart { | |
limit = 3 // 3 failed checks before restart | |
grace = "30s" // wait x seconds after restart to check again | |
ignore_warnings = false // Also treat warnings as a failed check | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment