This reference document is a field-by-field listing of the YAML schema used for Service Specifications. For an example of a real-world YAML Service Spec, see the svc.yml for hello-world. For several smaller examples, see the SDK Developer Guide.
This documentation effectively reflects the Java object tree under RawServiceSpec, which is what’s used as the schema to parse YAML Service Specifications. What follows is a field-by-field explanation of everything within that tree. For more information about service development in general, see the SDK Developer Guide.
Fields
- 
    
nameThe name of the service. This is used both for the Marathon app name for the scheduler, as well as for the Mesos framework name for the service tasks.
 - 
    
web-urlWhere requests should be sent when a user goes to
http://theircluster.com/service/<name>to view the service. By default this will go to the scheduler API endpoints. If you wish to expose additional custom endpoints via this URL, you should consider configuring Reproxy in your service so that the scheduler API endpoints are still available. - 
    
schedulerThis section contains settings related to the scheduler and its interaction with the cluster. All of these settings are optional, reasonable defaults are used if they are not manually provided.
- 
        
principalThe Mesos Principal to register as. Default is
<name>-principal. - 
        
zookeeperCustom zookeeper URL for storing scheduler state. Defaults to
master.mesos:2181. - 
        
userThe system user to run the service’s scheduler and pods as, with default
rootif unspecified. Availability of usernames depends on the cluster. In DC/OS Enterprise, if the security mode is set to strict, the service account used by the service must have permissions to launch tasks as the assigned user. 
 - 
        
 - 
    
podsThis section contains a listing of all pod types managed by the service.
- 
        
resource-setsResource sets allow defining a single set of resources to be reused across multiple tasks, where only one task may use the resource set at a time. This can be useful when defining maintenance operations. A single resource set can be created, and then assigned to multiple operations such as backup, restore, rebuild, etc… In this scenario, only one operation may be active at a time, as that task has ownership of the resource set.
- 
            
cpus,gpus,memory,ports,volume/volumesThese resource values are identical in meaning to their sister fields in a task definition. However, see above discussion about these resources only being used by one task at a time.
 
 - 
            
 - 
        
placementAny additional constraints to be applied when deciding where to deploy this pod. This field supports all Marathon placement operators. For example,
[["hostname", "UNIQUE"]]ensures that at most one pod instance is deployed per agent. This value may be exposed to end users via mustache templating to allow customizing placement of the service within their own environment. - 
        
countThe number of pods of this type to be deployed. This may either be hardcoded or exposed to end users via mustache templating. This value may always be increased after the service has been deployed, but it can only be decreased if
allow-decommissionistrue. - 
        
allow-decommissionWhether to allow this pod’s
countto be decreased by an operator in a configuration update. For safety reasons this defaults tofalse, but the service developer may set this field totrueto explicitly allow scale-down on a per-pod basis. - 
        
imageThe docker image to use for launching the pod, of the form
user/img:version. The image may either be in public Docker Hub, or in a custom Docker Registry. Any custom Docker Registry must have been configured in the DC/OS cluster to work. To ensure a lack of flakiness, docker images are only executed by Mesos’ Universal Container Runtime, neverdockerd. If this is unspecified, then a sandboxed directory on the system root is used instead.You do not have to specify an image if the service uses static binaries or an environment like the JVM to handle any runtime dependencies, but if your application requires a custom environment and/or filesystem isolation then you should probably specify an image here.
 - 
        
rlimitsThis section may be used to specify rlimits that need to be configured (by Mesos) before the container is brought up. One or more rlimit values may be specified as follows:
rlimits: RLIMIT_AS: // unlimited when 'soft' and 'hard' are both unset RLIMIT_NOFILE: soft: 128000 hard: 128000 - 
        
secretsThis section list the Secrets that will be made available to the pod. The content of a Secret may be exposed as a file and/or as a environment variable. If Secret content is changed, relevant pod needs to be restarted, so it can update new content from the Secret store.
- 
            
secretThe path of a Secret. This setting would typically be configurable by service users as it must match what path the administrator used in the DC/OS Secrets UI.
 - 
            
env-keyName of the environment variable to expose the Secret content against. This may be left unset if the secret shouldn’t be provided as an environment variable.
 - 
            
fileA path within the container to copy the Secret content into. The Secret file is a tmpfs file; it disappears when executor exits.
 
 - 
            
 - 
        
