根据条件在工作时间后缩小或删除不必要的工作负载
Winter Soldier can be used to
at user defined time of the day and conditions. Winter Soldier is an operator which expects conditions to be defined using CRD hibernator.
Overtime Kubernetes clusters end up with workloads which have outlived their utility and add to the TCO of infrastructure. Some prominent use cases are
Winter Soldier supports two type of actions on the workload
This action can be used to delete any Kubernetes object. eg
spec:
action: deleteThis condition can be used to change replicas of workload to 0. eg
spec:
action: sleepAt the end of hibernation cycle it sets replica count of workload to same number as it was before hibernation.
Hibernator uses gjson to select fields in Kubernetes objects and expr for conditions. Please check them out for advanced cases.
Objects can be included and excluded based on
selectors:
- inclusions:
- objectSelector:
name: ""
type: "deployment"
fieldSelector:
- AfterTime(Now(), AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '10h'))
namespaceSelector:
name: "all"
exclusions:
- objectSelector:
name: ""
type: "deployment"
namespaceSelector:
name: "kube-system"The above example will select Deployment kind objects which have been created 10 hours ago across all namespaces excluding kube-system namespace. Winter soldier exposes following functions to handle time, cpu and memory.
ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z')AddTime(ParseTime({{metadata.creationTimestamp}}, '2006-01-02T15:04:05Z'), '-10h') ll add 10h to the time. Use d for day, h for hour, m for minutes and s for seconds. Use negative number to get earlier time.any({{spec.containers.#.resources.requests}}, { MemoryToNumber(.memory) < MemoryToNumber('60Mi')}) will check if any resource.requests is less than 60MiThis defines the execution time
spec:
action: sleep
timeRangesWithZone:
reSyncInterval: 300 # in minutes
timeZone: "Asia/Kolkata"
timeRanges:
- timeFrom: 00:00
timeTo: 23:59:59
weekdayFrom: Sat
weekdayTo: Sun
- timeFrom: 00:00
timeTo: 08:00
weekdayFrom: Mon
weekdayTo: Fri
- timeFrom: 20:00
timeTo: 23:59:59
weekdayFrom: Mon
weekdayTo: FriAbove settings will take action on Sat and Sun from 00:00 to 23:59:59, and on Mon-Fri from 00:00 to 08:00 and 20:00 to 23:59:59. If action:sleep then runs hibernate at timeFrom and unhibernate at timeTo. If action: delete then it will delete workloads at timeFrom and timeTo.
spec:
pause: truespec:
pauseUntil: "Jan 2, 2026 3:04pm"spec:
hibernate: truespec:
unHibernate: true** Please Note: If both hibernate and unHibernate flag are set then hibernate flag is ignored
暂无开放 Issues,或尚未同步最近议题。