A sample demonstrating using knative serving for a Spring Boot 2 app deployment
Start app using the following command:
./gradlew -p applications/sample-boot-knative-app clean bootRun
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"
}'
A gatling based load can be sent to the app using:
./gradlew -p applications/load-scripts -DTARGET_URL=http://localhost:8080 knativeLoad
-
Install Knative using the instructions here
-
Run the following commands
cd knative
kubectl apply -f service.yml
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