kubernetes - Airflow KubePodOperator 从私有(private)仓库拉取镜像

标签 kubernetes airflow

Apache Airflow 的 KubernetesPodOperator从私有(private)存储库中提取 docker 镜像?
KubernetesPodOperator有一个 image_pull_secrets您可以通过 Secrets对象与私有(private)存储库进行身份验证。但是 secrets 对象只能表示一个环境变量或一个卷 - 这两者都不符合我对 Kubernetes 如何使用 secret 对私有(private) repos 进行身份验证的理解。

使用 kubectl您可以使用类似的东西创建所需的 secret

$ kubectl create secret docker-registry $SECRET_NAME \
              --docker-server=https://${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com \
              --docker-username=AWS \
              --docker-password="${TOKEN}" \
              --docker-email="${EMAIL}"

但是如何在 Airflow 中创建身份验证 key ?

最佳答案

secret带有 docker-registry 的对象根据 Kubernetes 输入 documentation可用于对私有(private)存储库进行身份验证。
正如您在问题中提到的那样;您可以使用 kubectl创建 docker-registry的 secret 类型 然后您可以尝试通过 image_pull_secrets .
但是,根据您使用的平台,可能有 有限完全没用根据 kubernetes documentation :

Configuring Nodes to Authenticate to a Private Registry

Note: If you are running on Google Kubernetes Engine, there will already be a .dockercfg on each node with credentials for Google Container Registry. You cannot use this approach.

Note: If you are running on AWS EC2 and are using the EC2 Container Registry (ECR), the kubelet on each node will manage and update the ECR login credentials. You cannot use this approach.

Note: This approach is suitable if you can control node configuration. It will not work reliably on GCE, and any other cloud provider that does automatic node replacement.

Note: Kubernetes as of now only supports the auths and HttpHeaders section of docker config. This means credential helpers (credHelpers or credsStore) are not supported.


在上述平台上进行这项工作是可能的,但需要自动化脚本和第三方工具。
就像在 Amazon ECR 示例中一样:Amazon ECR Docker Credential Helper需要定期将 AWS 凭证提取到 docker 注册表配置,然后使用另一个脚本来更新 kubernetes docker-registry secret 。
至于 Airflow 本身,我认为它没有创建自己的 docker-repository secret 的功能。
您可以在 Apache Airflow JIRA 中请求类似的功能.
附言
如果您的 K8s 集群仍然存在问题,您可能需要在堆栈上创建新问题来解决这些问题。

关于kubernetes - Airflow KubePodOperator 从私有(private)仓库拉取镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58293057/

相关文章:

neo4j - Kubernetes集群中的内部和外部集群通信

docker - 通过 Docker 登录 Airflow 的默认用户 ID 和密码是什么?

python - 从 sub dag 中拉取 xcom

amazon-web-services - 如何确保AWS EKS上的节点均匀分布在一个区域的可用区中?

kubernetes - 如何修复“由于节点以某种方式错误配置(需要禁用 cgroups)导致 kubelet 不健康”错误

kubernetes - 无法连接到服务器:调用tcp 127.0.0.1:45451:connectex:无法建立连接,因为目标计算机主动拒绝了它

amazon-web-services - Kops/Kubernetes实例组自动缩放

python - 分支任务的 Airflow 问题

Airflow UI 将执行日期时间更改为可读格式

airflow - 保证一些操作符将在同一个 Airflow worker 上执行