argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.89k stars 5.46k forks source link

Support label selectors for sync windows #2506

Open voidengineer opened 5 years ago

voidengineer commented 5 years ago

Summary

The new sync window feature is great! It would be even greater, if applications could not only be selected by name (maybe with wildcard) but also based on their labels.

Motivation

We have a lot of applications that are stateful (primary session-state) that should only be synced at night. It would be great to mark them with a label, say k8s.example.com/sync-policy: stateful and apply the matching sync window to it.

Proposal

Add a new field applicationSelector in spec.syncWindows[] following the rules for kubernetes label selectors, and match all applications in the project against them.

alexec commented 5 years ago

@adamjohnson01 fyi

adamjohnson01 commented 5 years ago

@voidengineer

When you say add a label to an application, are you referring to the application manifests or their resources? I think it would be a good idea to add labels to the application manifest and use those for matching windows. Currently the sync windows apply to the entire application so it would make sense for the labels to be part of the application manifest. If we wanted to make the sync windows even more granular and allow the ability to selective sync specific resources then labelling the resources would be the way to go but that could get complicated pretty quickly and I am not sure what a use case for that would be.

voidengineer commented 5 years ago

@adamjohnson01

I meant labels on the application manifest itself, not the individual resources. I agree that the later would be unnecessary complicated.

adamjohnson01 commented 5 years ago

@voidengineer. That is what I thought, I just wanted to make sure.

I am happy to work on this. I think it is a great idea.

alexec commented 5 years ago

I've reviewed the PR, and wondered if we can build this on top of the existing functionality as follows:

Add an optional field: SyncWindow.Selectors []string. This is one or more K8S label selector. For a window to match, it must match the namespace, cluster, and selector. This could be combined in two ways:

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

andre-taveira commented 4 years ago

Any update on the PR ? I'd love to use that feature on our projects. We have the same use case !

m-trojanowski commented 1 month ago

This is still relevant. It would be great to have it.