Hello world
To start off with we are going to look at deploying two very simple hello world functions. The first simply prints Hello World!
and the second takes an input and then displays it back to you.
The basic example
First of all, we need our function. The static hello-world function requires the following three lines of Python code:
import json def 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 is set to be triggered by an http
request...