Chuyển tới nội dung chính

Script task runners

A script task runs its commands in a container. The taskRunner property on the task says where that container runs. This page lists the runners egret has, the runner properties it honours, and the ones it refuses and why.

Documented from the source

Script tasks need a container runner, and the Docker demo stack has none, so none of the behaviour below can be tried on it. It is documented from the engine's source. See What runs on the Docker demo stack.

Choosing a runner​

- id: report
type: io.kestra.plugin.scripts.python.Script
containerImage: python:3.12-slim
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
memory:
memory: 512m
script: |
print("hello from a container")
taskRunner.typeRuns the taskStatus
io.kestra.plugin.scripts.runner.docker.DockerIn a Docker container, through the docker CLI.Works where workflow.container_runner is docker.
io.kestra.plugin.ee.kubernetes.runner.KubernetesIn a Kubernetes pod.Works where workflow.container_runner is kubernetes.
io.kestra.plugin.core.runner.Process—Refused when you save. It would run the commands inside the egret server itself; the message names the Docker and Kubernetes runners instead.

When taskRunner is absent the task uses the deployment's configured runner. The deprecated runner: DOCKER / runner: KUBERNETES key is accepted as an alias for taskRunner.type.

Asking for a runner the deployment is not configured for is refused with a message that names the configured one.

targetOS​

targetOS accepts LINUX and AUTO (both no-ops: egret runs every task in a Linux container). WINDOWS is refused with targetOS 'WINDOWS' is not supported by egret: it runs tasks in Linux containers, and any other value with 'targetOS' accepts 'LINUX' or 'AUTO'.

The Docker runner​

The Docker runner honours the resource knobs below. The rest of the cpu and memory groups (cpu.cpus, memory.memory) and shmSize work as in Kestra; these are the ones package #17a added:

PropertyWhat it does
memory.memorySwapTotal memory + swap the container may use.
memory.memoryReservationThe soft memory limit.
memory.memorySwappinessA whole number from 0 to 100.
memory.oomKillDisableDo not kill the container when it is out of memory. Requires memory.memory.
shmSizeThe size of /dev/shm.
killGracePeriodHow long a killed container is given to stop before it is forced.

Sizes use Docker's spelling (512m, 2g, a bare number is bytes).

Host support for two knobs

memorySwappiness and oomKillDisable are passed to docker create as you set them, but the host decides whether they take effect: on a cgroup v2 host (such as Docker Desktop) Docker accepts and then discards them. The container still runs; the two values have no effect there.

Operator resource caps​

An operator can cap what a task may ask for with workflow.docker.max_resources, in the same shape as the Kubernetes cap. Set any of its fields as environment variables or in egret.toml:

FieldCaps
cpuscpu.cpus
memorymemory.memory
memory_swapmemory.memorySwap
memory_reservationmemory.memoryReservation
shm_sizeshmSize
EGRET_WORKFLOW__DOCKER__MAX_RESOURCES__MEMORY=2g
EGRET_WORKFLOW__DOCKER__MAX_RESOURCES__CPUS=2

A task value above a cap is lowered to the cap when the container is created, never refused; a value below it, and a cap left unset, are untouched, so a deployment that sets no cap behaves exactly as before. A malformed cap, or a memory_swap cap below the memory cap, stops the Docker runner from starting.

Refused Docker properties​

These are refused when you save, each with a reason. They are kept refused by design, not pending work.

PropertyWhy
privilegedIt would give the task full control of the host.
userIt can run the task as any uid, root included; egret controls the identity a task runs as.
volumesA host bind mount is full access to the host filesystem.
hostIt would repoint the worker at another Docker daemon.
networkModeHost and container modes break network isolation.
extraHostsIt can alias internal names (SSRF, host.docker.internal).
deviceRequestsIt passes host devices and GPUs through to the task.
portBindingsIt publishes host ports, which a batch task has no use for.
config, credentialsRegistry credentials and daemon configuration are the operator's, not the author's.
entryPointEgret spends the container entrypoint on the script interpreter.
fileHandlingStrategyEgret stages files with docker cp, never a bind mount or a named volume.
wait, resumeAn egret run always attaches to the attempt's container by name and collects its outputs.
kernelMemoryRemoved in current Docker; it cannot be honoured.

The Kubernetes runner​

The Kubernetes runner accepts pullPolicy (ALWAYS, IF_NOT_PRESENT, NEVER), resources and delete. A WorkingDirectory that groups script tasks now runs on Kubernetes as well as on Docker: the files staged into the working directory, and the files a task leaves there, are carried to and from the pod.

The pod's identity, placement and security come from the operator's workflow.kubernetes.* settings, not from the task. These properties are refused when you save, each saying it is set by the operator:

namespace, serviceAccountName, nodeSelector, tolerations, affinity, hostNetwork, hostPath, securityContext, privileged, priorityClassName, volumes.

Any other property the Kubernetes runner does not know is refused as well; it accepts only pullPolicy, resources and delete.

Python dependencies​

A Python script task can install packages before it runs with dependencies, a list of pip requirement strings:

- id: report
type: io.kestra.plugin.scripts.python.Script
containerImage: python:3.12-slim
dependencies:
- requests==2.32.3
- pandas
script: |
import requests, pandas

Egret installs them with pip into the task's working directory and puts that directory on PYTHONPATH. The index it installs from is the operator's workflow.python_index_url, the public PyPI (https://pypi.org/simple) by default:

EGRET_WORKFLOW__PYTHON_INDEX_URL=https://nexus.internal/repository/pypi/simple

It must be an http:// or https:// URL with a host and no credentials; a bad value stops the worker from starting.

The other Python package properties are refused when you save:

PropertyWhy
packageManagerEgret installs dependencies with pip only.
pythonVersionPin the Python version through the task's containerImage.
dependencyCacheEnabledEgret runs one container an attempt, so there is nothing to cache between runs.
uvAutoInstallEnabled, uvInstallerVersion, uvInstallerSha256Fetching the uv binary at run time is a supply-chain decision egret does not make for you.

Output file patterns​

A script task's outputFiles are shell-style glob patterns matched against the files the task leaves behind. Egret supports *, ?, ** (any depth), a character class ([abc], a range [a-z], a negation [!a-z]) and a trailing directory wildcard. A brace list ({a,b}), an escaped character (\x) and an unterminated class ([a) are refused when you save, naming the pattern — these are a later package. The same patterns work on Docker and Kubernetes.

Limits and known issues​

  • None of this runs on the Docker demo stack: it has no container runner.
  • memorySwappiness and oomKillDisable are discarded by a cgroup v2 host.
  • Brace, escape and unterminated-class glob patterns in outputFiles are refused.

Further reading​