-
-
Save zemm/dbf12775566bef26b0c49d19ed008143 to your computer and use it in GitHub Desktop.
Nomad Exec debug tasks for logging
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
locals { | |
script = <<EOH | |
i=0 | |
for i in $(seq 1 10); do | |
echo "${NOMAD_JOB_NAME}.${NOMAD_GROUP_NAME}.${NOMAD_TASK_NAME}[${NOMAD_ALLOC_INDEX}]" i=$i | |
sleep 2 | |
done | |
while true; do sleep 5; done | |
EOH | |
} | |
job "count-to-ten-1" { | |
datacenters = ["dc1"] | |
type = "service" | |
group "group-1" { | |
count = 1 | |
task "counter" { | |
driver = "exec" | |
config { | |
command = "/bin/sh" | |
args = ["-c", "${local.script}"] | |
} | |
resources { | |
cpu = 10 | |
memory = 16 | |
} | |
} | |
} | |
group "group-2" { | |
count = 1 | |
task "counter" { | |
driver = "exec" | |
config { | |
command = "/bin/sh" | |
args = ["-c", "${local.script}"] | |
} | |
resources { | |
cpu = 10 | |
memory = 16 | |
} | |
} | |
} | |
} |
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
locals { | |
script = <<EOH | |
i=0 | |
for i in $(seq 1 10); do | |
echo "${NOMAD_JOB_NAME}.${NOMAD_GROUP_NAME}.${NOMAD_TASK_NAME}[${NOMAD_ALLOC_INDEX}]" i=$i | |
sleep 2 | |
done | |
while true; do sleep 5; done | |
EOH | |
} | |
job "count-to-ten-2" { | |
datacenters = ["dc1"] | |
type = "service" | |
group "group" { | |
count = 3 | |
task "counter" { | |
driver = "exec" | |
config { | |
command = "/bin/sh" | |
args = ["-c", "${local.script}"] | |
} | |
resources { | |
cpu = 10 | |
memory = 16 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment