Knative Eventing 示例
示例
命令
kn broker create --help
kn broker create default --class MTChannelBasedBroker -n default
kn broker create mybroker --namespace myproject --class Kafka --broker-config rabbitmq.com/v1beta1:RabbitmqCluster:mycluster:test
kn trigger create -h
kn trigger create mytrigger --broker default --filter type=dev.knative.samples.helloworld --sink ksvc:mysvc
# 创建事件命令,实现过滤验证
curl -v "http://broker-ingress.knative-eventing.svc.cluster.local/knative-samples/default" \
-X POST \
-H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f79" \
-H "Ce-Specversion: 1.0" \
-H "Ce-Type: dev.knative.samples.helloworld" \
-H "Ce-Source: dev.knative.samples/helloworldsource" \
-H "Content-Type: application/json" \
-d '{"msg":"Hello World from the curl pod."}'
exit
kn channel -h
kn channel create -h
kn channel create imc1 --type messaging.knative.dev:v1:InMemoryChannel
kn channel list
# 可以往 channel 发送消息
kn subscription -h
kn subscription create -h
kn subscription create sub0 --channel imc1 --sink ksvc:receiver
kn subscription list
Broker/Trigger 示例
curl source --CloudEvent--> (Broker -> Trigger) -> event-display-hi
- event-display Kservice 创建
$ kn service create event-display-hi --image xiexianbin/event_display --port 8080 --scale-min 1 -n event-demo
$ kn service list
镜像 xiexianbin/knative_event_display
需参考制作
可用示例
gitlab -> GitLab Source --CloudEvent--> Sink(Knative Service)
https://github.com/knative/docs/blob/main/code-samples/eventing/gitlab-source/README.md