This is a sample that uses KNative and Cloud Events (with the .NET SdK).
- Install Docker, Rancher or Podman;
- Install k3d;
- Install
libnss-myhostname
so that hosts*.localhost
resolve to127.0.0.1
; - Install k6 (only to test autoscaling).
- Run
./install.sh
- Source the configuration:
source use-cluster.sh
# directly with an nginx reverse proxy into the cluster load balanced services
curl helloworld-csharp.hello-world.knative.knativetest.localhost
# or using the cluster load balanced services through metallb
KNATIVE_SERVING_IP=`kubectl get service --namespace knative-serving kourier -ojsonpath='{ .status.loadBalancer.ingress[0].ip }'`
curl -H 'Host: helloworld-csharp.hello-world.knative.knativetest.localhost' $KNATIVE_SERVING_IP
Or run the serving.http file.
First you need to find the IP the ingress created for the KNative broker:
KNATIVE_EVENTING_IP=`kubectl get ingress --namespace knative-eventing knative-ingress -ojsonpath='{ .status.loadBalancer.ingress[0].ip }'`
Then, to run the producer:
dotnet run --project func/producer/ -- --ip $KNATIVE_EVENTING_IP --host broker-ingress.knativetest.localhost
Or run the cloudevent.http file.
The consumer will start and stop after 2 minutes without messages.
To view the pods and logs from the consumer:
kubectl get pod --namespace consumerns
kubectl logs --namespace consumerns --selector serving.knative.dev/service=consumer
Access the tracing dashboard at http://jaeger.knativetest.localhost
Run ./scale/run-web.sh
and in parallel watch -n1 kubectl get pod --namespace hello-world
to see the pods autoscaling.
Run ./scale/run-inmemory-broker.sh
. Use ./scale/run-inmemory-broker.sh --help
to see options, for example:
# run for 120 seconds, waiting 50 miliseconds between messages, with 10 parallel users
./scale/run-inmemory-broker.sh --run-for 120 --delay 50 --parallel 10
Jaeger: http://jaeger.knativetest.localhost Knative eventing brokers:
- In memory broker: http://broker-ingress.knativetest.localhost
Knative Serving service endpoint (hello world function): http://helloworld-csharp.hello-world.knative.knativetest.localhost Registry: http://registry.knativetest.localhost:5000
See the requests directory.
See cloudevent.http.
You can run it with Visual Studio Code and the Rest Client extension (there are other tools that run this format, as well).