cloudfoundry-community / autosleep

Auto sleep service for CloudFoundry
Apache License 2.0
39 stars 21 forks source link

Autosleep

Build Status Coverage Status

license releases Slack channel

Goal

The aim of the auto-sleep project is to give the ability for Cloud Foundry users to automatically have their app stopped after a given period of inactivity, and then automatically started when accessed through traffic received on their routes.

Status

You can check the full specifications and the currently supported features in the acceptance tests.

Get a deeper introduction in the Autosleep talk at Cf Summit Santa Clara 2016 ( slides, youtube video recording, and high-res demo )

Autosleep Cf Summit Santa Clata 2016 talk

What's already working:

For now we provide a service broker which instances will:

Download latest release if you want to give it a try, or build from sources

What we are working on:

We manage our roadmap as github issues (also displayed as milestones in huboard. Detailed breakdown of org enrollement is in pivotal tracker, following is however an overview of planned short-term work:

Usage by CloudFoundry users

We suppose that the autosleep service broker is already available in your market place. If you need help on that check how to publish service broker.

Create your autosleep service instance

Basics

Create an autosleep service instance to watch all applications in the space and automatically put them to sleep after default idle duration:

cf cs autosleep default my-autosleep

Autosleep will periodically automatically bind every applications in the space to this service instance (if you want to fine tune which apps gets auto-bound, please use the exclude-from-auto-enrollment parameter to exclude some apps).

Once bound, your application will be watched for inactivity, and automatically stopped by the autosleep service. If you wish to disable this watch, simply unbind your application from the autosleep service instance.

Advanced configuration parameters

Optionally the autosleep service broker accepts the following parameters during service creation:

Only the auto-enrollment field is is mutable, i.e. is accepted on service updates, e.g. cf cs autosleep default my-autosleep -c '{"auto-enrollment": "normal", "secret": "Th1s1zg00dP@$$w0rd"}'

If you need to update other fields (e.g. idle-duration), rather choose to instanciate a new service instance.up

idle-duration

Duration after which bound applications will be considered as inactive. The time format used is [the ISO8601] (https://en.wikipedia.org/wiki/ISO_8601#Durations) duration format.

exclude-from-auto-enrollment

If you don't want all the application to be automatically bound, you can set this parameter with a regular expression to filter on application names.

:lock:auto-enrollment

By default this parameter is set as standard. If platform teams (admins, org managers, or specific members of the space) don't want all space members to be able to manually permanently unbound apps from the autosleep service themselves, then a forced mode is supported.

In a forced auto-enrollment mode then:

To enable to forced mode, set the auto-enrollment parameter to forced. As this is a protected parameter, you will have also have to provide a secret parameter.

secret

Provide a secret if you wish to set/change a protected parameter. Please save it carefully, has you will be asked to provide the same secret the next time you set/change a protected parameter. As a fallback, you may also use the credential password set at deployment time (see the security.user.password in publish documentation).

Usage by platform teams

How to build

If you wish to build the app yourself, go to build documentation.

How to deploy and publish

Once you built the application or if you got it from latest release, go to publish documentation.

How to test

Acceptance tests are available in the source code, as robotframework tests. More information here.