Kubeless | Simple Scheduled Function

This example demonstrates a simple sexample in Python for a scheduled function.



Clone This Example

Step #1 - npm install serverless -g
Step #2 - serverless install -u https://github.com/serverless/examples/tree/master/kubeless-python-simple-scheduled-function -n  kubeless-python-simple-scheduled-function

Serverless Boilerplate - Kubeless - Python

Make sure kubeless and serverless are installed. See the respective installation guides:

Please see the this guide for more information.

1. Install Service Dependencies

Run npm install in this directory to download the modules from package.json.

2. Setting the schedule

You can check that we are setting the function schedule in the serverless.yml file. This schedule should follow the Cron notation. In this example we are setting it to * * * * * for the function to be executed every minute.

3. Deploy

Run serverless deploy in order to deploy the function defined in serverless.yml

$ serverless deploy
Serverless: Packaging service...
Serverless: Deploying function clock...
Serverless: Function clock successfully deployed

3. Check the function logs

Run serverless logs --function clock

In your terminal window you should see the consecutive executions of the scheduled function:

$ sls logs -f clock
Bottle v0.12.13 server starting up (using CherryPyServer())...
Listening on
Hit Ctrl-C to quit. - - [26/Sep/2017:10:25:27 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/153 - - [26/Sep/2017:10:25:41 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/96
10:26 - - [26/Sep/2017:10:26:04 +0000] "GET / HTTP/1.1" 200 5 "" "Wget" 0/1647 - - [26/Sep/2017:10:26:11 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/95 - - [26/Sep/2017:10:26:41 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/100

For more information on the Serverless Kubeless plugin, please see the project repository: https://github.com/serverless/serverless-kubeless.

view on Github

Latest commit b2f54ec on Sep 24, 2017

New to serverless?

To get started, pop open your terminal & run:

npm install serverless -g