假设您在由 ArgoCD 管理的集群内有一个
Application
规范,例如:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: foo-app
namespace: argocd
spec:
destination:
name: some-cluster
namespace: foo-namespace
project: default
source:
path: kubernetes/helm
repoURL: https://github.com/my/great-project.git
targetRevision: HEAD
现在假设在 Helm Chart 中,我需要访问已签出的 Git 提交 SHA,该 SHA 用于在
kubernetes/helm
中获取 Helm Chart。喜欢参考图片名称my-registry.com/my/great-project:<COMMIT_SHA>
。
如何实现这一目标?
根据 构建环境,您应该能够在 Helm 图表上使用环境变量
ARGOCD_APP_REVISION
。
要将这些构建环境变量与 Helm 一起使用,您可以执行以下操作:
spec:
source:
helm:
parameters:
- name: revision
value: $ARGOCD_APP_REVISION
来源:https://argo-cd.readthedocs.io/en/stable/user-guide/helm/#build-environment