networksAllows the pod to join any number of virtual networks on the DC/OS cluster. One kind of virtual network that is supported at present is the
dcosoverlay network. To have the pod join a virtual network (thedcosoverlay network in this case) add the following to its YAML specification:networks: dcos:Pods on virtual networks have the following effects:
- The pod receives its own IP address from the subnet of the virtual network belonging to the agent where the pod is deployed. The IP can be retrieved using the DNS 
<task_name>.<framework_name>.autoip.dcos.thisdcos.directory. This DNS will also work for pods on the native host network. - The 
portsresource requirements will be ignored (i.e. the agent does not need to have these ports available) because the pod has its own IP address. - Once the pod is on a virtual network, you cannot move it to the host network. This is disallowed because the ports may not be available on the agent that has the rest of the task's reserved resources.
 
For more information see the DC/OS Virtual Network documentation.
 - The pod receives its own IP address from the subnet of the virtual network belonging to the agent where the pod is deployed. The IP can be retrieved using the DNS 
 - 
        
urisA list of uris to be downloaded (and automatically unpacked) into the
$MESOS_SANDBOXdirectory before launching instances of this pod. It is strongly recommended that all URIs be templated out and provided as scheduler environment variables. This allows field replacement in the case of running an offline cluster without internet connectivity.If you’re using a Docker image (specified in the
imagefield), these bits should ideally be already pre-included in that image, but separate downloads can regardless be useful in some situations.If you wish to use
configsin your tasks, this needs to include a URI to download thebootstrapexecutable. - 
        
volume/volumesOne or more persistent volumes to be mounted into the pod environment. These behave the same as volumes on a task or resource set, but are guaranteed to be shared between tasks in a pod. Although volumes defined on a task currently behave the same way, individual tasks will not be able to access volumes defined by another task in the future.
 - 
        
pre-reserved-roleEnsures that this pod only consumes resources against a role which has already been statically assigned within the cluster. This is mainly useful for placing pods within a predefined quota, or otherwise assigning them a specific set of resources. For example, DC/OS clusters have a convention of using the
slave_publicrole for machines which are not firewalled. Pods which have theirpre-reserved-roleset toslave_publicwill be placed on those machines so that they are visible outside the cluster. - 
        
share-pid-namespaceWhether the tasks within this pod should share the same process id namespace (
true), or whether pid namespaces should be distinct for every task in the pod (false). Default isfalse. - 
        
tasksThis section lists the tasks which run within a given pod. All tasks share the same pod environment and resources. Resources may be more granularly allocated on a per-task basis in the future.
- 
            
