Skip to main content

Services

Services are much like Runnables but they don't define any containers and associated lifecycle sections. Services are meant to be an abstract counterpart of Runnables that defines 3rd party services existing outside of Monk control. They can be useful for representing external APIs together with associated state, actions and variables.

Services can be composed with other Services and Runnables to form Groups.

Minimal example

runnable.yaml
namespace: reference

example-runnable:
defines: runnable

containers:
defines: containers
utils:
image: amouat/network-utils
image-tag: latest
entrypoint: sleep 36000

This example shows a runnable example-runnable inside a namespace reference. At minimum, a valid runnable must have a containers sub-section containing at least one container.

Sub-sections

Runnable sections can have multiple sub-sections of special meaning. All definitions applicable inside a runnable are described below.

containers

containers:
defines: containers
container-a: ...
container-b: ...
info

Applicable to: runnable

Required: yes

Containers section is a map of container, each container is named by its key (container-a, container-b in above example). Names can be any valid YAML key.

container

container-name:
image: string
image-tag: string
entrypoint: container entrypoint
bash: shell command to run
workdir: container working directory
environment:
- list of environment variables
ports:
- list of public port mappings
paths:
- list of paths to mount
labels:
- list of labels
info

Applicable to: containers

Required: at least one

FieldValuePurposeRequired
imagealpine, alpine:latest, gcr.io/someimageA container image to runyes
image-taglatest, v2Image tag, will override the one in image if present.only when no tag in image
entrypointrun.sh --someoptionContainer entrypoint, will override the image's entrypoint.no
bashrm /app/cacheA shell command to run upon container start.no
portslist of: 8080, 8080:9090, 0.0.0.0:8080:9090A list of ports to bind and publish to the internet.no
pathslist of: host/path:container/pathA list of filesystem paths to bind.no
labelslist of: "com.example.description=Accounting webapp"A list of container labels.no

variables

variables:
defines: variables
variable-a: ...
variable-b: ...
info

Applicable to: runnable

Required: no

Variables section is a map of variable, each container is named by its key (variable-a, variable-b in above example). Names can be any valid YAML key.

::info

These variables are not environment variables - they live on Monk's control plane. Use env to bind them to environment variables if you need.

:::

variable

variable-name:
type: variable type
value: variable value
env: environment variable to bind to

variable-name: variable value
info

Applicable to: variables

Required: at least one

A variable can either just specify the value - in which case the type is inferred automatically, or specify its type and value.

FieldValuePurposeRequired
typeone of: string, int, floatType of the variableyes
valueanythingInitial value of the variableyes
envVAIRABLE_NAMEName of environment variable that will receive the variable's value in all containersno

actions

variables:
defines: actions
action-a: ...
action-b: ...
info

Applicable to: runnable

Required: no

Action section is a map of action, each container is named by its key (action-a, action-b in above example). Names can be any valid YAML key.

action

action-name:
description: action description
arguments:
arg-a:
type: argument type
description: argument description
default: argument default value
arg-b: ...
code: Arrow script code
info

Applicable to: actions

Required: yes

Actions are somewhat akin to function definitions known from regular programming languages. They are specified by name, list of arguments and code to be executed upon calling the action. action specifies its code using Arrow script syntax but without <- as the code is constant here.

FieldValuePurposeRequired
descriptionhuman readable stringHuman readable description of the action. MonkHub displays these.yes
codeArrow script codeCode for the action, notice that the <- prefix is not neededyes
argumentsmap of argumentsSpecifies action's expected arguments. See the table belowno

argument

FieldValuePurposeRequired
descriptionhuman readable stringHuman readable description of the argument. MonkHub displays these.yes
typeone of: string, int, floatType of the argumentyes
defaultanythingValue of the argument used when it is not specified during callno

Example

actions:
defines: actions

sum:
description: sums two numbers
arguments:
a:
type: int
description: first number
b:
type: int
description: second number
add-one:
type: bool
description: add 1 to result
default: false # if default is not set, the argument is required
code: $args["a"] $args["b"] add $args["add-one"] add
Rate this page