<p><strong>What we want to achieve:</strong></p>

<p>We would like to use Airflow to manage our machine learning and data pipeline while using Kubernetes to manage the resources and schedule the jobs. What we would like to achieve is for Airflow to orchestrate the workflow (e.g. Various tasks dependencies. Re-run jobs upon failures) and Kubernetes to orchestrate the infrastructure (e.g cluster autoscaling and individual jobs assignment to nodes). In other words Airflow will tell the Kubernetes cluster what to do and Kubernetes decides how to distribute the work. In the same time we would also want Airflow to be able to monitor the individual tasks status. For example if we have 10 tasks spreaded across a cluster of 5 nodes, Airflow should be able to communicate with the cluster and reports show something like: 3 “small tasks” are done, 1 “small task” has failed and will be scheduled to re-run and the remaining 6 “big tasks” are still running.</p>

<p><strong>Questions:</strong></p>

<p>Our understanding is that Airflow has no Kubernetes-Operator, see open issues at <a href="https://issues.apache.org/jira/browse/AIRFLOW-1314" rel="noreferrer">https://issues.apache.org/jira/browse/AIRFLOW-1314</a>. That being said we don’t want Airflow to manage resources like managing service accounts, env variables, creating clusters, etc. but simply send tasks to an existing Kubernetes cluster and let Airflow know when a job is done. An alternative would be to use Apache Mesos but it looks less flexible and less straightforward compared to Kubernetes.</p>

<p>I guess we could use Airflow’s bash_operator to run <code>kubectl</code> but this seems not like the most elegant solution.</p>

<p>Any thoughts? How do you deal with that?</p>

<p>Airflow has both a <a href="https://github.com/apache/incubator-airflow/blob/master/airflow/contrib/executors/kubernetes_executor.py" rel="noreferrer">Kubernetes Executor</a> as well as a <a href="https://github.com/apache/incubator-airflow/blob/master/airflow/contrib/operators/kubernetes_pod_operator.py" rel="noreferrer">Kubernetes Operator</a>.  </p>

<p>You can use the Kubernetes Operator to send tasks (in the form of Docker images) from Airflow to Kubernetes via whichever AirflowExecutor you prefer. </p>

<p>Based on your description though, I believe you are looking for the KubernetesExecutor to schedule all your tasks against your Kubernetes cluster. As you can see from the source code it has a much tighter integration with Kubernetes. </p>

<p>This will also allow you to not have to worry about creating the docker images ahead of time as is required with the Kubernetes Operator.</p>
