Skip to content

igayoso/sample-boot-knative

 
 

Repository files navigation

Spring Boot app on Knative serving

A sample demonstrating using knative serving for a Spring Boot 2 app deployment

Running it locally

Start app using the following command:

./gradlew -p applications/sample-boot-knative-app clean bootRun

Testing

Assuming that httpie is installed

http POST 'http://localhost:8080/messages' id="1" payload="one"   delay="1000"

OR with CURL

curl -X "POST" "http://localhost:8080/messages" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d $'{
  "id": "1",
  "payload": "one",
  "delay": "1000"
}'

Generating load

A gatling based load can be sent to the app using:

./gradlew -p applications/load-scripts  -DTARGET_URL=http://localhost:8080 knativeLoad

Deploying to Kubernetes using Knative serving

  • Install Knative using the instructions here

  • Run the following commands

cd knative
kubectl apply -f service.yml

Testing

export GATEWAY_URL=$(echo $(minikube ip):$(kubectl get svc knative-ingressgateway -n istio-system -o 'jsonpath={.spec.ports[?(@.port==80)].nodePort}'))
export APP_DOMAIN=$(kubectl get services.serving.knative.dev sample-boot-knative-service  -o="jsonpath={.status.domain}")

With Httpie:

http http://${GATEWAY_URL}/messages Host:"${APP_DOMAIN}" id=1 payload=test delay=100

Or with Curl:

curl -X "POST" "http://${GATEWAY_URL}/messages" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -H "Host: ${APP_DOMAIN}" \
     -d $'{
  "id": "1",
  "payload": "one",
  "delay": "300"
}'

Load Test:

./gradlew -p applications/load-scripts  -DTARGET_URL=http://${GATEWAY_URL} knativeLoad -DHOST_HEADER=${APP_DOMAIN} -DSIM_USERS=20

About

Demonstrates deploying a Spring Boot app to Knative serving

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 58.2%
  • Kotlin 21.2%
  • HTML 9.6%
  • Scala 4.7%
  • Java 4.3%
  • Dockerfile 1.6%
  • CSS 0.4%