Skip to content
Demonstrates deploying a Spring Boot app to Knative serving
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
applications
gradle/wrapper
knative
kube
.gitignore
README.adoc
docker-compose.yml
gradlew
gradlew.bat
settings.gradle

README.adoc

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
You can’t perform that action at this time.