goalThe goal state of the task. Must be either
RUNNING,FINISHorONCE:RUNNING: The task should launch and continue running indefinitely. If the task exits, the entire pod (including any other active tasks) is restarted automatically. To demonstrate, let’s assume a running instance thehello-worldservice on your DC/OS cluster. We’ll be updating the configuration of thehello-0pod and verifying that thehello-0-servertask with goal stateRUNNINGis restarted and stays running. First, we verify that the deploy plan has completed:$ dcos hello-world plan show deploy deploy (COMPLETE) ├─ hello (COMPLETE) │ └─ hello-0:[server] (COMPLETE) ...Now we take note of the ID of the
hello-0-servertask:$ dcos task NAME HOST USER STATE ID MESOS ID REGION ZONE hello-0-server 10.0.3.117 nobody R hello-0-server__46cf0925-9287-486b-83d7-7ffc43523671 61eee73c-b6a5-473c-990d-4bc8051cbd82-S4 us-west-2 us-west-2c ...Next, we update the amount of CPU being used by the
servertask in thehellopod type:$ echo '{"hello": {"cpus": 0.2}}' > options.json $ dcos hello-world update start --options=options.jsonAfter waiting for the update to complete and all tasks to be relaunched, we check the list of running tasks once again to verify that the
hello-0-serverstep is complete, that the task was restarted (which we’ll determine by verifying that it has a different task ID) and that it’s still running:$ dcos hello-world plan show deploy deploy (COMPLETE) ├─ hello (COMPLETE) │ └─ hello-0:[server] (COMPLETE) ... $ dcos task NAME HOST USER STATE ID MESOS ID REGION ZONE hello-0-server 10.0.3.117 nobody R hello-0-server__3007283c-837d-48e1-aa0b-d60baead6f4e 61eee73c-b6a5-473c-990d-4bc8051cbd82-S4 us-west-2 us-west-2cFINISH: The task should launch and exit successfully (zero exit code). If the task fails (nonzero exit code) then it is retried without relaunching the entire pod. If that task’s configuration is updated, it is rerun. To demonstrate, let’s assume that we’ve now launched hello-world with thefinish_state.ymlspecfile, like so:$ echo '{"service": {"spec_file": "examples/finish_state.yml"}}' > options.json $ dcos package install --yes hello-world --options=options.jsonOnce again, we wait for the deploy plan to complete, as above, and take note of the ID of the
world-0-finishtask (this time using the--completedflag, since the task has run to completion):$ dcos task --completed NAME HOST USER STATE ID MESOS ID REGION ZONE ... world-0-finish 10.0.0.232 nobody F world-0-server__955a28c2-d5bc-4ce4-a4e9-b9603784382e 61eee73c-b6a5-473c-990d-4bc8051cbd82-S3 us-west-2 us-west-2c ...Now we update the amount of CPU being used by the
finishtask in theworldpod type:$ echo '{"world": {"cpus": 0.2}}' > options.json $ dcos hello-world update start --options=options.jsonAfter waiting for the update to complete, we check the task list again and this time see two completed entries for
world-0-finish, showing that the configuration update has caused it to run to completion again:$ dcos task --completed NAME HOST USER STATE ID MESOS ID REGION ZONE ... world-0-finish 10.0.0.232 nobody F world-0-finish__955a28c2-d5bc-4ce4-a4e9-b9603784382e 61eee73c-b6a5-473c-990d-4bc8051cbd82-S3 us-west-2 us-west-2c world-0-finish 10.0.3.117 nobody F world-0-finish__bd03efc2-26a0-4e36-a332-38159492557e 61eee73c-b6a5-473c-990d-4bc8051cbd82-S4 us-west-2 us-west-2c ...ONCE: The task should launch and exit successfully (zero exit code). If the task fails (nonzero exit code) then it is retried without relaunching the entire pod. If that task’s configuration is updated, it will not be rerun. To demonstrate, let’s assume that this time we’ve launched hello-world with thediscovery.ymlspecfile, like so:</li>$ echo '{"service": {"spec_file": "examples/discovery.yml"}}' > options.json $ dcos package install --yes hello-world --options=options.jsonAgain we wait for the deploy plan to complete and take note of the ID of the
hello-0-oncetask, using the--completedflag since that task has run to completion:$ dcos task --completed NAME HOST USER STATE ID MESOS ID REGION ZONE ... hello-0-once 10.0.3.117 nobody F hello-0-once__8f167b23-48c8-4ea9-8559-4cf95a3703ae 61eee73c-b6a5-473c-990d-4bc8051cbd82-S4 us-west-2 us-west-2c ...Now we update the amount of CPU being used by both tasks in the
hellopod type:$ echo '{"hello": {"cpus": 0.2}}' > options.json $ dcos hello-world update start --options=options.jsonAfter waiting for deployment to complete, we check the task list and find that
hello-0-onceonly appears one time, indicating that the configuration update did not cause it to rerun:$ dcos task --completed NAME HOST USER STATE ID MESOS ID REGION ZONE ... hello-0-once 10.0.3.117 nobody F hello-0-once__8f167b23-48c8-4ea9-8559-4cf95a3703ae 61eee73c-b6a5-473c-990d-4bc8051cbd82-S4 us-west-2 us-west-2c ...
 - 
            
essentialMarks this task as either “Essential”, where task failure results in relaunching all tasks in the pod as a unit, or “Non-essential”, where task failure results in only relaunching this task and leaving other tasks in the pod unaffected. By default this value is
true, such that the failure of the task will result in relaunching all tasks in the pod. This is only applicable in cases where a given pod has multiple tasks with a goal state ofRUNNINGdefined. - 
            
cmdThe command to be run by the task, in the form of a shell script. This script may execute any executables that are visible within the pod environment.
If you wish to use
configsin this task, thecmdneeds to run thebootstrapexecutable. For example:./bootstrap && ./your/exe/here - 
            
