Skip to main content

kubernetes

@webda/kubernetes

Kubernetes integration for Webda — KubeRunner dispatches async jobs as Kubernetes batch Jobs, KubernetesSecretsStore reads model data from K8s Secrets, and CronJobDeployer manages CronJob lifecycle.

When to use it​

  • You are using @webda/async and 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"]
}
}
}
ParameterTypeDefaultRequiredDescription
jobImagestring—Yes*Docker image to use for the Kubernetes Job pod (* or jobResources)
jobResourcesobject | string—Yes*Full Kubernetes Job manifest (object or path to YAML file) overriding the default template
configstring | object—NoKubernetes config path or inline K8sConfiguration (defaults to in-cluster config)
contextstring—NoKubernetes 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​

Classes​

Interfaces​

Variables​

Functions​