Resource: dcos_job
Provides a resource creating metronome jobs on DC/OS.
Should be used together with dcos_job_schedule
.
Example Usage
# an example
provider "dcos" {
cluster = "my-cluster"
}
resource "dcos_job" "job" {
name = "testjob"
cmd = "echo foo"
cpus = 1
mem = 64
disk = 0
user = "root"
description = "the best description ever"
max_launch_delay = 600
docker {
image = "ubuntu:latest"
}
placement_constraint {
attribute = "host"
operator = "LIKE"
}
env {
key = "my_env_key"
secret = "secret1"
}
env {
key = "cool_key"
value = "cool_value"
}
secrets {
secret1 = "/something"
cool_secret = "something_else"
}
restart {
active_deadline_seconds = 120
policy = "NEVER"
}
artifacts {
uri = "http://downloads.mesosphere.com/robots.txt"
extract = false
executable = true
cache = false
}
volume {
container_path = "/mnt/test"
host_path = "/dev/null"
mode = "RW"
}
}
resource "dcos_job_schedule" "jobsched" {
dcos_job_id = "${dcos_job.job.name}"
name = "someschedule"
cron = "0,30 * * * *"
}
Argument Reference
The following arguments are supported
ucr
(Optional)image
(Required) The ucr repository image name.secrets
(Optional) Any secrets that are necessary for the jobplacement_constraint
(Optional)attribute
(Required) The attribute name for this constraint.operator
(Required) The operator for this constraint.value
(Optional) The value for this constraint.cpus
(Required) The number of CPU shares this job needs per instance. This number does not have to be integer, but can be a fraction.name
(Required) Unique identifier for the job.user
(Optional) The user to use to run the tasks on the agent.description
(Optional) A description of this job.labels
(Optional) Attaching metadata to jobs can be useful to expose additional information to other services.args
(Optional) An array of strings that represents an alternative mode of specifying the command to run. This was motivated by safe usage of containerizer features like a custom Docker ENTRYPOINT. Eithercmd
orargs
must be supplied. It is invalid to supply bothcmd
andargs
in the same job.env
(Optional) Environment variableskey
(Required) The key/name of the variablevalue
(Required) The value of the key/namesecret
(Optional) The name of the secret.restart
(Optional) Defines the behavior if a task fails.active_deadline_seconds
(Optional) If the job fails, how long should we try to restart the job. If no value is set, this means forever.policy
(Required) The policy to use if a job fails. NEVER will never try to relaunch a job. ON_FAILURE will try to start a job in case of failure.mem
(Required) The amount of memory in MB that is needed for the job per instance.cmd
(Optional) The command that is executed. This value is wrapped by Mesos via/bin/sh -c ${job.cmd}
. Eithercmd
orargs
must be supplied. It is invalid to supply bothcmd
andargs
in the same job.artifacts
(Optional)cache
(Optional) Cache fetched artifact if supported by Mesos fetcher module.uri
(Required) URI to be fetched by Mesos fetcher module.executable
(Optional) Set fetched artifact as executable.extract
(Optional) Extract fetched artifact if supported by Mesos fetcher module.docker
(Optional)image
(Required) The docker repository image name.volume
(Optional)container_path
(Required) The path of the volume in the container.host_path
(Required) The path of the volume on the host.mode
(Required) Possible values are RO for ReadOnly and RW for Read/Write.secret
(Optional) Allow for volume secrets if using UCR.disk
(Optional) How much disk space is needed for this job. This number does not have to be an integer, but can be a fraction.max_launch_delay
(Optional) The number of seconds until the job needs to be running. If the deadline is reached without successfully running the job, the job is aborted.
Attributes Reference
addition to all arguments above, the following attributes are exported:
gid
(Optional) User ID to apply the grant on.