envA listing of environment variables to be included in the
cmdruntime. If you’re using config templates usingbootstrap, this section must be populated with any relevant template values.For convenience, the following environment variables are automatically provided to all tasks:
TASK_NAME: The name of the task, of the form<pod>-<#>-<task>. For example:mypod-0-node.FRAMEWORK_NAME: The name of the service.FRAMEWORK_HOST: The host domain for pods on the service. For example, the full hostname for a task would be[TASK_NAME].[FRAMEWORK_HOST].FRAMEWORK_VIP_HOST: The host domain for VIPs on the service. For example, the full hostname for a VIP would be[VIP_NAME].[FRAMEWORK_VIP_HOST].SCHEDULER_API_HOSTNAME: The hostname for the Scheduler HTTP API. For example, an endpoint on the scheduler would behttp://[SCHEDULER_API_HOSTNAME]/myendpoint.POD_INSTANCE_INDEX: The index of the pod instance, starting at 0 for the first instance.<TASK_NAME>=true: The task name as the envvar name, withtrueas the value.
 - 
            
configsThis section allows specifying config templates to be rendered by the
bootstrapexecutable, which must be invoked manually incmd. A common use case for DC/OS services is allowing end-users to customize the configuration of the service. This allows specifying arbitrary text templates which are automatically populated with that configuration. For example, say we had awebservertask with aconfig.yamllike the following:hostname: localhost port: 80 ssl: enabled: true key: /etc/ssl/priv.key cert: /etc/ssl/pub.cert # Default value when unset: #custom_404: 404 Not Found #custom_403: 403 Forbidden root: /var/wwwThe service developer can create a
config.yaml.mustachewhich templates out the options to be exposed to end users:hostname: {{TASK_NAME}}.{{FRAMEWORK_NAME}}.mesos // mesos-dns hostname for this task port: {{PORT_HTTP}} ssl: enabled: {{SSL_ENABLED}} key: /etc/ssl/priv.key // not customizable cert: /etc/ssl/pub.cert // not customizable {{#CUSTOM_404_MESSAGE}} custom_404: {{CUSTOM_404_MESSAGE}} {{/CUSTOM_404_MESSAGE}} {{#CUSTOM_403_MESSAGE}} custom_403: {{CUSTOM_403_MESSAGE}} {{/CUSTOM_403_MESSAGE}} root: {{ROOT_DIR}}And then the following settings would be manually added to the task’s
env. These env vars meanwhile would be provided automatically by the SDK:TASK_NAMEandFRAMEWORK_NAMEare included for free, as mentioned underenvabove.PORT_HTTPis the default advertised environment variable for a reserved port namedhttp, as mentioned underportsbelow.
env: SSL_ENABLED: {{WEB_SSL_ENABLED}} CUSTOM_404_MESSAGE: {{WEB_CUSTOM_404_MESSAGE}} CUSTOM_404_MESSAGE: {{WEB_CUSTOM_404_MESSAGE}} HTTP_ROOT: {{WEB_ROOT_DIR}}See the SDK Developer Guide more information on each of these files.
- 
                
templateThe source template file path within the scheduler environment to be downloaded into the task. Relative paths are interpreted as relative to the scheduler’s
$MESOS_SANDBOX. - 
                
destThe destination path within the task environment to place the rendered result. An absolute or relative path may be used. Relative paths are interpreted as relative to the task’s
$MESOS_SANDBOX. 
 - 
            
cpusThe number of CPUs to be reserved by this task. Fractional values (e.g.
1.5) are supported. If the task exceeds the reserved usage, it will be throttled and inconsistent performance may result. - 
            
gpusThe number of GPUs to be reserved by this task. Unlike with CPUs this cannot be a fractional value in practice. This is only supported in DC/OS 1.9+.
 - 
            
memoryThe amount of RAM (in MB) to be reserved by this task. If the task exceeds this amount, it will be forcibly restarted.
 - 
            
