如何使用HTTP访问令牌从ARGO-WF访问Git仓库?
如何在Argo Workflow中使用HTTP访问令牌访问私有Git仓库
步骤1:创建存储HTTP令牌的Kubernetes Secret
先把你的HTTP访问令牌存入K8s Secret,避免明文暴露:
kubectl create secret generic git-http-token --from-literal=token=[你的HTTP-TOKEN]
替换[你的HTTP-TOKEN]为实际令牌内容。
步骤2:修改Workflow配置
在原有Workflow的Git artifact配置中添加Secret引用,同时替换为你的私有仓库地址:
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: input-artifact-git- spec: entrypoint: git-clone templates: - name: git-clone inputs: artifacts: - name: argo-source path: /src git: repo: https://code.company.com/scm/tc_pbms/report_configs.git secretName: git-http-token # 引用创建好的Secret username: "" # Bearer认证无需实际用户名,设为空即可 container: image: alpine command: [sh, -c] args: ["cd /src; ls"] workingDir: /src
说明
Argo的Git artifact组件会读取Secret中的token字段作为密码,当username为空时,自动生成Authorization: Bearer <token>请求头,和你在终端执行的git clone命令效果一致,完成私有仓库的认证访问。
内容的提问来源于stack exchange,提问作者olli
相关产品推荐
相关产品推荐

