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+
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.
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.
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.
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.
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.
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.
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
-
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. |