Skip to content

PythonKubernetesOperator and kubernetes taskflow decorator #19135

@c-thiel

Description

@c-thiel

Description

After the implementation of the Docker Taskflow Operator in 2.2, having a simple function on Kubernetes should be quite simple to accomplish.

One major difference I see is how to get the Code into the Pod.
My prefered way here would be to add an init container which takes care of this - much similar on how we use a Sidecar to extract XCom.

I would also prefer to add more defaults than the KubernetesPodOperator does by default to keep the call as simple and straightforward as possible. We could for example default the namespace to the namespace Airflow is running in if it is a Kubernetes Deployment. Also, we could generate a reasonable pod name from DAG-ID and Task ID.

Use case/motivation

Beeing able to run a task as simple as:

@task.kubernetes(image='my_image:1.1.0')
def sum(a, b):
    from my_package_in_version_1 import complex_sum
    return complex_sum(a,b)

would be awesome!
It would cleanly separate environments and resources between tasks just as the Docker or Virtualenv Operators do - and unlinke the @task.python decorator. We could specify the resources and environment of each task freely by specifying a resources Argument.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions