Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Custom AppSet generator - Schedules generator #16215

Open
Aym3nTN opened this issue Nov 2, 2023 · 8 comments
Open

[Proposal] Custom AppSet generator - Schedules generator #16215

Aym3nTN opened this issue Nov 2, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@Aym3nTN
Copy link
Contributor

Aym3nTN commented Nov 2, 2023

Summary

I'm suggesting to create an AppSet generator to un-apply/delete an Application using Cron expressions.

Motivation

My motivation is about cost savings, in my case, I have multiple applications that each uses an Ingress that is responsible for creating an AWS ALB (using AWS ALB Controller plugin) and alb costs money; therefore I'd like to automate shutting down my dev/stg environment when not needed like weekends or after work hours.

What do you think about that? The idea is similar to KubeGreen but acts on Argo Application resource level rather than Deployments resources.

@Aym3nTN Aym3nTN added the enhancement New feature or request label Nov 2, 2023
@crenshaw-dev
Copy link
Member

I think it's a cool idea. What would be the syntax?

You could probably do it today with a plugin. Pass the plugin some unique key (app name maybe) and a cron schedule, have the plugin pass back the unique key and a shutdown: true/false. Merge the plugin output with your other generators', and filter on the shutdown param.

@Aym3nTN
Copy link
Contributor Author

Aym3nTN commented Nov 2, 2023

Won't that require having my plugin's code deployed somewhere? I believe that would fit better in the applicationset_controller code base.

It can look something like that, we can adjust afterward:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: myapps
spec:
  generators:
  - schedules:
      weekdays: ["weekends", "Saturday', ...]
      workdays: "18:00-08:00"
      timezone: "UTC+1"

@crenshaw-dev
Copy link
Member

Yep, it would need to be deployed separately. I'm not opposed to having it in the main code, but there is a maintenance cost tradeoff. Given the current 400 PR backlog, it might be prudent to start with a plugin.

@Aym3nTN
Copy link
Contributor Author

Aym3nTN commented Nov 3, 2023

I will write it in Go so in the future I can add to this proposal.

@blakepettersson
Copy link
Member

Perhaps this could be done with a scale-to-zero feature as proposed in #6430? If we could scale an Application from 1 to 0 by implementing a scale subresource on it then we could potentially use something like KEDA to scale an application up and down.

@Aym3nTN
Copy link
Contributor Author

Aym3nTN commented Nov 13, 2023

@blakepettersson This issue is more general then the other one since in this one we're looking at not generating the "Application" at all to begin within which means no having the create any sub-k8s resources that the "Application" was supposed to generate.

@blakepettersson
Copy link
Member

@Aym3nTN this could also/or be implemented on the ApplicationSet resource as well. We could have the same semantics as deleting an Application[Set] if we were to scale it down to zero. I'm not sure if this is even workable, it's just a crazy idea that I have 😄

@blakepettersson
Copy link
Member

Hmm, thinking a bit more about this it would probably be a better approach to extend SyncWindows as proposed in #11755, with an added option to scale-down/remove resources in a given window.

There's overlap with #16063, where the issue is to protect an Application from being deleted, but perhaps this could also then be extended to ensure the deletion of an application during that window.

Then it'd be possible to have an AppProject scoped sync window where a generated application could be allowed to scale down within a given window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants