我正在尝试在 Airflow 的 Kubernetes 执行器中设置 request_cpu
参数,但一直无法找到可以执行此操作的位置。在default airflow config我找到了 default_cpus
但根据 this answer没有任何地方使用它,在 Kubernetes 部分的其他任何地方我都找不到对 CPU 请求的引用。
如何在 Airflow Kubernetes 执行器中设置 request_cpu
参数?
编辑: 理想情况下,我希望能够做的是将其设置为全局默认值而不是基于每个运算符(operator),尽管通常我认为按运算符(operator)/任务设置它确实更有意义
最佳答案
您可以在任务级别为 KubernetesExecutor 设置此 executor_config
,如下所示。
exmaple_task = PythonOperator(
task_id="exmaple_task",
python_callable=print_stuff,
executor_config={
"KubernetesExecutor": {"request_cpu": "1",
"request_memory": "128Mi",
"limit_memory": "128Mi"}}
)
您可以在 executor_config
中定义以下内容:
- 图片
- image_pull_policy
- 请求内存
- request_cpu
- 限制内存
- limit_cpu
- 限制GPU
- 节点选择器
- 亲和性
- 容忍度
- 注释
- 数量
- volume_mounts
- volume_mounts
关于kubernetes - 如何使用 kubernetes 执行程序为 airflow worker pod 全局设置 request_cpu?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60443124/