Skip to content
This repository was archived by the owner on Jul 15, 2024. It is now read-only.
This repository was archived by the owner on Jul 15, 2024. It is now read-only.

Git generator with condition #598

@rshiva777

Description

@rshiva777

I am using git generator for deploying applications. I want to deploy an application on to a cluster only if the cluster has particular labels matched in applicationset, else ignore it

If i remove the cluster generator part from the manifest and keep only git generator, application are creating on all the cluster configs that are present on the below path

applicationsets/git-generator/cluster-config/**/config.yaml

I want an feature where i can restrict the app deployment to destination cluster, it should happen only when the secret of cluster in argocd has the below label:

app: testapp

Below is a sample manifest

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: bgd
  namespace: openshift-gitops
spec:
  generators:
  - git:
      repoURL: https://github.com/christianh814/gitops-examples
      revision: master
      files:
      - path: "applicationsets/git-generator/cluster-config/**/config.yaml"
  - clusters:
      selector:
        matchLabels:
          app: testapp
  template:
    metadata:
      name: '{{cluster.name}}-bgd'
    spec:
      project: default
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
      source:
        repoURL: https://github.com/christianh814/gitops-examples
        targetRevision: master
        path: applicationsets/git-generator/overlays/{{cluster.overlay}}
      destination:
        server: '{{cluster.server}}'
        namespace: bgd

Here is the sample config file of a single cluster:
applicationsets/git-generator/cluster-config/testcluster/config.yaml

cluster:
  name: testcluster
  server: test.apiserver.com:6443
  overlay: testapp

The above applicationset should create an application on if the destination cluster has the below labels in argocd secret:

app: testapp

I tried to check on merge generator with git and cluster generators, but didnt find any clues to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions