【问题标题】:Not able to connect private github repository in apache ariflow helm chart in Kubernetes无法在 Kubernetes 的 apache 气流 helm 图表中连接私有 github 存储库
【发布时间】:2021-01-24 10:12:11
【问题描述】:

我是 Airflow 和 Kubernetes 的新手。我正在尝试在 Kubernetes 中使用 apache Airflow。

为了部署它,我使用了这个图表:https://github.com/apache/airflow/tree/master/chart

我想将我的 dags 上传到我的 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

但似乎无法正常工作。

【问题讨论】:

  • 您得到的确切错误信息是什么?

标签: kubernetes airflow kubernetes-helm


【解决方案1】:

我看到您正在通过 https 连接到您的 github 存储库。

尝试使用:

ssh://git@github.com/mygithubrepository.git

或者干脆

git@github.com/mygithubrepository.git

您可能会遇到通过https 连接的问题,尤其是如果您在您的 github 帐户上启用了双因素身份验证。在this 文章中有更详细的描述。

还可以看看他提到的VonC'sanswer

Oliver 中所述 answer,HTTPS URL 如果two-factor authentication (2FA),则不会使用用户名/密码 已激活。

在这种情况下,密码应该是PAT (personal access token),如“Using a token on the command line”所示。

这仅适用于 HTTPS URL,SSH 不受此影响 限制。

以及this one 提供的rc0r

但正如我所说,只需使用 ssh 而不是 https 应该可以轻松解决您的问题。

【讨论】:

【解决方案2】:

我遇到了这个确切的问题。我正要使用 ssh 代替,但后来坚持了下来。我如何让 https 工作(使用 PAT)是:

填写你的repo 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 编码字符串,所以我想我只是有点自满。不过我花了一段时间才意识到这个问题。

【讨论】:

    猜你喜欢
    • 2021-08-03
    • 2014-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-29
    • 2018-09-23
    • 2018-10-13
    • 2018-05-02
    相关资源
    最近更新 更多