Knative Eventing 示例

发布时间: 更新时间: 总字数:241 阅读时间:1m 作者: IP上海 分享 网址

Knative Eventing 示例

示例

命令

  • broker
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
  • trigger
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
  • channel
kn channel -h

kn channel create -h

kn channel create imc1 --type messaging.knative.dev:v1:InMemoryChannel

kn channel list

# 可以往 channel 发送消息
  • subscription
kn subscription -h

kn subscription create -h

kn subscription create sub0 --channel imc1 --sink ksvc:receiver

kn subscription list

Broker/Trigger 示例

  • 以 curl 事件源创建事件,并展示
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

Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数