docker build -t keptnsandbox/klc-runtime:${VERSION} .
The Keptn function runtime uses Deno
to execute Javascript/Typescript code.
The Keptn Lifecycle Toolkit uses this runtime to run KeptnTask
for pre- and post-checks.
The Keptn Lifecycle Toolkit passes parameters of KeptnTask
s and
Context information
to the runtime via the special environmental variable DATA
.
It also supports mounting Kubernetes secrets making them accessible via the SECURE_DATA
env var.
You can then read the data with the following snippet of code.
const data = Deno.env.get("DATA")!;
const secret = Deno.env.get("SECURE_DATA")!;
console.log(data);
console.log(secret);
KeptnTask
s can be tested locally with the runtime using the following command.
Replace ${VERSION}
with the KLT version of your choice.
docker run -v $(pwd)/test.ts:/test.ts -e SCRIPT=/test.ts -e DATA='{ "url":"http://localhost:9090" }' -e SECURE_DATA='{ "token": "myToken"}' -it ghcr.io/keptn/functions-runtime:${VERSION}
docker run \
-e SCRIPT=https://raw.githubusercontent.com/keptn/lifecycle-toolkit/main/functions-runtime/samples/ts/hello-world.ts \
-it \
keptnsandbox/klc-runtime:${VERSION}
docker run \
-e SCRIPT=https://raw.githubusercontent.com/keptn/lifecycle-toolkit/main/functions-runtime/samples/ts/scheduler.ts \
-e DATA='{ "targetDate":"2025-04-16T06:55:31.820Z" }' \
-it \
keptnsandbox/klc-runtime:${VERSION}
docker run \
-e SCRIPT=https://raw.githubusercontent.com/keptn/lifecycle-toolkit/main/functions-runtime/samples/ts/slack.ts \
-e SECURE_DATA='{ "slack_hook":"hook/parts","text":"this is my test message" }' \
-it \
keptnsandbox/klc-runtime:${VERSION}
docker run \
-e SCRIPT=https://raw.githubusercontent.com/keptn/lifecycle-toolkit/main/functions-runtime/samples/ts/prometheus.ts \
-e DATA='{ "url":"http://localhost:9090", "metrics": "up{service=\"kubernetes\"}", "expected_value": "1" }' \
-it \
ghcr.keptn.sh/keptn/functions-runtime:${VERSION}