我是Airflow和Kubernetes的新手。我正在尝试在Kubernetes中使用apache Airflow。
为了部署它,我使用了以下图表:https://github.com/apache/airflow/tree/master/chart.
我想把我的dag上传到我的github存储库中,所以:
gitSync:
enabled: true
# git repo clone url
# ssh examples ssh://git@github.com/apache/airflow.git
# git@github.com:apache/airflow.git
# https example: https://github.com/apache/airflow.git
repo: https://github.com/mygithubrepository.git
branch: master
rev: HEAD
root: "/git"
dest: "repo"
depth: 1
# the number of consecutive failures allowed before aborting
maxFailures: 0
# subpath within the repo where dags are located
# should be "" if dags are at repo root
subPath: ""
然后我发现,要使用私人github存储库,我必须创建一个在value.yml文件中指定的秘密:
# if your repo needs a user name password
# you can load them to a k8s secret like the one below
# ---
# apiVersion: v1
# kind: Secret
# metadata:
# name: git-credentials
# data:
# GIT_SYNC_USERNAME: <base64_encoded_git_username>
# GIT_SYNC_PASSWORD: <base64_encoded_git_password>
# and specify the name of the secret below
#credentialsSecret: git-credentials
我正在创造秘密:
apiVersion: v1
data:
GIT_SYNC_USERNAME: bXluYW1l
GIT_SYNC_PASSWORD: bXl0b2tlbg==
kind: Secret
metadata:
name: git-credentials
namespace: default
然后我使用value.yml文件中的秘密名称:
repo: https://github.com/mygithubrepository.git
branch: master
rev: HEAD
root: "/git"
dest: "repo"
depth: 1
# the number of consecutive failures allowed before aborting
maxFailures: 0
# subpath within the repo where dags are located
# should be "" if dags are at repo root
subPath: ""
# if your repo needs a user name password
# you can load them to a k8s secret like the one below
# ---
# apiVersion: v1
# kind: Secret
# metadata:
# name: git-credentials
# data:
# GIT_SYNC_USERNAME: <base64_encoded_git_username>
# GIT_SYNC_PASSWORD: <base64_encoded_git_password>
# and specify the name of the secret below
credentialsSecret: git-credentials
但似乎不是蜜蜂在工作。
我看到您正在通过https
连接到您的github repo。
尝试使用:
ssh://git@github.com/mygithubrepository.git
或简称
git@github.com/mygithubrepository.git
通过https
连接时可能会遇到问题,尤其是在您的github帐户上启用了双因素身份验证的情况下。本文对其进行了更详细的描述。
还可以看看VonC的回答,他提到:
如Oliver的答案,HTTPS URL如果双因素身份验证,则不会使用用户名/密码(2FA(被激活。
在这种情况下,密码应该是PAT(个人访问令牌(,如";在命令上使用令牌行";。
这只适用于HTTPS URLS,SSH不受此影响限制
以及rc0r提供的这个。
但正如我所说,简单地使用ssh
而不是https
应该可以很容易地解决您的问题。
我遇到了这个问题。我本来打算改为使用ssh,但后来还是坚持了下来。我如何让https工作(使用PAT(是:
填写您的回购URL
repo: "https://github.com/USERNAME/REPOSITORY.git"
添加您的秘密的名称
httpSecret: "my-airflow-secret"
填写此部分太
httpSecretUsernameKey: "your-username-key"
httpSecretPasswordKey: "your-PAT-key"
现在,关键是,当创建base64编码的字符串以放入您的秘密时,使用:
echo -n "your-user-name" | base64
-n表示echo不附加换行符。之后它就正常工作了。我有许多其他应用程序不介意不带-n的base64编码字符串,所以我想我只是有点自满。我花了一段时间才意识到这个问题。