Quick start guide ================= Quick start guide describes the simplest example that allows you to create and run your own lambda local or in kubernetes cluster. .. note:: Here and below will be presented the simplest useless example of lambda. For applicable in real life cases, detailed requirements, lifecycle and other description see `detailed lambdas description `_. Local lambda execution ---------------------- #) Create virtual environment and install `luna-lambda-tools` package. (available at `VL pypi `_) .. code-block:: bash pip install --trusted-host pypi.visionlabs.ru --extra-index-url http://pypi.visionlabs.ru/root/public/+simple luna-lambda-tools #) Create the main file: .. code-block:: :caption: lambda_main.py from luna_lambda_tools import StandaloneLambdaRequest async def main(request: StandaloneLambdaRequest) -> dict: return {"request_length_in_bytes": len(request.body)} #) Create file for lambda local execution (it only needs to execute lambda local): .. code-block:: :caption: run.py from luna_lambda_tools.public.run import run if __name__ == "__main__": run(lambdaType="standalone") #) Execute lambda using configuration from running instance of configurator: .. code-block:: bash python run.py --luna-config http://127.0.0.1:5070/1 All requests to lambda must use `/main` endpoint. If there no errors on previous steps, when sending the following request, the following response will be received: .. code-block:: bash curl -X POST "http://127.0.0.1:8000/main" --data-binary 123 >>> {"request_length_in_bytes":3} Deploy lambda using `Luna lambda` into kubernetes cluster --------------------------------------------------------- .. note:: `Luna-Api` provides necessary methods to create and use lambdas at `lambda` section of openapi documentation. #) `Luna-Lambda` requires kubernetes cluster to work with. It is possible to use `minikube `_ as temporary solution for lambda development. To use minikube it needs to properly specify *CLUSTER* location setting, more information about configuration and settings available `here <./config.html#configuration-requirements>`_. There are also some additional requirements `for lambda <./lambda_requirements.html#lambda-general-python-code-requirements>`_ and `kubernetes cluster <./lambda_requirements.html#kubernetes-cluster-requirements>`_. #) Install and execute `Luna-Lambda` (see `installation chapter <./install.html>`_ for details). #) Create zip-archive with `lambda_main.py` file from previous step of quick start guide. #) Create lambda using zip-archive by making `lambda creation request <./_static/api.html#operation/createLambda>`_. #) Wait for lambda starts and check its availability, see `lambda usage chapter <./lambda_usage.html>`_ for details.