The basic example

First of all, we need our function. The static hello-world function requires the following three lines of Python code:

import jsondef handler():    return "Hello World!"

Place the preceding code, which is also available in the Chapter04/hello-world folder of the GitHub repository that accompanies this book, in a file called hello.py.

Now we have our function we can deploy it into the default namespace by running the following command:

$ kubeless function deploy hello \  --from-file hello.py  --handler hello.handler \  --runtime python2.7 \  --trigger-http

This command creates a function called hello, using the file hello.py. Whenever the function called hello.handler is executed, we are using the python2.7 runtime, and our function ...

Get Kubernetes for Serverless Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.