Registry / workflow / dagster-k8s

dagster-k8s

JSON →
library0.29.20pypypi✓ verified 26d ago

The `dagster-k8s` library provides a robust integration for running Dagster with Kubernetes. It enables launching Dagster runs as Kubernetes Jobs, executing external code in Kubernetes pods directly from assets and ops using `PipesK8sClient`, and forms the foundation for Dagster's official Helm chart deployments. The library is actively maintained, with version `0.29.0` typically aligning with major releases of the core Dagster library.

pip install dagster-k8s
INSTALL
IMPORT
SIG · DAGSTER-K8S
D
dagster-k8s
workflowpythonv0.29.20
Install
19.3s avg
Import
4787ms
Disk
241MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.29.20 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 4.920s · 242.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 19.3s · import 4.654s · 240MB
241MB installed
● package 241MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

K8sRunLauncher
from dagster_k8s.launcher import K8sRunLauncher
Used for configuring the Dagster instance to launch runs as Kubernetes Jobs.
k8s_job_executor
from dagster_k8s import k8s_job_executor
An executor that launches each step of a Dagster job as a separate Kubernetes Job.
PipesK8sClient
from dagster_k8s import PipesK8sClient
from dagster_k8s import k8s_job_op
The `k8s_job_op` API is superseded; `PipesK8sClient` is the recommended resource for launching Kubernetes pods directly from Dagster assets and ops.

This example demonstrates how to use `PipesK8sClient` to launch a Kubernetes pod from within a Dagster asset. The `PipesK8sClient` allows Dagster to receive real-time events from the initiated jobs running in Kubernetes. You would typically deploy this with a Dagster instance configured to run on Kubernetes.

import dagster as dg from dagster_k8s import PipesK8sClient @dg.asset def k8s_pipes_asset( context: dg.AssetExecutionContext, k8s_pipes_client: PipesK8sClient ): # Replace 'pipes-example:v1' with your actual Docker image # The image must contain the necessary code and dependencies to execute the external process return k8s_pipes_client.run( context=context, image='pipes-example:v1', command=["python", "-c", "print('Hello from K8s pod!')"] ).get_materialize_result() defs = dg.Definitions( assets=[k8s_pipes_asset], resources={ "k8s_pipes_client": PipesK8sClient() }, )
Debug
Known issues
deprecatedThe `k8s_job_op` API has been superseded by `PipesK8sClient` for launching Kubernetes jobs from within Dagster ops. While `k8s_job_op` may still function, it is no longer the recommended approach.
fix
Migrate usage from `k8s_job_op` to `PipesK8sClient` for launching Kubernetes pods from assets and ops.
affects: <=0.28.x
gotchaKubernetes configuration via `dagster-k8s/config` tags has different propagation rules depending on the executor. When using `k8s_job_executor` (which runs each step in its own pod), job-level `dagster-k8s/config` tags are NOT propagated to individual step pods.
fix
For `k8s_job_executor`, use the `step_k8s_config` field directly on the executor definition to apply configuration to every step pod, or apply `dagster-k8s/config` tags to individual ops if fine-grained control is needed.
affects: All versions
gotchaWhen deploying Dagster projects to Kubernetes, it is crucial to build and push a custom Docker image that contains your Dagster project code and all its Python dependencies, including `dagster-k8s`.
fix
Ensure your deployment workflow includes a Dockerfile that copies your project, installs `dagster`, `dagster-k8s`, and any other project dependencies, and then build and push this image to an accessible container registry.
affects: All versions
gotchaSome APIs within `dagster-k8s` may be marked as 'beta' and can introduce breaking changes in minor version releases.
fix
Refer to the official Dagster documentation and release notes before upgrading minor versions to identify potential breaking changes in beta APIs and adjust your code accordingly.
affects: All versions
Errors
Common errors & fixes
gRPC Error code: UNAVAILABLE
This error typically indicates that the Dagster webserver or daemon cannot establish a connection to the user code deployment, often due to network issues, misconfigured Kubernetes services, or the user code pod being unhealthy, restarting, or resource-constrained (e.g., OOMKilled).
fix
Check Kubernetes pod logs for the user code deployment (`kubectl logs <user-code-pod-name>`), verify the service is running and accessible (DNS resolution, port accessibility), ensure adequate CPU/memory resources for the user code pod, and review network policies.
CrashLoopBackOff
A Kubernetes pod status indicating that a container repeatedly starts and crashes, often due to application errors, incorrect entrypoints, missing dependencies, or insufficient resources (e.g., OOMKilled) preventing the Dagster process from initializing.
fix
Examine the logs of the crashing pod using `kubectl logs <pod-name>` (and `kubectl logs --previous <pod-name>` for past attempts) to identify the root cause, which could be a `ModuleNotFoundError`, `DagsterInvalidConfigError`, or application-level exception. Also, check pod events with `kubectl describe pod <pod-name>` for issues like `OOMKilled` or image pull errors.
ModuleNotFoundError: No module named 'your_module_name'
This occurs when Python within the Dagster Kubernetes pod cannot find an imported module, typically because the user code is not correctly packaged into the Docker image, the `PYTHONPATH` is not set correctly, or required dependencies are missing from the environment.
fix
Ensure your Dockerfile correctly copies your Dagster project and installs all necessary Python dependencies (including the project itself in editable mode, e.g., `pip install -e .`). Verify that your `dagster.yaml` or workspace definition correctly points to the module or package.
dagster.core.errors.DagsterInvalidConfigError: You have attempted to fetch the environment variable "YOUR_ENV_VAR" which is not set.
This error arises when Dagster attempts to resolve an environment variable specified in your run configuration (e.g., in `dagster.yaml` or a run's config) within a Kubernetes pod, but the environment variable has not been properly injected into the pod. This commonly happens with secrets or config maps.
fix
Verify that your Kubernetes deployment (e.g., Helm chart `values.yaml`) correctly configures environment variables or mounts secrets/config maps to the Dagster user code pods, and that the variable names match exactly. For Helm, ensure `envConfigMaps` or `envSecrets` are configured correctly.
ERROR:dagster.consume_pod_logs:An unhandled exception happened during processing: 'utf-8' codec can't decode byte 0xe2 in position XXX: unexpected end of data
This specific `UnicodeDecodeError` occurs when `PipesK8sClient` attempts to parse logs streamed from a Kubernetes pod, and the log stream contains invalid UTF-8 sequences or truncated multi-byte characters, which can happen with logs from multiple containers or non-standard output.
fix
This often requires a fix within the `dagster-k8s` library itself (as noted in GitHub issues) to robustly handle log streaming. For user-managed code, ensure containers are outputting valid UTF-8. If using custom log readers, implement more resilient decoding. Upgrading Dagster to a version where this issue is resolved is the primary solution.
Upgrade
Version history
0.29.20latest on PyPI · released Aug 27, 2026
Audit
Dependencies
dagsterrequiredCore Dagster library is required for defining and orchestrating data pipelines.
dagster-postgresoptionalCommonly used for persistent metadata storage in Kubernetes deployments, as seen in Helm charts and Dockerfile examples.
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources