Skip to main content
Version: 2.13.0

Configure Recurring Events

This topic describes the configuration to schedule recurring events.

The following table describes the configuration parameters.

ParameterParameter TypeDescriptionRequired
apiVersionStringThe Smart Scaler API version. A set of resources that are exposed together, along with the version. The value must be v1alpha1.Mandatory
kindStringThe name of a particular object schema. The value must be EventConfigSet.Mandatory
metadataObjectThe metadata describes parameters (names and types) and attributes that have been applied.Mandatory
specObjectThe specification of the desired state of an object.Mandatory

Metadata Parameters

ParameterParameter TypeDescriptionRequired
nameStringThe application namespace.Mandatory

Spec Parameters

ParameterParameter TypeDescriptionRequired
templateObjectThe object contains the recurring events template parameters.Mandatory
recurrenceConfigObjectThe object represents a set of parameters related to the recurrence or scheduling of events.Mandatory

Template Configuration Parameters

ParameterParameter TypeDescriptionRequired
metadataObjectThe metadata describes parameters (names and types) and attributes that have been applied.Mandatory
specObjectThe specification of the desired state of an object.Mandatory

Template Metadata Parameters

ParameterParameter TypeDescriptionRequired
nameStringThe name of the EventConfig.Mandatory

Template Spec Parameters

ParameterParameter TypeDescriptionRequired
displayNameStringThe name of the upcoming event.Mandatory
eventDurationAlphaNumericIt is the duration of each instance of the recurring event.Mandatory
cooldownDurationAlphaNumericThe cooldown duration is a time period during which the auto-scaling system pauses further scaling actions after a scaling event has occurred. It helps prevent rapid and frequent scaling adjustments in response to short-term fluctuations or noise in the traffic.Mandatory
applicationConfigNameStringThe name of the applicationConfig created. This binds the services in the applicationConfig with this event.Mandatory
scalingRatioConfigNameStringThe name of the scalingRatioConfig created. This binds the scaling ratios of services with this event.Mandatory
scalingConfigurationObjectThe scalingRatio description parameters.Mandatory
destinationContextsListThe list of the names of your Kubernetes cluster where each application is deployed. You can use the cluster name added in ArgoCD.Mandatory only when applications configuration is manually created without depending on ArgoCD.

Template Scaling Configuration parameters

ParameterParameter TypeDescriptionRequired
minScalingFactorNumericThe minimum scaling factor is a numerical value that defines the lower limit for how much a service or component can be scaled down when autoscaling is triggered. It is often expressed as a percentage or a whole number.Mandatory
maxScalingFactorNumericThe maximum scaling factor is a numerical value that defines the upper limit for how much a service or component can be scaled up when autoscaling is triggered. It is often expressed as a percentage or a whole number.Mandatory

Recurrence Configuration Parameters

The following table describes the recurrence configuration parameters.

ParameterParameter TypeDescriptionRequired
scheduleAlphaNumericThis parameter specifies the schedule or timing for the recurring event.Mandatory
startDateNumericThis parameter specifies the date and time when the recurring event should start.Mandatory
endDateNumericThis parameter specifies the date and time when the recurring event should end.Mandatory
concurrentFutureEventsNumericThis parameter specifies the number of concurrent future eventConfigs that would be generated preemptively. The default value is 3.Mandatory
cleanupCompletedEventsBooleanThis parameter specifies to cleanup past completed events. The default value is false.Mandatory

Create the Recurring Events Configuration

Create the recurring events configuration of the EventConfigSet kind. The EventConfigSet consists of two sections: template and recurrenceConfig. The template section includes the parameters for an EventConfig, the parameters for an upcoming event. The recurrenceConfig section includes the parameters to schedule recurring events. You can schedule the recurring events using cron expressions. To know more, see crontab guru.

The following is an example recurring events configuration YAML file.

apiVersion: agent.smart-scaler.io/v1alpha1
kind: EventConfigSet
metadata:
name: weekend-sale
spec:
template:
metadata:
name: weekend-sale # need a way to generate a event specific name
# other metadata fields
spec:
displayName: WeekendSale
eventDuration: 24h
cooldownDuration: 30s
applicationConfigName: applicationconfig-sample ## references applicationConfig CR
scalingRatioConfigName: scalingratioconfig-sample ## references scalingConfig CR
scalingConfiguration:
minScalingFactor: "10.2"
maxScalingFactor: "20.4"
destinationContexts:
- ca-central-1
- us-south-east-2
- us-west-2
recurrenceConfig:
schedule: "0 0 * * 0,6" # support only recurring type schedule
startDate: "2023-12-12" # Date from which the schedule would start
endDate: "2024-12-12" # Date at which the schedule would end
concurrentFutureEvents: 2 # no. of concurrent future eventConfigs that would be generated
cleanupCompletedEvents: false # Cleanup completed events

In the above configuration file, you will schedule recurring events for an upcoming event. This configuration creates eventConfig's for all the weekends.

The schedule expressions provide the eventConfig start time. If the cron expression for the schedule parameter in the recurrenceConfig section is 0 10 * * 0,6, the job starts on 2023-12-16 (at 00:00 on Sunday and Saturday). If the concurrentFutureEvents parameter is 2, the EvenConfigSet creates two eventConfig's, resulting in a pool of preloaded two eventConfig events. The eventDuration parameter in the template section specifies the end of the eventConfig's. If the parameter value is 24h, the job will end after 24 hours.

The starDate and endDate parameters are applicable for the eventConfigSet. If job must run for an entire year, the startDate is 2023-12-12 and endDate is 2024-12-12.

Apply the Configuration

Use the following command to apply the configuration YAML file:

kubectl  apply -f recurring-events.yaml -n smart-scaler