我们在 Kubernetes 上运行气流。下面是我的airflowlocalsettings
:
airflowLocalSettings: |
from airflow.contrib.kubernetes.pod import Pod, Resources
from airflow.configuration import conf
def pod_mutation_hook(pod: Pod):
pod.labels.update({"app": "airflow-pod"})
pod.annotations.update({"iam.amazonaws.com/role": "role"})
pod.tolerations += [{"key": "spotInstance", "operator": "Exists"}]
pod.resources = Resources(limit_memory = "512Mi", limit_cpu = "300m")
pod.affinity.update({
"nodeAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [
{"weight": 100, "preference": {
"matchExpressions": [{
"key": "role.node.kubernetes.io/spot-worker",
"operator": "In",
"values": ["spot-worker"]
}]
}}
]
}
})
我想启动一些选择性任务 pod,它们有自己的资源通过resources
参数传递KubernetesPodOperator
。现在的问题是 Resources 被覆盖,它从pod_mutation_hook
.
我们如何绕过 pod_mutation 资源,让这些 pod 拥有自己的资源设置?我无法从中删除资源设置,pod_mutation_hook
因为它也被其他 pod 使用。