Repeat Schedule¶
It schedule the chaos in the repeat mode. There are various ways we can set up this type of schedule by varying the the fields inside spec.repeat
.
Note
- We have just one field i.e. minChaosInterval to be specified as mandatory one. All other fields are optional and totally dependent on the desired behaviour.
View the schedule repeat schema
Field | .spec.schedule.repeat.timeRange.startTime |
---|---|
Description | Flag to specify start timestamp of the range within which chaos is injected, when the policy is repeat . The chaosengine is not created before this timestamp. |
Type | Mandatory |
Range | user-defined (type: UTC Timeformat) |
Default | n/a |
Notes | When startTime is specified against the policy repeat , ChaosEngine will not be formed before this time, no matter when it was created. |
Field | .spec.schedule.repeat.timeRange.endTime |
---|---|
Description | Flag to specify end timestamp of the range within which chaos is injected, when the policy is repeat . The chaosengine is not created after this timestamp. |
Type | Mandatory |
Range | user-defined (type: UTC Timeformat) |
Default | n/a |
Notes | When endTime is specified against the policy repeat , ChaosEngine will not be formed after this time. |
Field | .spec.schedule.repeat.properties.minChaosInterval.hour.everyNthHour |
---|---|
Description | Flag to specify the hours between each successive schedule |
Type | Mandatory |
Range | integer |
Default | n/a |
Notes | The minChaosInterval.hour.everyNthHour in the spec specifies the time interval in hours between each schedule |
Field | .spec.schedule.repeat.properties.minChaosInterval.hour.minuteOfTheHour |
---|---|
Description | Flag to specify minute of hour for each successive schedule |
Type | Mandatory |
Range | integer |
Default | 0 |
Notes | The minChaosInterval.hour.minuteOfTheHour in the spec specifies the minute of the hour between each schedule |
Field | .spec.schedule.repeat.properties.minChaosInterval.minute.everyNthMinute |
---|---|
Description | Flag to specify the minutes for each successive schedule |
Type | Mandatory |
Range | integer |
Default | n/a |
Notes | The minChaosInterval.hour.everyNthMinute in the spec specifies the time interval in minutes between each schedule |
Field | .spec.schedule.repeat.workDays.includedDays |
---|---|
Description | Flag to specify the days at which chaos is allowed to take place |
Type | Mandatory |
Range | user-defined (type: string)(pattern: [{day_name},{day_name}...]). |
Default | n/a |
Notes | The includedDays in the spec specifies a (comma-separated) list of days of the week at which chaos is allowed to take place. {day_name} is to be specified with the first 3 letters of the name of day such as Mon , Tue etc. |
Field | .spec.schedule.repeat.workHours.includedHours |
---|---|
Description | Flag to specify the hours at which chaos is allowed to take place |
Type | Mandatory |
Range | {hour_number} will range from 0 to 23 (type: string)(pattern: {hour_number}-{hour_number}). |
Default | n/a |
Notes | The includedHours in the spec specifies a range of hours of the day at which chaos is allowed to take place. 24 hour format is followed
|
Basic Schema to Execute Repeat Strategy¶
This will keep executing the schedule and creating engines for an indefinite amount of time.
Schedule ChaosEngine at every nth minute¶
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
properties:
minChaosInterval:
# schedule the chaos at every 5 minutes
minute:
everyNthMinute: 5
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Schedule ChaosEngine at every nth hour¶
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
properties:
minChaosInterval:
# schedule the chaos every hour at 0th minute
hour:
everyNthHour: 1
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Schedule ChaosEngine at nth minute of every nth hour¶
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
properties:
minChaosInterval:
# schedule the chaos every hour at 30th minute
hour:
everyNthHour: 1
minuteOfTheHour: 30
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Specifying Time Range for the Chaos Schedule¶
This will manipulate the schedule to be started and ended according to our definition.
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
timeRange:
#should be modified according to current UTC Time
startTime: "2020-05-12T05:47:00Z"
endTime: "2020-09-13T02:58:00Z"
properties:
minChaosInterval:
minute:
everyNthMinute: 5
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Specifying Just the End Time¶
Assumes the custom resource creation timestamp as the StartTime
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
timeRange:
#should be modified according to current UTC Time
endTime: "2020-09-13T02:58:00Z"
properties:
minChaosInterval:
minute:
everyNthMinute: 5
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Specifying Just the StartTime¶
Executes chaos indefinitely (until the ChaosSchedule CR is removed) starting from the specified timestamp
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
timeRange:
#should be modified according to current UTC Time
startTime: "2020-05-12T05:47:00Z"
properties:
minChaosInterval:
minute:
everyNthMinute: 5
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
auxiliaryAppInfo: ''
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Specifying Work Hours¶
This ensures chaos execution within the specified hours of the day, everyday.
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
properties:
minChaosInterval:
minute:
everyNthMinute: 5
workHours:
# format should be <starting-hour-number>-<ending-hour-number>(inclusive)
includedHours: 0-12
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
# It can be true/false
annotationCheck: 'true'
#ex. values: ns1:name=percona,ns2:run=nginx
auxiliaryAppInfo: ''
chaosServiceAccount: pod-delete-sa
# It can be delete/retain
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Specifying work days¶
This executes chaos on specified days of the week, with the specified minimum interval.
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
spec:
schedule:
repeat:
properties:
minChaosInterval:
minute:
everyNthMinute: 5
workDays:
includedDays: "Mon,Tue,Wed,Sat,Sun"
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
auxiliaryAppInfo: ''
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'