AKS部署Airflow查看DAG任务日志报错:缺失http/https协议
AKS部署Airflow后任务日志读取失败问题解决
问题现象
在Azure Kubernetes Service(AKS)中通过Helm Chart(版本1.11.0)部署Airflow,使用Azure Postgres作为元数据库,运行DAG后打开任务日志时出现错误:
*** Could not read served logs: Request URL is missing an 'http://' or 'https://' protocol
部署相关信息
部署命令
# Add helm repo for airflow helm repo add apache-airflow https://airflow.apache.org # Install airflow helm chart version 1.11.0 with custom configurations helm upgrade airflow apache-airflow/airflow --version 1.11.0 --install --namespace <namespace> --create-namespace -f override-values.yaml
自定义配置文件(override-values.yaml)
webserverSecretKey: "<webserver secret key created using official helm production guide>" scheduler: waitForMigrations: enabled: false initDb: enabled: true # Disable postgre instance to be created postgresql: enabled: false # Update storage class name for logs pvc to be managed-premium logs: persistence: storageClassName: managed-premium # Update storage class name for dags pvc to be managed-premium dags: persistence: storageClassName: managed-premium # Update storage class name for triggerer pvc to be managed-premium triggerer: persistence: storageClassName: managed-premium # Update storage class name for workers pvc to be managed-premium workers: persistence: storageClassName: managed-premium # For Postgres azure connection pgbouncer: enabled: true pgbouncer: # The maximum number of connections to PgBouncer maxClientConn: 100 # The maximum number of server connections to the metadata database from PgBouncer metadataPoolSize: 10 # The maximum number of server connections to the result backend database from PgBouncer resultBackendPoolSize: 5 env: - name: AIRFLOW__CORE__TEST_CONNECTION value: Enabled - name: AIRFLOW__WEBSERVER__EXPOSE_CONFIG value: 'true' - name: AIRFLOW__API__AUTH_BACKENDS value: "airflow.api.auth.backend.basic_auth" # For Postgres azure connection data: metadataSecretName: <secret having azure postgres database connection string> # For DAGs git sync dags: gitSync: enabled: true repo: <repo url> branch: "<branch name in repo>" subPath: "" sshKeySecret: <secret holding ssh key for repo>
解决方案
该错误源于Airflow WebServer无法正确生成日志服务的请求URL,需通过以下步骤修复:
添加WebServer基础URL配置
在override-values.yaml的env节点中补充以下环境变量,指定WebServer的完整访问地址(带协议):env: # 保留原有环境变量 - name: AIRFLOW__WEBSERVER__BASE_URL value: "http://airflow-webserver.<namespace>.svc.cluster.local:8080" - name: AIRFLOW__LOGGING__REMOTE_LOGGING value: "False"说明:
airflow-webserver是Helm部署默认的WebServer服务名,若自定义过服务名需替换<namespace>替换为实际部署Airflow的命名空间- 若通过Ingress对外暴露服务,可将
BASE_URL设为外部访问域名(如https://airflow.yourdomain.com)
验证日志存储PVC状态
执行命令确认日志持久化存储PVC已正常绑定:kubectl get pvc -n <namespace>确保
airflow-logs的PVC状态为Bound,若未绑定需检查AKS中managed-premium存储类是否正常可用。重新部署Airflow
应用更新后的配置重新部署:helm upgrade airflow apache-airflow/airflow --version 1.11.0 --install --namespace <namespace> -f override-values.yaml
部署完成后重新运行DAG,即可正常查看任务日志。
内容的提问来源于stack exchange,提问作者daemon22
相关产品推荐
相关产品推荐

