Configure Recurring Events
This topic describes the configuration to schedule recurring events.
The following table describes the configuration parameters.
Parameter | Parameter Type | Description | Required |
---|---|---|---|
apiVersion | String | The Smart Scaler API version. A set of resources that are exposed together, along with the version. The value must be v1alpha1 . | Mandatory |
kind | String | The name of a particular object schema. The value must be EventConfigSet . | Mandatory |
metadata | Object | The metadata describes parameters (names and types) and attributes that have been applied. | Mandatory |
spec | Object | The specification of the desired state of an object. | Mandatory |
Metadata Parameters
Parameter | Parameter Type | Description | Required |
---|---|---|---|
name | String | The application namespace. | Mandatory |
Spec Parameters
Parameter | Parameter Type | Description | Required |
---|---|---|---|
template | Object | The object contains the recurring events template parameters. | Mandatory |
recurrenceConfig | Object | The object represents a set of parameters related to the recurrence or scheduling of events. | Mandatory |
Template Configuration Parameters
Parameter | Parameter Type | Description | Required |
---|---|---|---|
metadata | Object | The metadata describes parameters (names and types) and attributes that have been applied. | Mandatory |
spec | Object | The specification of the desired state of an object. | Mandatory |
Template Metadata Parameters
Parameter | Parameter Type | Description | Required |
---|---|---|---|
name | String | The name of the EventConfig. | Mandatory |
Template Spec Parameters
Parameter | Parameter Type | Description | Required |
---|---|---|---|
displayName | String | The name of the upcoming event. | Mandatory |
eventDuration | AlphaNumeric | It is the duration of each instance of the recurring event. | Mandatory |
cooldownDuration | AlphaNumeric | The 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 |
applicationConfigName | String | The name of the applicationConfig created. This binds the services in the applicationConfig with this event. | Mandatory |
scalingRatioConfigName | String | The name of the scalingRatioConfig created. This binds the scaling ratios of services with this event. | Mandatory |
scalingConfiguration | Object | The scalingRatio description parameters. | Mandatory |
destinationContexts | List | The 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
Parameter | Parameter Type | Description | Required |
---|---|---|---|
minScalingFactor | Numeric | The 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 |
maxScalingFactor | Numeric | The 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.
Parameter | Parameter Type | Description | Required |
---|---|---|---|
schedule | AlphaNumeric | This parameter specifies the schedule or timing for the recurring event. | Mandatory |
startDate | Numeric | This parameter specifies the date and time when the recurring event should start. | Mandatory |
endDate | Numeric | This parameter specifies the date and time when the recurring event should end. | Mandatory |
concurrentFutureEvents | Numeric | This parameter specifies the number of concurrent future eventConfigs that would be generated preemptively. The default value is 3. | Mandatory |
cleanupCompletedEvents | Boolean | This 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