Snorlax is a Kubernetes operator that wakes and sleeps a specified set of Kubernetes deployments on a schedule.
You can also specify ingresses which will be updated to point to a wake server when asleep. When a request is received, the wake server serves a "waking up" splash page and wakes the deployments up. Once the deployments are ready, the ingresses are restored and the splash page will auto-refresh.
Sleeping your environments is the equivalent of turning off the lights at night.
As a common example, if you sleep all of your staging/ephemeral deployments for 8 hours each night and on weekends, they'll sleep ~55% of the month. That means ~55% savings on your cloud bill for those resources.
Install the snorlax
Helm chart to install the SleepSchedule
CRD and controller
helm repo add moonbeam https://moonbeam-nyc.github.io/helm-charts
helm repo update
helm install snorlax moonbeam/snorlax --create-namespace --namespace snorlax
Create your SleepSchedule
resource to define the schedule for the deployment
# filename: your-app-sleep-schedule.yaml
apiVersion: snorlax.moonbeam.nyc/v1beta1
kind: SleepSchedule
metadata:
namespace: your-app-namespace
name: your-app
spec:
# Required fields
wakeTime: '8:00am'
sleepTime: '10:00pm'
deployments:
- name: your-app-frontend
- name: your-app-db
- name: your-app-redis
# (optional) the ingresses to update and point to the snorlax wake server,
# which wakes your deployment when a request is received while it's
# sleeping.
ingresses:
- name: your-app-ingress
# (optional, defaults to all deployments) specify which deployments
# must be ready to wake this ingress
requires:
- deployment:
name: your-app-frontend
# (optional, defaults to UTC) the timezone to use for the input times above
timezone: 'America/New_York'
Apply the SleepSchedule
resource
kubectl apply -f your-app-sleep-schedule.yaml
(Requires make
, minikube
and helm
to be installed)
Run make demo
to:
snorlax
localhost
to your Minikube cluster ingress service (you'll need to enter your password)Then go to http://localhost to see either the sleeping page or the dummy deployment (depending on the time of day).
You can also then try updating the sleep schedule with kubectl edit sleepschedule dummy
.
(Requires make
, minikube
, helm
, and docker
to be installed)
Setup Minikube with the CRD and dummy application with sleep schedule:
make dev-setup
Then make your updates and run the operator:
make dev-run
0 8 * * *
)Wondering how to best use Snorlax? Have questions or ideas for new features?
I'd love to hear, and maybe even build them! Reach out to me at: