Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this guide we will explain how to use the Serverless platform module, in order to deploy functions similar to the functionality of microservices functionality.

We recommend taking a look at this guide to understand the different concepts involved in this functionality.

Concepts

A new module has been We have integrated into the platform a new module that allows the development of components in the form of Functions, using a serverless architecture. This module is based on the Open Source project fn project.

Following the scheme proposed by fn, we distinguish two concepts to be taken into account: applications and functions.

Applications encompass a set of functions, and each platform user can create as many applications as needed. These applications will have a working Git repository associated with them, where the code of all the functions that belong to these applications will reside.

Likewise, within each application, N functions can be created. For practical purposes, a function will be a code project (javaJava/mavenMaven, pythonPython, ...) with a structure that we will detail later. Each function will be responsible for executing a specific functionality.

Applications

List

If we you go within the Development menu to My Serverless Applications/ or Serverless Application Management (depending on the role we you have), we you will go to see a list where all our your created applications will be shown.

...

For each function, data will be shown in the table will show data such as: owner, Git repository, number of functions in the application...

...

To create a new application, we will have to click on the '+' icon in the list.

When creating a new application, we you will be asked for the Git credentials (GitHub or GitLabGitLab), and we you will be asked if we you want to create a new project associated with that application, if not we . If not, you 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 you will develop the functions of the application.

NOTE: soon 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.

...

Update

In the application modification screen, accessible from the list through the pencil icon, we you can only modify the information related to the name and the Git configuration.

...

...

Deletion

The application can be deleted both from the list and from the edit and view pages.

The only thing to keep bear 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 , you can see both the general information of the application and the list of its functions.

General information:

Here we you 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, however they can be overwritten at function level.

...

List of functions:

In the second tab of the view, we you 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 you can create, edit, delete and deploy 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 . 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 with the necessary information for the compilation, deployment and execution of the function will be included.

Below Next 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:

Code Block
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:

Code Block
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

...

View file
nameexamples-serverless.zip

Update

In the modification update screen of a function we , you will be able to update both the name of our your function and the relative path within the repository.

Remove

We will be able to You can delete a function (but not the repository code) from the list of functions of an application, or from the modification screen.

Deployment

When we you have our your function ready, we you 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 you 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).

...

Once the function is deployed, we you can invoke it via HTTP to execute /and test it. There are two types of invocable endpoints: auto-generated and HTTP triggers.

...

Triggers can be invoked with the GET or POST verb, depending on whether our your function needs to receive a payload or not.

...