Skip to content

Instantly share code, notes, and snippets.

@pars3c
Last active March 24, 2020 20:17
Show Gist options
  • Save pars3c/f8dd266ca5b57aee2ef8abf9237869c6 to your computer and use it in GitHub Desktop.
Save pars3c/f8dd266ca5b57aee2ef8abf9237869c6 to your computer and use it in GitHub Desktop.
Job Specifications
# Name of your job
job "my_job" {
# Which region are you running your job
datacenters = ["dc1"]
/*
Job type can be "service", "batch" or "system".
A "service" job is made for long lived services that should never go down,
Service jobs are made to run until explicitly stopped by the operator.
A "batch" job is made for short lived operations which can last
from a couple of minutes to a few days.
Batch schedulers are very similar to Service schedulers but with a few optimizations,
for the batch workload.
Batch jobs are intended to run until the job is successful, if the Batch task
exits with an error it will be handled according to the job's restart
and reschedule stanzas.
A "system" job is made for registering jobs that should be run on every client,
that has job's constraints.
The system job is also used when clients join the cluster or transition into the,
ready state.
*/
type = "service"
# Group represents the same of what a pod is in k8s
group "web" {
count = 1
task "frontend" {
# The driver used to manage the containers
driver = "docker"
config {
# Image we want to pull
image = "aderito/react-app"
# Define the mapped port
port_map = {
frontendPort = 3000
}
}
# Set the computing resources for this task
resources {
cpu = 500 # MHz
memory = 128 # MB
network {
mbits = 10
port "frontendPort" {
# Set the port that will bridge our orchestration with the container port
static = "3000"
}
}
}
}
task "backend" {
# The driver used to manage the containers
driver = "docker"
config {
# Image we want to pull
image = "aderito/express-app"
# Define the mapped port
port_map = {
backendPort = 9000
}
}
# Set the computing resources for this task
resources {
cpu = 500 # MHz
memory = 128 # MB
network {
mbits = 10
port "backendPort" {
# Set the port that will bridge our orchestration with the container port
static = "9000"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment