Lithops with OpenWhisk as serverless compute backend. Lithops can also run functions on vanilla OpenWhisk installations, for example by deploying OpenWhisk with openwhisk-devtools.
-
install the openwhisk-cli
-
Make sure you can run end-to-end python example.
For example, create a file named
hello.pywith the next content:def main(args): name = args.get("name", "stranger") greeting = "Hello " + name + "!" print(greeting) return {"greeting": greeting}
Now issue the
wskcommand to deploy the python action:wsk action create helloPython hello.pyFinally, test the helloPython action:
wsk action invoke --result helloPython --param name World
-
Edit your Lithops config and add the following keys:
lithops: backend: openwhisk openwhisk: endpoint : <OW_ENDPOINT> namespace : <NAMESPACE> api_key : <AUTH_KEY> insecure : <True/False>
-
You can find all the values in the
~/.wskpropsfile. The content of the file should looks like:APIHOST=192.168.1.30 AUTH=23bc46b1-71f6-4ed5-8c54-816aa4f8c50:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCG INSECURE_SSL=true NAMESPACE=guestCopy all the values into the lithops config file as:
openwhisk: endpoint : https://192.168.1.30 namespace : guest api_key : 23bc46b1-71f6-4ed5-8c54-816aa4f8c50:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCG insecure : True
-
| Group | Key | Default | Mandatory | Additional info |
|---|---|---|---|---|
| openwhisk | endpoint | yes | API Host endpoint | |
| openwhisk | namespace | yes | Namespace | |
| openwhisk | api_key | yes | API Auth | |
| openwhisk | insecure | yes | Insecure access | |
| openwhisk | max_workers | 100 | no | Max number of workers per FunctionExecutor() |
| openwhisk | worker_processes | 1 | no | Number of Lithops processes within a given worker. This can be used to parallelize function activations within a worker |
| openwhisk | runtime | no | Docker image name | |
| openwhisk | runtime_memory | 256 | no | Memory limit in MB. Default 256MB |
| openwhisk | runtime_timeout | 600 | no | Runtime timeout in seconds. Default 10 minutes |
| openwhisk | invoke_pool_threads | 500 | no | Number of concurrent threads used for invocation |
Once you have your compute and storage backends configured, you can run a hello world function with:
lithops hello -b openwhisk -s ibm_cosYou can view the function executions logs in your local machine using the lithops client:
lithops logs poll