Schedules
The Scheduled Jobs feature allows administrators to automate tasks such as deployments, destructions, or workflow executions at the Environment Template level using cron expressions. This feature provides flexibility for users to opt out of predefined schedules through configurable rules and approval workflows, ensuring efficient management of routine operations.
Example Use Cases
- Provision an Environment: Automatically provision an environment at the beginning of each week, e.g., Monday at 6:00 AM
- Destroy an Environment: Automatically destroy an environment at the end of the week, e.g., Friday at 10:00 PM
- Free Up Space: Clear all attached volumes at a specified time
Environment Template Specification Example¶
The following example includes two schedules:
- First Schedule: Configured with a Time-To-Live (TTL) value of 10 minutes. When the environment is deployed, the destruction schedule is triggered 10 minutes later.
- Second Schedule: Configured with the cron expression 44 * * * *, which executes the schedule based on the defined time pattern.
apiVersion: eaas.envmgmt.io/v1
kind: EnvironmentTemplate
metadata:
description: Environment Template for ec2 Resources
name: rautoenv-tmp1-dash-220886
project: defaultproject
spec:
hooks: {}
resources:
- kind: resourcetemplate
name: rautort1-dash-220886
resourceOptions:
version: version2-220886
type: dynamic
schedules:
- cadence:
timeToLive: 10m
name: ttl
optOutOptions:
allowOptOut: true
maxAllowedDuration: 2d
maxAllowedTimes: 3
type: destroy
- cadence:
cronExpression: 44 * * * *
cronTimezone: Asia/Kolkata
description: Destroy the ec2 instance
name: destroy1-ec2-instance
optOutOptions:
allowOptOut: true
maxAllowedDuration: 1d
maxAllowedTimes: 5
type: destroy
version: v33
versionState: active
Setting | Description |
---|---|
apiVersion | Rafay’s API version eaas.envmgmt.io/v1 . |
Kind | EnvironmentTemplate . |
spec -> schedules | Configures schedules for jobs with the following fields: Required - name (String): Name of the schedule. - type (String): Schedule type, available options are deploy , destroy , and workflows . - cadence (Block List, Max: 1): Configure a cadence for automatic job triggering. Optional - description (String): Description of the schedule. - context (Block List, Max: 1): Input data configuration required for the schedule run. - workflows (Block List, Max: 1): Name of the custom workflow provider executed with the job. - opt_out_options (Block List, Max: 1): Opt-out options for the schedule. Schema for cadence - cron_expression (String): Cron expression for scheduling jobs. - cron_timezone (String): Timezone for the cron expression. - time_to_live (String): Maximum environment lifetime, using units like h (hours) or d (days), e.g., 8h or 2d . You can choose either cron_expression or time_to_live . (String): Maximum environment lifetime, using units like h (hours) or d (days), e.g., 8h or 2d . You can choose either cron_expression or time_to_live . Schema for opt-outs - allow_opt_out (Bool): Specify if users can opt out from this schedule. Optional - max_allowed_duration (String): Maximum opt-out duration, e.g., 8h or 2d . - max_allowed_times (Number): Maximum number of opt-outs without approval, e.g., users can opt out up to three times. - approval (Block List, Max: 1): Details of approval workflow for opt-outs. |