所以,我在 EKS 上设置 Airflow。
除了我无法使用 KubernetesExecutor 之外,一切似乎都已准备就绪。每次我尝试使用它时,我都会收到此错误:
使用 open(TEST_CONFIG_FILE, 'w') as f: PermissionError: [Errno 13] Permission denied: '/usr/local/airflow/unittests.cfg'
我试过进入豆荚和chmod
文件chown
。我在 docker 映像中尝试了相同的操作,还尝试创建unitttests.cfg
文件,并将其从本地复制到映像。它们都返回相同的错误。
Docker镜像:
FROM python:3.7.6-slim
ARG AIRFLOW_USER_HOME=/var/lib/airflow
ENV AIRFLOW_HOME=$AIRFLOW_USER_HOME
# Define en_US.
ENV LANGUAGE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LC_CTYPE en_US.UTF-8
ENV LC_MESSAGES en_US.UTF-8
RUN mkdir $AIRFLOW_USER_HOME && \
useradd -ms /bin/bash -d ${AIRFLOW_USER_HOME} airflow && \
buildDeps='freetds-dev libkrb5-dev libsasl2-dev libssl-dev libffi-dev libpq-dev' \
apt-get update && \
apt-get install -yqq --no-install-recommends $buildDeps build-essential default-libmysqlclient-dev && \
pip install psycopg2-binary \
pip install --no-cache-dir 'apache-airflow[crypto,kubernetes,postgres,mysql]' && \
apt-get purge --auto-remove -yqq $buildDeps && \
apt-get autoremove -yqq --purge && \
rm -rf /var/lib/apt/lists/*
COPY ./dags ${AIRFLOW_USER_HOME}/dags
COPY ./config/unittests.cfg ${AIRFLOW_USER_HOME}/unittests.cfg
RUN adduser airflow sudo
RUN chgrp -R airflow ${AIRFLOW_USER_HOME}
RUN chown -R airflow ${AIRFLOW_USER_HOME}
USER airflow
WORKDIR $AIRFLOW_USER_HOME
狗屎:
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime
default_args = {
"start_date": datetime(2020, 9, 24),
"email_on_failure": False,
"email_on_retry": False,
"retries": 0,
'run_as_user': 1000
}
dag = DAG("test_bash_dag", default_args=default_args, schedule_interval=None, catchup=False)
t1 = BashOperator(task_id="foo", bash_command="echo foo", xcom_push=True, dag=dag)
t2 = BashOperator(task_id="bar", bash_command="echo bar", dag=dag)
t2.set_upstream(t1)
正如你所看到的,dag 实际上只是一个测试,但我已经在这里停留了一段时间。