Features | Open Source | Releases | Docs | Try us free | Blog | Product
How to use the Serverless Manager module?
Available since version 3.2.0
- 1 Introduction
- 2 Applications
- 2.1 List
- 2.2 Creation
- 2.3 Modification
- 2.4 Deleted
- 2.5 View
- 3 Functions
- 3.1 Creation
- 3.2 Update
- 3.3 Remove
- 3.4 Deployment
- 3.5 HTTP Invocation
Introduction
In this guide we will explain how to use the Serverless platform module, in order to deploy functions similar to microservices functionality.
We recommend taking a look at this guide to understand the different concepts involved in this functionality.
Applications
List
If we go within the Development menu to My Serverless Applications/Serverless Application Management (depending on the role we have), we will go to a list where all our created applications will be shown.
For each function, data will be shown in the table such as: owner, Git repository, number of functions in the application...
Creation
To create a new application, we will have to click on the '+' icon in the list.
When creating a new application, we will be asked for the Git credentials (GitHub or GitLab), and we will be asked if we want to create a new project associated with that application, if not we will also have to specify the URL of the existing Git repository.
This Git repository created or already existing, will be the working repository where we will develop the functions of the application.
NOTE: soon we will incorporate a functionality that will allow us to create applications with several archetypes as an example on which to start developing the functions.
Modification
In the application modification screen, accessible from the list through the pencil icon, we can only modify the information related to the name and the Git configuration.
Deleted
The application can be deleted both from the list and from the edit and view pages.
The only thing to keep in mind is that even if the application and its functions are deleted, the Git repository will not be deleted.
View
From the view page we will be able to see both the general information of the application and the list of its functions.
General information:
Here we will find the information related to Git, as well as the environment variables defined in the application.
These environment variables will be accessible from each and every function of the application, however they can be overwritten at function level.
List of functions:
In the second tab of the view, we can see a list of functions with relevant data such as: function version, allocated memory, name, relative path within the Git project, invocation endpoints...
In addition, from this list, we can create, edit, delete and deploy functions.
Functions
Creation
From the application view we can create new functions.
When creating a function we will only be asked for the name of the function and the relative path within the Git repository. At the time of creation it is not necessary that the code associated with the function exists within the repository, but it will have to exist when deploying it.
Code structure of a function
The structure of the function will be given by the programming language to be used, it could be a maven project, java, go, python... Here is a list of the supported languages.
Whatever the language, it will be necessary to include in the root directory of the function a file 'func.yaml', where the necessary information for the compilation, deployment and execution of the function will be included.
Below is an example of a structure with a maven function and a python function.
To complete the func.yaml file, we recommend to see this document where each property is explained.
Func.yaml of a Java function
schema_version: 20180708
name: ontology
version: 0.0.26
runtime: java11
build_image: fnproject/fn-java-fdk-build:jdk11-1.0.124
run_image: fnproject/fn-java-fdk:jre11-1.0.124
cmd: com.minsait.onesait.OntologyCalculationFn::handleRequest
config:
API_KEY: 26104876616f40908e3643ed1f6357d1
GRAYLOG_HOST: log-centralizer
GRAYLOG_PORT: "12201"
triggers:
- name: endpoint
type: http
source: /calculate
Func.yaml of a Python function
schema_version: 20180708
name: pythonfn
version: 0.0.1
runtime: python
entrypoint: /python/bin/fdk /function/func.py handler
memory: 256
config:
API_KEY: 26104876616f40908e3643ed1f6357d1
triggers:
- name: endpoint
type: http
source: /pythonfn
Below is a zip file with 3 examples of functions.
Update
In the modification screen of a function we will be able to update both the name of our function and the relative path within the repository.
Remove
We will be able to delete a function (but not the repository code) from the list of functions of an application or from the modification screen.
Deployment
When we have our function ready, we can deploy it from the rocket icon in the list of functions.
This may take up to 1 minute. Once the deployment is finished, the page will be reloaded and we will see how the version of the deployed function is increased (it will be reflected in the func.yaml of the repository with a commit).
HTTP Invocation
Once the function is deployed, we can invoke it via HTTP to execute/test it. There are two types of invocable endpoints: auto-generated and HTTP triggers.
The first ones are automatically generated by the fn manager, and the second ones are defined from the func.yaml
Auto-generated always take the form of /fn/invoke/{UUID} and will always be POST requests.
Triggers can be invoked with the GET or POST verb, depending on whether our function needs to receive a payload or not.