GKE / GCP中的气流KubernetesPodOperator无法启动自定义吊舱

时间:2019-06-03 14:35:00

标签: kubernetes google-cloud-platform google-kubernetes-engine airflow

我们正在使用KubernetesExecutor在GCP的GKE集群上运行自管理的Airflow 1.10.2。到目前为止,除KubernetesPodOperator之外,所有内部运算符都工作正常,我们希望使用它运行自定义docker映像。看来Airflow工作程序映像没有特权来启动Kubernetes集群中的其他Pod。 DAG启动后似乎什么都没做。这是我们最初在日志中找到的:

FileNotFoundError: [Errno 2] No such file or directory: '/root/.kube/config'

下一次尝试-KubernetesPodOperator部分中的in_cluster=True参数似乎无济于事。之后,我们尝试在airflow.cfg的[kubernetes]部分中使用此参数:

gcp_service_account_keys = kubernetes-executor-private-key:/var/tmp/private/kubernetes_executor_private_key.json

,错误消息现在为TypeError: a bytes-like object is required, not 'str' 这是来自github的参数定义:

# GCP Service Account Keys to be provided to tasks run on Kubernetes Executors
# Should be supplied in the format: key-name-1:key-path-1,key-name-2:key-path-2
gcp_service_account_keys =

已经尝试在此处使用各种括号和引号,但没有成功。

DAG代码:

from datetime import datetime, timedelta
from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
from airflow.operators.dummy_operator import DummyOperator


default_args = {
    'owner': 'xxx',
    'depends_on_past': False,
    'start_date': datetime.utcnow(),
    'email': ['airflow@example.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5)
}

dag = DAG(
    'kubernetes_sample', default_args=default_args, schedule_interval=timedelta(minutes=10))


start = DummyOperator(task_id='run_this_first', dag=dag)

passing = KubernetesPodOperator(namespace='default',
                          image="Python:3.6",
                          cmds=["Python","-c"],
                          arguments=["print('hello world')"],
                          labels={"foo": "bar"},
                          name="passing-test",
                          task_id="passing-task",
                          in_cluster=True,
                          get_logs=True,
                          dag=dag
                          )

failing = KubernetesPodOperator(namespace='default',
                          image="ubuntu:1604",
                          cmds=["Python","-c"],
                          arguments=["print('hello world')"],
                          labels={"foo": "bar"},
                          in_cluster=True,
                          name="fail",
                          task_id="failing-task",
                          get_logs=True,
                          dag=dag
                          )

passing.set_upstream(start)
failing.set_upstream(start)

有人遇到同样的问题吗?我在这里想念东西吗?

0 个答案:

没有答案