portsThe ports which your service will be using to accept incoming connections. Each port is given a unique name across the service, and this name is what’s used to advertise that port in the
endpointslisting. Ports may be defined a task as follows:ports: http-api: port: 0 # use a random port advertise: true # advertise the port in service endpoint lookups vip: port: 80 # create a VIP debug: port: 9090 env-var: DEBUG_PORT # advertise DEBUG_PORT=9090 in task envAll ports are reserved against the same interface that Mesos uses to connect to the rest of the cluster. In practice you should only use this interface as well. Surprising behavior may result if you use a different interface than Mesos does. For example, imagine dealing with a situation where Mesos loses connectivity on
eth0, but your service is still connected fine overeth1. Or vice versa.It’s worth noting that port reservations in DC/OS are technically honor-system at the moment. However, you should still reserve all the ports you intend to use. This is to ensure that Mesos doesn’t place your task on a machine where a port you need is already occupied. You must give Mesos enough information to find a place where all your required ports are available.
- 
                
portThe port to be reserved and used by the service. This may be set to
0to use a random port, which will be advertised via the task environment. - 
                
env-keyThis may be used to define an environment variable used to advertise this port within the task. This is most useful when a random dynamic port is being used, as it allows the task to know what port was allocated for it.
 - 
                
advertiseThis may be manually set to
trueto enable advertising this port in the service’sendpointslisting. Default isfalse. - 
                
vipThis section enables a Virtual IP (or VIP) address for this port. The VIP is effectively a highly-available hostname at which the task may be reached at an arbitrary advertised endpoint. Using VIPs is similar to using Mesos-DNS, except you have more control over the port used by others to connect to your service, without requiring users check SRV records like Mesos-DNS does. For example, you could run several web servers behind random ports (see above), but expose them all a single VIP endpoint at port
80.- 
                    
portThe ‘external’ port to use in the VIP.
 - 
                    
prefixThe name to put at the start of the VIP. For example,
httpwill result in a VIP hostname ofhttp.<servicename>.l4lb.thisdcos.directory. By default, the parent port’s name is used. 
 - 
                    
 
 - 
                
 - 
            
health-checkHealth checks are additional validation that your task is healthy, in addition to just the fact that its process is still running. This is an extra convenience for sitations where a service can enter a zombie state from which it can never return. For example, it might query an HTTP endpoint to validate that an HTTP service is still responding.
- 
                
cmdThis is the command to run in the health check. It will be run in the same environment as the task itself, but any envvars which are assigned within the task’s
cmdwill not appear here. If the command exits with code0, then the health check is considered successful. Otherwise it failed. - 
                
intervalThe period in seconds to wait after the last check has completed to start the next check.
 - 
                
grace-periodAn initial amount of time in seconds to ignore failed health checks.
 - 
                
max-consecutive-failuresThe number of consecutive health check failures which are allowed before the task is restarted. An unset value is treated as equivalent to no retries.
 - 
                
delayAn amount of time in seconds to wait before starting the readiness check attempts. This delay is triggered once the task has started running.
 - 
                
timeoutAn amount of time in seconds to wait for a health check to succeed. If all health checks continuously fail for the timeout duration, the task is restarted (and its persistent volumes will persist).
 
 - 
                
 - 
            
readiness-checkReadiness checks are similar in implementation to health checks, but they are only run when the task is first coming up. Readiness checks allow the service to expose when a given task has completed some initialization process, as opposed to just exposing that the process is running. If a readiness check is defined, the scheduler will wait until this check passes before attempting to launch another task. Unlike with health checks which are only really needed in specific cases, readiness checks are frequently useful for ensuring that process health during startup accurately represents the internals of the service, and to give the scheduler an opportunity to automatically restart a task if initialization is taking too long.
- 
                
cmdThis is the command to run in the readiness check. It will be run in the same environment as the task itself, but any envvars which are assigned within the task’s
cmdwill not appear here. If the command exits with code0, then the health check is considered successful. Otherwise it failed. - 
                
intervalThe period in seconds to wait after the last check has completed to start the next check.
 - 
                
delayAn amount of time in seconds to wait before starting the readiness check attempts.
 - 
                
timeoutAn amount of time in seconds to wait for a readiness check to succeed. If all readiness checks continuously fail for the timeout duration, the task is restarted and initialization is reattempted.
 
 - 
                
 - 
            
volume/volumesOne or more persistent volumes to be mounted into the task environment. Any files placed within persistent volumes will survive a task being restarted, but will not survive a task being moved to a new machine.
volumeis a convenience syntax for specifying a task with a single volume.- 
                
pathWhere the persistent volume should be mounted in the task filesystem. A relative path will be placed relative to
$MESOS_SANDBOX. - 
                
