apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: nextgen-o11y-agent
spec:
  generators:
    - list:
        elements:
          - env: aws-prod-us-west-2-ng
            cluster: prod-seed-us-west-2-ng
          - env: aws-prod-us-west-2-pov
            cluster: prod-seed-us-west-2-pov
          - env: aws-prod-ap-southeast-1-ng
            cluster: prod-seed-ap-southeast-1-ng
          - env: ali-prod-ap-southeast-1-ng
            cluster: prod-ap-southeast-1-controlplane-ng
          - env: ali-prod-cn-hongkong-ng
            cluster: prod-seed-cn-hongkong-ng
          - env: aws-prod-ap-northeast-1-ng
            cluster: prod-seed-ap-northeast-1-ng
          - env: aws-prod-ap-southeast-2-ng
            cluster: prod-seed-ap-southeast-2-ng
          - env: aws-prod-us-east-1-byoc-poc
            cluster: prod-seed-us-east-1-byoc-poc
          - env: aws-prod-ap-east-1-ng
            cluster: prod-seed-ap-east-1-ng
          - env: aws-prod-us-east-1-na-test
            cluster: prod-seed-us-east-1-na-test
          - env: alicloud-prod-ali-apne1ng
            cluster: prod-seed-ali-apne1ng
          - env: aws-prod-us-west-2-ess
            cluster: prod-seed-us-west-2-ess
          - env: aws-prod-us-west-2-na-test
            cluster: prod-seed-us-west-2-na-test
          - env: aws-prod-us-west-2-byoc-fnu
            cluster: prod-seed-us-west-2-byoc-fnu
          - env: aws-prod-ap-east-1-ess
            cluster: prod-seed-ap-east-1-ess
          - env: aws-prod-ap-northeast-1-ess
            cluster: prod-seed-ap-northeast-1-ess
          - env: aws-prod-ap-south-1-prem
            cluster: prod-seed-ap-south-1-prem
          - env: aws-prod-ap-south-1-ess
            cluster: prod-seed-ap-south-1-ess
          - env: alicloud-prod-ali-apse1-ess
            cluster: prod-seed-ali-apse1-ess
          - env: aws-prod-byoc-usw2-mithra
            cluster: prod-seed-byoc-usw2-mithra
          - env: alicloud-prod-ali-cnhk-ess
            cluster: prod-seed-ali-cnhk-ess
          - env: aws-prod-us-east-1-byoc-se
            cluster: prod-seed-us-east-1-byoc-se
          - env: aws-prod-us-west-2-byoc-se
            cluster: prod-seed-us-west-2-byoc-se
          - env: aws-prod-apne2-prem
            cluster: prod-seed-apne2-prem
          - env: aws-prod-use1-byoc-jpg-test
            cluster: prod-seed-use1-byoc-jpg-test
          - env: aws-prod-apse1-ess
            cluster: prod-seed-apse1-ess
          - env: aws-prod-byoc-apne1-0908
            cluster: prod-seed-byoc-apne1-0908
          - env: aws-prod-us-west-2-canary
            cluster: prod-seed-us-west-2-canary
  template:
    metadata:
      name: "{{env}}-nextgen-o11y-agent"
    spec:
      project: default
      sources:
        - repoURL: https://helm.vector.dev
          chart: vector
          targetRevision: 0.17.1
          helm:
            releaseName: o11ystack-seed
            valueFiles:
              - $values/nextgen-regional-control-plane/o11y-agent/envs/{{env}}/vector-values.yaml
        - repoURL: https://github.com/tidbcloud/app-delivery.git
          targetRevision: HEAD
          path: "nextgen-regional-control-plane/o11y-agent/common"
        - repoURL: https://github.com/tidbcloud/app-delivery.git
          targetRevision: HEAD
          path: "nextgen-regional-control-plane/o11y-agent/envs/{{env}}"
          directory:
            exclude: "vector-values.yaml"
        - repoURL: https://github.com/tidbcloud/app-delivery.git
          targetRevision: HEAD
          ref: values
      destination:
        namespace: logging
        name: "{{cluster}}"
      syncPolicy:
        automated:
          selfHeal: true
          prune: true
        syncOptions:
          - CreateNamespace=true
        retry:
          limit: 5
          backoff:
            duration: 5s
            factor: 2
            maxDuration: 3m
