Skip to content

lvivJavaClub/spring-cloud-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring cloud functions with knative

Install knative at docker-for-mac

https://knative.dev/docs/install/knative-with-minikube/

Spring cloud functions with docker

Local build

cd reverse-function
docker build -t uppercase-function .

and

cd reverse-function
docker build -t reverse-function .

Run

docker run -p8081:8080 uppercase-function:latest 

and

docker run -p8082:8080 reverse-function:latest 

Invoke the function

curl http://localhost:8081/uppercase/abcd

or

curl http://localhost:8082/reverse/abcd

Spring cloud functions riff

Local build

mvnci

or

mvn clean install

Build and deploy

riff function create reverse --image $DOCKER_ID/reverse \
 -l ./reverse-function \
 --artifact reverse-0.0.1-SNAPSHOT.jar \
 --invoker java --handler=reverse
 
 
riff function create uppercase --image $DOCKER_ID/uppercase \
  -l ./uppercase-function \
  --artifact uppercase-0.0.1-SNAPSHOT.jar \
  --invoker java --handler=uppercase

Invoke the function

riff service invoke reverse  --text -- -w '\n' -d "text"

riff service invoke uppercase  --text -- -w '\n' -d "text"

Invoke the function through channel

Start monitoring

watch -n 1 kubectl get pods,ksvc,channel,subscription,deploy

Install correlator

riff service create correlator --image projectriff/correlator:s1p2018

Create channel

riff channel create reverse --cluster-bus stub
riff channel create uppercase --cluster-bus stub
riff channel create replies --cluster-bus stub

Create subscriptions

riff subscription create reverse-subscription --channel reverse --subscriber reverse --reply-to uppercase
riff subscription create uppercase-subscription --channel uppercase --subscriber uppercase --reply-to replies
riff subscription create correlator-subscription --channel replies --subscriber correlator

Invoke the function

riff service invoke correlator /reverse --text -- -d "Spring cloud functions" -v -H "Knative-Blocking-Request:true"

Cleanup

riff service delete correlator

riff channel delete reverse
riff channel delete uppercase
riff channel delete replies

riff subscription delete reverse-subscription
riff subscription delete uppercase-subscription
riff subscription delete correlator-subscription

Delete the function

riff service delete reverse
riff service delete uppercase