-
Notifications
You must be signed in to change notification settings - Fork 22
Templates
On startup, Cluster Broccoli tries to read job templates from the templates directory. The default location is templates
, but it can be configured by setting broccoli.templates.storage.fs.path
.
The directory must contain one sub-directory for each template. These template directories contain a template for a Nomad job (template.json
) and an optional file with meta information (meta.json
).
templates
├── http-server
│ ├── meta.json
│ └── template.json
├── jupyter
│ └── template.json
└── zeppelin
├── meta.json
└── template.json
The template file is basically a Nomad job file in JSON format. In order to allow for customization (e.g. launching multiple instances of the same job with different names or settings), you can add parameters. A parameter is enclosed in two curly brackets ({{...}}
).
Each template has to have at least a parameterized job ID:
{
"Job": {
"Region": "global",
"ID": "{{id}}",
"Name": "{{id}}",
...
}
}
For your convenience you can write the job in HCL syntax and convert it using nomad run -output template.hcl > template.json
.
Currently you can provide two types of meta information about a template: A description and parameter information.
{
"description": "A simple Python HTTP request handler. This class serves files from the current directory and below, directly mapping the directory structure to HTTP requests.",
"parameters": {
"cpu": {
"default": "100",
"type": "raw"
},
"password": {
"secret": true,
"type": "string"
}
}
}
The description can be used to briefly describe your template. It will be shown in the user interface to explain what to expect when creating a new instance based on this template.
{
"description": "This is my great Broccoli template. Apply gently for extreme awesomeness!"
}
The template file usually contains different parameters. These parameters can have additional properties. Every parameter is required to have a type.
Parameters will be sorted in the UI based on their identifier (e.g. cpu
). If a parameter name is given (e.g. CPU Resources
, this one will be shown, otherwise the identifier is used.
{
"parameters": {
"cpu": {
"name": "CPU Resources"
}
}
}
In order to avoid having to fill all parameter values on instance creation you can provide default values.
{
"parameters": {
"cpu": {
"default": "100"
}
}
}
Sometimes you want parameters to be not visible to non-administrators. In this case you can mark a parameter as 'secret'.
{
"parameters": {
"password": {
"secret": true
}
}
}
Every parameter has to have a type. The parameter value will be rendered according to the type.
{
"parameters": {
"password": {
"type": "string"
}
}
}
The following parameter types are supported:
Type | Description | Input | Output |
---|---|---|---|
string |
Escape quotes to safely use inside JSON string. | {{x}} |
\"foo\" |
raw |
Insert the value without any conversion. Use with caution! | {{x}} |
"foo" |
integer |
32 bit precision integer number | {{x}} |
5 |
decimal |
64 bit precision double number | {{x}} |
10.5 |
In order to load new templates you can either restart Broccoli or send SIGURS2
, which will trigger a hot reload.
docker kill -s SIGUSR2 <broccoli-container-id>