[英]Knative kafka version and python support
I want to use Knative for kafka event trigger.我想将 Knative 用于 kafka 事件触发器。 I found a good doc around it https://knative.dev/docs/eventing/samples/kafka/source/index.html .
我在它周围找到了一个很好的文档https://knative.dev/docs/eventing/samples/kafka/source/index.html 。
My questions are:我的问题是:
Does it support kafka version 2.5 or higher?它是否支持 kafka 2.5 或更高版本?
I want to write code in python and the file that i came across is in go.我想在 python 中编写代码,我遇到的文件在 go 中。 https://github.com/knative/eventing-contrib/blob/master/cmd/event_display/main.go
https://github.com/knative/eventing-contrib/blob/master/cmd/event_display/main.go
All i want to know can i have the same in python?我想知道的我可以在 python 中有相同的吗? or would i need a docker image that will use python as base image also in that case what would be the function syntax?
还是我需要一个 docker 图像,它将使用 python 作为基本图像,在这种情况下,function 语法是什么?
def consumer(context, event):
context.logger.debug(event.body)
print(event.trigger.kind)
I want something like this in Knative event trigger (python)我在 Knative 事件触发器(python)中想要这样的东西
The service or URL referenced by spec.sink
can be written in any language and in your target language you need to start an HTTP server and listen for events. spec.sink 引用的服务或
spec.sink
可以用任何语言编写,并且您需要启动 HTTP 服务器并侦听事件的目标语言。
In your case, I suggest looking at the Python CloudEvents SDK documentation for receiving events that contains a useful example using Flask: https://github.com/cloudevents/sdk-python/tree/v1.0.0-stable#request-to-cloudevent . In your case, I suggest looking at the Python CloudEvents SDK documentation for receiving events that contains a useful example using Flask: https://github.com/cloudevents/sdk-python/tree/v1.0.0-stable#request-to-云事件。
So, the Knative service in the Kafka Source example needs to reference your custom container image:因此,Kafka Source 示例中的Knative 服务需要引用您的自定义容器镜像:
# ...
spec:
template:
spec:
containers:
image: <your_custom_container_image>
Also, spec.sink
can be a Kubernetes service.此外,
spec.sink
可以是 Kubernetes 服务。 The following is an example configuration to deliver events to a custom path my-custom-path
for a Kubernetes service my-service
:以下是将事件传递到Kubernetes 服务
my-service
的自定义路径my-custom-path
的示例配置:
spec:
# ...
sink:
ref:
apiVersion: v1
kind: Service
name: my-service
uri: /my-custom-path
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.