根据 ArgoCD 官方文档的说明,metav1.Duration 类型可以被 Kubernetes 内部 JSON 格式所支持,但在 ArgoCD 中,需要手动进行转换为字符串(即使用 time.ParseDuration() 函数)。代码示例:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
spec:
project: my-project
source:
repoURL: https://github.com/username/repo.git
targetRevision: HEAD
path: path/to/app
destination:
server: https://kubernetes.default.svc
namespace: my-app-ns
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: true
syncOptions:
- "--timeout=5m" # 这里使用字符串类型的 Duration,而非 metav1.Duration 类型