O'Reilly logo

Kubernetes for Serverless Applications by Russ McKendrick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required