Back To Blogs

Introducing Vertx and SpringBoot Java Templates for OpenFaas

By: Ram Gopinathan

2018-02-11

Introduction

This post is more of an introductory post announcing release of SpringBoot and Vertx Java templates for OpenFaas. These templates allow you to develop your serverless function for the OpenFaas platform using SpringBoot or Vertx. In the Java ecosystem both SpringBoot and Vertx are very popular frameworks for developing microservices. With the release of these templates we are bringing the power of these frameworks into OpenFaas. You can find the templates in our github repository here. Please provide us any feedback or issues you might run into. If you are new to OpenFaas, please check out this kubecon talk by Alex Ellis creator of OpenFaas platform.

Downloading the template

Before you can create serverless functions using the above the templates, you must first install them on your local machine. Run the command below to install these templates on your local machine. Additional requirement is you need to have Faas cli installed and configured to either work with your local docker swarm or kubernetes cluster or remote clusters.


faas template pull https://github.com/tmobile/faas-java-templates.git

Verify templates are installed locally using command below


faas new --list

Creating functions using these templates

As mentioned earlier repository currently provides both Vertx or SpringBoot templates.

To create a function using these templates, run the command below.

Note: Replace string within ‘{}’ with a value that makes sense for your usecase.


faas new {name of function} --lang vertx|springboot

Building the function

Once you’ve implemented the function logic, you would build the function using the faas cli build command as shown below.

Note: Replace string within ‘{}’ with a value that makes sense for your usecase.


faas build {stack yml} --image {function docker image} --handler {path to your function handler} --lang vertx|springboot --name {function name}

Push the Image to a Registry

Once your function image is built you can push the image to a docker registry using the faas cli.


faas push -f {stack yml}

Deploying the function

Once the function is built using the faas cli, you can simply deploy them as shown below

Note: Replace string within ‘{}’ with a value that makes sense for your usecase.


faas deploy --image {function docker image} --name {function name}

In the next post we will demonstrate how to build a real serverless function using the above templates and deploy to Openfaas running on a Kubernetes cluster.

Thanks,

Ram

comments powered by Disqus