<p>I'm trying to set the <code>request_cpu</code> parameter in the Kubernetes executor for Airflow but haven't been able to find where I can do that. In the <a href="https://github.com/apache/airflow/blob/master/airflow/config_templates/default_airflow.cfg" rel="nofollow noreferrer">default airflow config</a> I found <code>default_cpus</code> but according to <a href="https://stackoverflow.com/a/48223083/6733371">this answer</a> there is nowhere that that is used, and nowhere else in the Kubernetes section could I find a reference to the CPU request. </p>

<p>How can I set the <code>request_cpu</code> parameter in the Airflow Kubernetes executor?</p>

<p>EDIT: 
Ideally, what I would like to be able to do is set this as a global default rather than on a per-operator basis, even though in general I think that it does make more sense to set it per-operator/task</p>

qfwfq
<p>You can set this <code>executor_config</code> at task level for KubernetesExecutor as follows. </p>

<pre class="lang-py prettyprint-override"><code>    exmaple_task = PythonOperator(
        task_id="exmaple_task",
        python_callable=print_stuff,
        executor_config={
            "KubernetesExecutor": {"request_cpu": "1",
                                   "request_memory": "128Mi",
                                   "limit_memory": "128Mi"}}
    )
</code></pre>

<p>You can define the following in <code>executor_config</code> :</p>

<ul>
<li>image</li>
<li>image_pull_policy</li>
<li>request_memory</li>
<li>request_cpu</li>
<li>limit_memory</li>
<li>limit_cpu</li>
<li>limit_gpu</li>
<li>node_selectors</li>
<li>affinity</li>
<li>tolerations</li>
<li>annotations</li>
<li>volumes</li>
<li>volume_mounts</li>
<li>volume_mounts</li>
</ul>

<p><strong>Doc</strong>: <a href="https://airflow.apache.org/docs/1.10.9/_api/airflow/contrib/executors/kubernetes_executor/index.html#airflow.contrib.executors.kubernetes_executor.KubernetesExecutorConfig" rel="nofollow noreferrer">https://airflow.apache.org/docs/1.10.9/_api/airflow/contrib/executors/kubernetes_executor/index.html#airflow.contrib.executors.kubernetes_executor.KubernetesExecutorConfig</a></p>
