Use Mage Pro if you need to run your blocks in separate pods or process while developing in the code editor.
executor_type: k8s) to run each block in its own Kubernetes pod.
Defaults in Mage Pro:
- Namespace:
default - Job name format:
mage-data-prep-block-{block_run_id}
Basic Setup
To configure a pipeline block to use Kubernetes executor, you simply just need to update theexecutor_type of the block to k8s in pipeline’s metadata.yaml:
default as the Kubernetes namespace. You can customize the namespace by setting the KUBE_NAMESPACE environment variable.
Configuration Methods
You can configure Kubernetes Executor in three ways:1. Block-Level Configuration
Addexecutor_config to a block in pipeline’s metadata.yaml:
- Run certain blocks in the Kubernetes executor
- Override the k8s executor config for specific blocks
2. Project-Level Configuration (applies to all k8s executor blocks)
Setk8s_executor_config in the project’s metadata.yaml:
- The Kubernetes job name is in this format:
mage-{job_name_prefix}-block-{block_run_id}. The defaultjob_name_prefixisdata-prep. You can customize it in thek8s_executor_config. You can interpolate the trigger name in thejob_name_prefixfield with the format{trigger_name}.
-
GPU Support:
Make sure GPU device plugins are installed.
-
Custom container & job spec:
3. Full Kubernetes Job Template (maximum control)
Set theK8S_CONFIG_FILE environment variable to the path of a YAML configuration file.
Example template:
Node Scheduling Configuration
Node Selector
Usenode_selector to schedule pods on specific nodes based on labels:
Tolerations
Usetolerations to allow pods to be scheduled on tainted nodes:
Affinity Rules
Useaffinity for advanced scheduling rules:
Custom Scheduler
Use a custom scheduler for advanced scheduling logic:Multi-Container Pods
If your Mage deployment runs in a multi-container pod, set theMAGE_CONTAINER_NAME environment variable to specify which container runs Mage:
Default config file
Only in Mage Pro.Try our fully managed solution to access this advanced feature.
K8S_DEFAULT_CONFIG_PATH environment variable. The file is loaded as a policy and merged with block-level and project-level config. Use this to enforce cluster-wide defaults (e.g. resource limits, service account) without editing every project.
Helm chart: When deploying Mage Pro with the Mage Helm chart, configure the default via k8sExecutorConfig in values.yaml. The chart creates a ConfigMap from your config, mounts it into the control-plane (and workspace pods), and sets K8S_DEFAULT_CONFIG_PATH automatically. Do not set the env var manually when using the chart. See Using Helm for details. For non-Helm deployments, set the env var and ensure the file exists at that path (e.g. via your own ConfigMap or volume mount).
File format:
| Field | Description |
|---|---|
enabled | If false, the policy is not applied. |
enforce | Controls how the default file is merged with user config (block + project). See Priority when merging below. |
| (other keys) | Same structure as project-level k8s_executor_config (e.g. resource_limits, resource_requests, pod, container, metadata, job). |
enforce:
enforce | Effective priority (highest → lowest) | Result |
|---|---|---|
true | 1. Default config file → 2. Block → 3. Project → 4. Env vars → 5. Hardcoded | Policy is highest priority. Values from the default file override block and project for the same keys. Use this to enforce cluster-wide defaults (e.g. resource limits, service account) that users cannot override. Conflicting values can cause an error on update when strict conflict checking is used. |
false | 1. Block → 2. Project → 3. Default config file (fills gaps only) → 4. Env vars → 5. Hardcoded | User wins. Block and project override the policy for the same keys. The policy only fills in keys that block and project did not set. Use this to provide optional defaults while allowing per-block or per-project overrides. |
enforce: true, the policy has the highest priority; when enforce: false, block and project are higher and the policy only supplies missing values.
Environment Variables Reference
General Configuration
| Variable | Purpose | Default |
|---|---|---|
KUBE_NAMESPACE | Namespace for job execution | default |
K8S_CONFIG_FILE | Path to full Kubernetes job config file | — |
MAGE_CONTAINER_NAME | Container to run Mage in multi-container pods | — |
Default Resource Configuration
Only in Mage Pro.Try our fully managed solution to access this advanced feature.
| Variable | Purpose | Example Value |
|---|---|---|
K8S_EXECUTOR_DEFAULT_RESOURCE_REQUESTS_CPU | Default CPU request for executor jobs | 250m |
K8S_EXECUTOR_DEFAULT_RESOURCE_REQUESTS_MEMORY | Default memory request for executor jobs | 512Mi |
K8S_EXECUTOR_DEFAULT_RESOURCE_LIMITS_CPU | Default CPU limit for executor jobs | 500m |
K8S_EXECUTOR_DEFAULT_RESOURCE_LIMITS_MEMORY | Default memory limit for executor jobs | 1Gi |
K8S_EXECUTOR_DEFAULT_SERVICE_ACCOUNT_NAME | Default service account for executor jobs | default |
- Block-level
executor_configin pipeline’smetadata.yaml - Project-level
k8s_executor_configin project’smetadata.yaml - Environment variable defaults (listed above)
- Hardcoded defaults