New to Kestra?
Use blueprints to kickstart your first workflows.
Run Python scripts in a Kubernetes pod with declarative CPU and memory limits using Kestra, with automatic file exchange and retries.
Run a Python script on a remote Kubernetes pod directly from a Kestra flow, with full control over CPU and memory requests so each job lands on the right node and stays inside its resource budget. This blueprint solves a common gap in container orchestration: you want ephemeral, isolated compute for data and automation scripts without writing your own pod manifests, managing the pod lifecycle, or shipping files in and out of the container by hand. Kestra handles pod creation, resource sizing, file exchange, and cleanup while you keep your logic in plain Python.
The flow has a single task, send_data, of type io.kestra.plugin.scripts.python.Script. Instead of running on the local worker, the script is dispatched to a Kubernetes pod through the io.kestra.plugin.ee.kubernetes.runner.Kubernetes task runner.
masterUrl, username, and certificate data passed through config, and schedules the pod in the default Kubernetes namespace with pullPolicy: ALWAYS.resources.request reserves 500m CPU and 128Mi memory for the pod.kestra, prints host, Python version, platform, and OS/arch details, and writes them both to Kestra.outputs(...) and to environment_info.json.outputFiles captures *.json, so a sidecar container downloads environment_info.json back into Kestra storage. The kestra pip dependency is installed via dependencies.If your script task adds inputFiles or namespaceFiles, an init container uploads them into the main container; with outputFiles, a sidecar downloads results. All containers share an in-memory emptyDir volume for file exchange. If a task is resubmitted after a retry or worker crash, the new worker reattaches to the already running or finished pod instead of starting a new one.
Kubernetes schedules pods, but it does not orchestrate multi-step data pipelines. Kestra adds event and schedule triggers, automatic retries, run-level lineage, and a fully declarative YAML definition, then offloads heavy work to Kubernetes pods sized exactly as you specify. You get pod-level isolation and resource control without leaving your workflow layer, and without building CronJobs and glue scripts the cluster scheduler alone cannot coordinate.
kestra package is installed at runtime via dependencies).Store these as Kestra secrets:
K8S_USERNAME: Kubernetes user name.MASTER_URL: cluster API server URL.caCertData: cluster CA certificate data.clientCertData: client certificate data.clientKeyData: client private key data.namespace to your target.resources.request to match your workload.environment_info.json.dependencies.inputFiles or namespaceFiles to ship code or config into the pod.resources.limit alongside request to cap usage.