Open Aym3nTN opened 1 year ago
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.
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"
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.
I will write it in Go so in the future I can add to this proposal.
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.
@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.
@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 😄
Hmm, thinking a bit more about this it would probably be a better approach to extend SyncWindow
s 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.
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.