2.5.4. 示例:与环境标签进行同步
以下示例演示了如何使用环境标签配置应用程序间的同步:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: cluster-apps
namespace: openshift-gitops
spec:
strategy:
type: RollingSync
rollingSync:
steps:
- matchExpressions:
- key: envLabel
operator: In
values:
- env-dev
- matchExpressions:
- key: envLabel
operator: In
values:
- env-prod
maxUpdate: 10%
generators:
- list:
elements:
- cluster: dev-cluster
url: https://dev-cluster.example.com
envLabel: env-dev
- cluster: prod-cluster
url: https://prod-cluster.example.com
envLabel: env-prod
template:
metadata:
name: '{{cluster}}-app'
labels:
envLabel: '{{envLabel}}'
spec:
project: default
source:
repoURL: https://github.com/example/repo.git
targetRevision: HEAD
path: apps
destination:
server: '{{url}}'
namespace: default
在本例中:
-
第 1 步使用
envLabel: env-dev标签更新应用程序。 -
第 2 步使用
envLabel: env-prod标签更新应用程序,最多会同时更新 10% 的生产应用程序。