Coder Social home page Coder Social logo

kameshsampath / ow-scf-greeter Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 3.0 56 KB

OpenShift OpenWhisk Spring Cloud Functions Greeter Demo

License: Apache License 2.0

Makefile 6.65% Shell 56.07% Batchfile 33.42% Java 3.85%
openwhisk demos spring-cloud-function openshift minishift

ow-scf-greeter's Introduction

OpenShift - OpenWhisk - Spring Cloud Functions

Greeter demo application shows deploying Spring Cloud Functions application to OpenWhisk deployed on OpenShift/Kubernetes.

Overview

This example shows how to build and deploy a Spring Boot Application with functions defined as Spring Beans.

Build

Build application

./mvnw clean install

Docker Build application

To make the builds faster and resolve to right repositories the application uses contrib/settings.xml during build.

Note
The default app is configured to use mirrors, it can be removed if you don’t use nexus

The Docker build takes the following arguments,

  • APP_VERSION default 0.0.1-SNAPSHOT

  • SPRING_BOOT_VERSION default 1.5.9.RELEASE

  • SPRING_CLOUD_FUNCTION_VERSION default 1.0.0.BUILD-SNAPSHOT

  • JAVA_APP_NAME default com.redhat.developers.greeter.GreeterApplication

  • FUNCTION_NAME default greeter

docker-hello-app:
	docker build --rm \
	--build-arg APP_VERSION=$(APP_VERSION) \
	--build-arg SPRING_BOOT_VERSION=$(SPRING_BOOT_VERSION) \
	--build-arg SPRING_CLOUD_FUNCTION_VERSION=$(SPRING_CLOUD_FUNCTION_VERSION) \
	--build-arg JAVA_APP_NAME=$(JAVA_APP_NAME) \
    --build-arg FUNCTION_NAME=$(FUNCTION_NAME) \
	--tag kameshsampath/ow-scf-greeter .

Deploying Function to OpenWhisk

Create

wsk -i action create hello --docker kameshsampath/ow-scf-greeter

Update

wsk -i update create hello --docker kameshsampath/ow-scf-greeter

Testing Function

OpenWhisk CLI

As the function takes single parameter called name, it is required to pass it via function parameter name called payload. The following snippet shows how to invoke it via OpenWhisk CLI:

wsk -i action invoke greeter -p payload spring --result

REST API

Each OpenWhisk action that is deployed can be invoked using REST API:

URL=$(wsk -i action get greeter --url | tail -n 1) (1)
AUTH=$(wsk -i property get --auth | awk '{print $3}') (2)
curl -k -H "Content-Type: application/json" -u "$AUTH" -d '{"payload": "openshift"}' $URL (3)
wsk -i activation result [activationId from <3>]  (4)
  1. Get the function REST url

  2. Get the credentials to invoke the action

  3. Will return a activation id e.g. {"activationId":"3fc210dc8acf47788210dc8acf277875"}

  4. Will output the result of curl call

Base Docker Images

The Spring Boot applications need to build the custom docker images to run the app, the details of how to build the docker image is available here,

For convenience the following docker images are built and available to be used to run Spring Cloud Functions on OpenWhisk:

The sources of the docker images is available here

Note
Applications and bases images uses SNAPSHOT builds

ow-scf-greeter's People

Contributors

kameshsampath avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.