kubernetes
@webda/kubernetes
Kubernetes integration for Webda —
KubeRunnerdispatches async jobs as Kubernetes batch Jobs,KubernetesSecretsStorereads model data from K8s Secrets, andCronJobDeployermanages CronJob lifecycle.
When to use it
- You are using
@webda/asyncand want async job workers to run as Kubernetes Jobs (one pod per job, auto-retried, auto-cleaned). - You want to store Webda model instances in Kubernetes Secrets (useful for small, sensitive configuration objects).
- You need to deploy a scheduled Webda service operation as a Kubernetes CronJob.
Install
pnpm add @webda/kubernetes
Configuration
KubeRunner (async job runner)
{
"services": {
"kubeRunner": {
"type": "KubeRunner",
"jobImage": "my-registry/my-webda-app:latest",
"context": "my-k8s-context"
},
"asyncJobService": {
"type": "AsyncJobService",
"queue": "AsyncActionsQueue",
"runners": ["kubeRunner"]
}
}
}
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
jobImage | string | — | Yes* | Docker image to use for the Kubernetes Job pod (* or jobResources) |
jobResources | object | string | — | Yes* | Full Kubernetes Job manifest (object or path to YAML file) overriding the default template |
config | string | object | — | No | Kubernetes config path or inline K8sConfiguration (defaults to in-cluster config) |
context | string | — | No | Kubernetes context name (from kubeconfig) to use |
Usage
// Workers are dispatched automatically by AsyncJobService.
// KubeRunner translates each AsyncAction into a Kubernetes Job:
//
// 1. AsyncJobService.launchAsAsyncAction("MyService", "runReport", reportId)
// → saves AsyncAction to store → sends to queue
//
// 2. KubeRunner picks up the queue message and creates a Kubernetes Job:
// kubectl get jobs
// NAME COMPLETIONS DURATION
// kuberunner-abc123 1/1 12s
//
// 3. The Job pod runs: webda runAsyncAction
// → calls MyService.runReport(reportId) inside the cluster
// To run locally (without Kubernetes), switch to ServiceRunner:
{
"services": {
"asyncJobService": {
"runners": ["serviceRunner"] // swap in for dev
}
}
}
Reference
- API reference: see the auto-generated typedoc at
docs/pages/Modules/kubernetes/. - Source:
packages/kubernetes - Related:
@webda/asyncfor the job orchestration layer;@webda/awsforLambdaDeployeras an AWS equivalent;@webda/corefor theRunnerbase class.