typeTwo types are currently supported:
ROOTandMOUNT. Both behave the same in terms of persistence; the difference is mainly in how they perform and how they’re reserved:ROOTvolumes are against the root filesystem of the host system. In terms of performance they will share IO with the other users of that filesystem. In terms of reservations, the requested size is exactly what's obtained.MOUNTvolumes are separate partitions which the cluster administrator had mounted onto the host machine as/dcos/volumeN. These partitions will typically have their own dedicated IO/spindles, resulting in more consistent performance.MOUNTvolumes are reserved as a unit and are not shared across services. If a service requests a 1 GB volume and theMOUNTvolumes are all 100 GB, then the service is getting a 100 GB volume all to itself.
 - 
                
sizeThe required minimum size of the volume. See reservation semantics between
ROOTandMOUNTvolume types above. 
 - 
                
 - 
            
resource-setTasks may either be assigned independent resources via the
cpus,gpus,memory,ports, andvolume/volumesfields, or they may be assigned to a commonresource-setwhich was defined separately inresource-sets(see above). Not both. - 
            
discoveryThis may be used to define custom discovery information for the task, affecting how it’s advertised in Mesos DNS.
- 
                
prefixA custom name to use for advertising the pod via Mesos DNS. By default this is the pod name, so e.g. a pod specification named
foowill by default have pod with discovery names offoo-0,foo-1, and so on. This value may be used to have pods whose hostnames are Mesos DNS (default<podname>-<#>-<taskname>.<servicename>.mesos) is different from their task name. Note that to avoid name collisions, different pods are not allowed to share the same prefix value. - 
                
visibilityThe default visibility for the discovery information. May be
FRAMEWORK,CLUSTER, orEXTERNAL. If unset this defaults toCLUSTER. See Mesos documentation on service discovery for more information on these visibility values. 
 - 
                
 - 
            
transport-encryptionA task may optionally ask for a X.509 TLS certificate with private key and CA certificate bundle. A certificate can be used by service to enable secure communication.
- 
                
nameA name of files representing the TLS artifacts in the task sandbox directory. For example a
name: nginxwithtype: TLSwill result in$MESOS_SANDBOX/nginx.crt,$MESOS_SANDBOX/nginx.keyand$MESOS_SANDBOX/nginx.cafiles. - 
                
typeA type or format of delivered TLS artifacts. This can be set either to
TLSfor PEM encoded private key file, certificate and CA bundle orKEYSTOREfor certificate and private key to be delivered in a separate keystore file and CA bundle in other truststore file. 
For detailed information see the SDK Developer Guide.
 - 
                
 
 - 
            
 
 - 
        
 - 
    
plansThis section allows specifying custom deployment behavior, either by replacing the default
deployplan, replacing the defaultupdateplan (otherwisedeployis used for updates), and/or by adding new custom plans. This can be useful for overriding the default behavior, which is sequentially deploying all the tasks in the order that they were declared above. Plans are listed in this section by name, with the content of each Plan listing the Phases and Steps to be run within them. See the SDK Developer Guide for some examples and additional information on customizing Plans.- 
        
strategyHow the phases within a given plan should be deployed, either
serialorparallel. For example, aserialstrategy will ensure Phase 1 is only stared after Phase 0 is complete, while aparallelstrategy will start both Phase 0 and Phase 1 at the same time. - 
        
phasesThe list of Phases which compose a given Plan. In the canonical case of a deployment of separate
indexanddatanodes, a Phase would represent deploying all of one of those types of nodes.- 
            
strategyHow the steps within a given plan should be deployed. This may be any of
serial,parallel,serial-canary, orparallel-canary. The-canarystrategies will invoke the first step as a “trial”, and then wait for the operator to manually confirm that the “trial” step was successful and invoke aplan continuecall to continue the rollout. This may be useful in the case of deploying a configuration change to the cluster, where the first change is checked against a “canary” node before applying the rollout further. - 
            
podThe name of the pod (listed above) against which this phase will be invoked.
 - 
            
stepsThis section allows specifying non-default behavior for completing Steps. It may be used for e.g. defining custom init operations to be performed in the
deployplan, or for defining entirely custom plans for things like Backup and Restore. See the SDK Developer Guide for some examples and additional information on specifying custom steps. 
 - 
            
 
 -