Skip to content

Multiple runtimes(Quarkus, Spring Boot, Go, Python, NodeJs) to deploy OpenShift Serverless

Notifications You must be signed in to change notification settings

redhat-mw-demos/serverless-runtimes-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy Multiple Cloud-Native Apps to OpenShift Serverless

This repository contains how to develop multiple applications(Quarkus, Spring Boot, Python, NodeJs, Go) and deploy them as serverless services on Red Hat OpenShift 4.3+

1. Install OpenShift Serverless Operator

Follow the Installing OpenShift Serverless on OpenShift 4.3 or later. Then be sure if all pods are running in knative_serving and knative_serving_ingess namespaces.

2. Run Each Cloud-Native application locally

2-1. Build go application and run it locally:

cd go
go build
./serverless

Access the endpoint via curl command or web browser:

curl http://localhost:8080/api/go

You will see the result:

Welcome, Go with Serverless!

Stop the go runtimes via CTL+C.

2-2. NodeJs Application

Build node.js application and run it locally:

cd ../nodejs
npm install
npm start

Access the endpoint via curl command or web browser:

curl http://localhost:8080/api/nodejs

You will see the result:

Welcome, Nodejs with Serverless!

Stop the go runtimes via CTL+C.

2-3. Python Application

Build python application and run it locally:

cd ../python
python app.py

Access the endpoint via curl command or web browser:

curl http://localhost:8080/api/python

You will see the result:

Welcome, Python with Serverless!

Stop the go runtimes via CTL+C.

2-4. Spring Boot Application

Build spring boot application and run it locally:

cd ../springboot
mvn package -DskipTests
java -jar target/springboot-0.0.1-SNAPSHOT.jar

Access the endpoint via curl command or web browser:

curl http://localhost:8080/api/spring

You will see the result:

Welcome, Spring Boot with Serverless!

Stop the go runtimes via CTL+C.

2-5. Quarkus Application

Build quarkus application and run it locally:

cd ../quarkus
mvn package -DskipTests
java -jar target/quarkus-serverless-1.0-SNAPSHOT-runner.jar

Access the endpoint via curl command or web browser:

curl http://localhost:8080/api/quarkus

You will see the result:

Welcome, Quarkus with Serverless!

Stop the go runtimes via CTL+C.

3. Deploy the App via Knative Service

Log in OpenShift cluster 4.3+ then create a new project, demo-serverless. Select Deploy Image in Dev Console.

Copy the following container image that pre-pushed based Quakrus native executable binary:

danielon30/quarkus-serverless:latest

You wil see that Quarkus application is up in 60 secs. When you go to the logs in Pod, you will see 10~15 millisecs to start Quarkus.

Repeat the following 4 images to deploy via Knative Service in Dev Console:

  • danielon30/springboot-serverless:latest

  • danielon30/go-serverless:latest

  • danielon30/python-serverless:latest

  • danielon30/nodejs-serverless:latest

4. Trigger Each Endpoint

  • call-go.sh YOUR_ROUTE_DOMAIN_URL

  • call-nodejs.sh YOUR_ROUTE_DOMAIN_URL

  • call-python.sh YOUR_ROUTE_DOMAIN_URL

  • call-quarkus.sh YOUR_ROUTE_DOMAIN_URL

  • call-springboot.sh YOUR_ROUTE_DOMAIN_URL

Run each script, replacing YOUR_ROUTE_DOMAIN_URL with the wildcard route domain for your cluster (i.e. apps.cluster-runtimes-8a37.runtimes-8a37.example.opentlc.com), in separated terminals then see which app will go up for the first time. Quarkus will be the FIRST.

You can also run call-all.sh YOUR_ROUTE_DOMAIN_URL which will run all the endpoints and print out the results in the order they come back.

Note

Be sure to run the above scripts when all pods scaled to down to zero. It typically takes 30 seconds.

5. (Optional) Deploy All Cloud-Native Applications to OpenShift via Magic Script

Run the following command in your local computer. Be sure to log in the remote OpenShift cluster via oc login:

sh scripts/deploy-all.sh

Move on the topology view and ensure 5 serverless applications are running.