OpenFaaS is an alternative to enable the serverless approach in your infrastructure when you’re not running in the public cloud and you don’t have available those other options like AWS Lambda Functions or Azure Functions or even in public cloud, you’d like the features and customizations option it provides.
OpenFaaS® (Functions as a Service) is a framework for building serverless functions with Docker and Kubernetes which has first-class support for metrics. Any process can be packaged as a function enabling you to consume a range of web events without repetitive boiler-plate coding.
OpenFaaS® (Functions as a Service) is a framework for building Serverless functions with Docker and Kubernetes which…
There is good content on medium about OpenFaaS so I don’t like to spend so much time on this, but I’d like to leave you here some links for reference:
Running serverless functions on premises using OpenFaas with Kubernetes
Earlier most of companies had monolithic architecture for their cloud applications (all the things in a single…
An Introduction to Serverless DevOps with OpenFaaS
DevOps isn’t about just doing CI/CD. But a CI/CD pipeline has an important role inside DevOps. I’ve been investing my…
We already have a lot of info about how to run a Flogo Application as a Lambda Function as you can see here:
But.. what about OpenFaaS? Can we run our Flogo application inside OpenFaaS? Sure! Let me explain to you how.
OpenFaaS is a very customize framework to build zero-scaled functions and it could need some time to get familiar with concepts. Everything is based on watchdogs that are the components listening to the requests are responsible for launching the forks to handle the requests:
We’re going to use the new watchdog named as of-watchdog that is the one expected to be the default one in the feature and all the info is here:
The of-watchdog is a new version of the OpenFaaS watchdog which provides the original STDIO mode from the Classic…
This watchdog provides several modes, one of them is named HTTP and it is the default one, and is based on some HTTP Forward to the internal server running in the container. That fits perfectly with our Flogo application and means that the only thing we need is to deploy an HTTP Receive Request trigger in our Flogo Application and that's it.
The only things you need to configure is the method (POST) and the Path (/) to be able to handle the requests. In our case we’re going to do a simple Hello World app as you can see here:
To be able to run this application we need to use several things, and let’s explain it here:
First of all, we need to do the installation of the OpenFaaS environment, I’m going to skip all the details about this process and just point to you to the detailed tutorial about it:
Deploy OpenFaaS on Amazon EKS | Amazon Web Services
We've talked about FaaS (Functions as a Service) in Running FaaS on a Kubernetes Cluster on AWS Using Kubeless by…
Now we need to create our template and to do that, we are going to use a Dockerfile template. To create it we’re going to execute:
faas-cli new --lang dockerfile
We’re going to name the function flogo-test. And now we’re going to update the Dockerfile to be like this:
Most of this content is common for any other template using the new of-watchdog and the HTTP mode.
I’d like to highlight the following things:
We use several environment variables to define the behavior:
- mode = HTTP to define what we’re going to use this method
- upstream_url = URL that we are going to forward the request to
- fprocess = OS command that we need to execute, in our case means to run the Flogo App.
Other things are the same as you should do in case you want to run flogo apps in Docker:
- Add the engine executable for your platform (UNIX in most cases as the image base is almost always a Linux based)
- Add the JSON file of the application that you want to use.
We also need to change the yml file to look like this:
And that’s it! Now, we only need to execute the following command:
faas-cli up -f .\flogo-test.yml
And the function is going to be deployed to your environment and we can run it using the OpenFaas portal directly:
All the code is available here (the only thing left is the Flogo Enterprise Engine that you need to use to be able to build and upload it)