3

我正在将 Airflow 与 Kubernetes 执行程序一起使用并在本地进行测试(使用 minikube),虽然我能够启动并运行它,但我似乎无法将我的日志存储在 S3 中。我已经尝试了所有描述的解决方案,但仍然出现以下错误,

*** Log file does not exist: /usr/local/airflow/logs/example_python_operator/print_the_context/2020-03-30T16:02:41.521194+00:00/1.log
*** Fetching from: http://examplepythonoperatorprintthecontext-5b01d602e9d2482193d933e7d2:8793/log/example_python_operator/print_the_context/2020-03-30T16:02:41.521194+00:00/1.log
*** Failed to fetch log file from worker. HTTPConnectionPool(host='examplepythonoperatorprintthecontext-5b01d602e9d2482193d933e7d2', port=8793): Max retries exceeded with url: /log/example_python_operator/print_the_context/2020-03-30T16:02:41.521194+00:00/1.log (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd00688a650>: Failed to establish a new connection: [Errno -2] Name or service not known'))

我实现了这个答案中提到的自定义 Logging 类,但仍然没有运气。

我的airflow.yaml长相是这样的

airflow:
  image:
     repository: airflow-docker-local
     tag: 1

  executor: Kubernetes

  service:
    type: LoadBalancer

  config:
    AIRFLOW__CORE__EXECUTOR: KubernetesExecutor
    AIRFLOW__CORE__TASK_LOG_READER: s3.task
    AIRFLOW__CORE__LOAD_EXAMPLES: True
    AIRFLOW__CORE__FERNET_KEY: ${MASKED_FERNET_KEY}
    AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://postgres:airflow@airflow-postgresql:5432/airflow
    AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://postgres:airflow@airflow-postgresql:5432/airflow
    AIRFLOW__CELERY__BROKER_URL: redis://:airflow@airflow-redis-master:6379/0

    # S3 Logging
    AIRFLOW__CORE__REMOTE_LOGGING: True
    AIRFLOW__CORE__REMOTE_LOG_CONN_ID: s3://${AWS_ACCESS_KEY_ID}:${AWS_ACCESS_SECRET_KEY}@S3
    AIRFLOW__CORE__REMOTE_BASE_LOG_FOLDER: s3://${BUCKET_NAME}/logs
    AIRFLOW__CORE__S3_LOG_FOLDER: s3://${BUCKET_NAME}/logs
    AIRFLOW__CORE__LOGGING_LEVEL: INFO
    AIRFLOW__CORE__LOGGING_CONFIG_CLASS: log_config.LOGGING_CONFIG
    AIRFLOW__CORE__ENCRYPT_S3_LOGS: False
    # End of S3 Logging

    AIRFLOW__WEBSERVER__EXPOSE_CONFIG: True
    AIRFLOW__WEBSERVER__LOG_FETCH_TIMEOUT_SEC: 30
    AIRFLOW__KUBERNETES__WORKER_CONTAINER_REPOSITORY: airflow-docker-local
    AIRFLOW__KUBERNETES__WORKER_CONTAINER_TAG: 1
    AIRFLOW__KUBERNETES__WORKER_CONTAINER_IMAGE_PULL_POLICY: Never
    AIRFLOW__KUBERNETES__WORKER_SERVICE_ACCOUNT_NAME: airflow
    AIRFLOW__KUBERNETES__DAGS_VOLUME_CLAIM: airflow
    AIRFLOW__KUBERNETES__NAMESPACE: airflow
    AIRFLOW__KUBERNETES__DELETE_WORKER_PODS: True
    AIRFLOW__KUBERNETES__KUBE_CLIENT_REQUEST_ARGS: '{\"_request_timeout\":[60,60]}'

persistence:
  enabled: true
  existingClaim: ''
  accessMode: 'ReadWriteMany'
  size: 5Gi

logsPersistence:
  enabled: false

workers:
  enabled: true

postgresql:
  enabled: true

redis:
  enabled: true

我已经尝试通过 UI 设置连接并通过创建连接airflow.yaml,但似乎没有任何效果,我已经尝试了 3 天,但没有运气,任何帮助将不胜感激。

我附上了截图供参考,

在此处输入图像描述 在此处输入图像描述

4

1 回答 1

3

我很确定这个问题是因为 s3 日志记录配置尚未在工作 pod 上设置。工作 pod 没有使用环境变量(例如AIRFLOW__CORE__REMOTE_LOGGING: True. 如果您希望在工作 pod 中设置此变量,则必须复制该变量并附AIRFLOW__KUBERNETES_ENVIRONMENT_VARIABLES__加到复制的环境变量名称:AIRFLOW__KUBERNETES_ENVIRONMENT_VARIABLES__AIRFLOW__CORE__REMOTE_LOGGING: True.

在这种情况下,您需要复制所有为 s3 日志记录指定配置的变量并附AIRFLOW__KUBERNETES_ENVIRONMENT_VARIABLES__加到副本中。

于 2020-03-31T08:29:01.753 回答