Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How to change sleeping time in kube-green

Use the SleepInfo resource in the target namespace to control when workloads sleep and wake up.

Check existing SleepInfo resources

kubectl get sleepinfo --all-namespaces

Edit a namespace configuration

For example, to edit the hh-ballbot namespace:

kubectl edit sleepinfo -n hh-ballbot

This command opens your default editor.

SleepInfo fields

  • weekdays: Days when the sleep rule applies. Use * for every day, 1 for Monday, or 1-5 for Monday to Friday.
  • sleepAt: Time in HH:mm when the namespace should sleep.
  • wakeUpAt: Time in HH:mm when the namespace should be restored.
  • timeZone: Time zone in IANA format, for example Asia/Jakarta.

When kube-green puts a namespace to sleep, deployments are scaled down to 0. If suspendCronJobs is enabled, cron jobs are also suspended.

If wakeUpAt is not set, workloads will not be restored automatically.

Example configuration

In hh-ballbot, the namespace is configured to sleep at 20:00 and wake up at 20:10 every day.

spec:
  sleepAt: "20:00"
  timeZone: Asia/Jakarta
  wakeUpAt: "20:10"
  weekdays: "*"

Update the values as needed, then save the file.

If you are using Vim, save and exit with:

:wq

After saving, kube-green will apply the new schedule automatically.