Knative Broker无法触发Knative服务

问题描述 投票:0回答:2

我正在GKE中测试Knative,这是我想做的:

enter image description here

但是,在“ default-broker-filter”的日志中出现以下错误:

caller: "http/transport.go:508"   
error: "Post http://helloworld-python.knative-samples.svc.cluster.local: dial tcp: lookup helloworld-python.knative-samples.svc.cluster.local on 10.0.0.10:53: no such host"   
level: "warn"   
logger: "fallback"   
msg: "got an error from receiver fn" 

我使用this official tutorial通过以下命令安装Knative:

kubectl apply --selector knative.dev/crd-install=true \
--filename https://github.com/knative/serving/releases/download/v0.12.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.12.0/eventing.yaml \
--filename https://github.com/knative/serving/releases/download/v0.12.0/monitoring.yaml

kubectl apply --filename https://github.com/knative/serving/releases/download/v0.12.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.12.0/eventing.yaml \
--filename https://github.com/knative/serving/releases/download/v0.12.0/monitoring.yaml

这是我用来在python中安装触发器和服务问候世界的yaml模板:

# Namespace for sample application with eventing enabled
apiVersion: v1
kind: Namespace
metadata:
  name: knative-samples
  labels:
    knative-eventing-injection: enabled
---
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-python
  namespace: knative-samples
spec:
  template:
    spec:
      containers:
        - image: gcr.io/knative-samples/helloworld-python
          env:
            - name: TARGET
              value: "Python Sample v1"

---
# Knative Eventing Trigger to trigger the helloworld-go service
apiVersion: eventing.knative.dev/v1alpha1
kind: Trigger
metadata:
  name: my-service-trigger
  namespace: knative-samples
spec:
  broker: default
  filter:
    attributes:
      type: dev.knative.samples.helloworld
  subscriber:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: helloworld-python

然后我创建一个pod执行我的curl命令:

kubectl --namespace knative-samples run curl --image=radial/busyboxplus:curl -it

curl -v "default-broker.knative-samples.svc.cluster.local" \
  -X POST \
  -H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f79" \
  -H "Ce-specversion: 0.3" \
  -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."}'

您能告诉我这是什么问题吗,因为我整个周末都没找到任何线索?

谢谢,

google-kubernetes-engine knative knative-serving knative-eventing
2个回答
1
投票

您是否启用了群集本地网关?如果没有,那么这可能就是它不起作用的原因。以下链接中的详细信息:

https://knative.dev/docs/install/installing-istio/


0
投票

您的应用程序仅接受GET请求,如您在此处看到的-https://github.com/knative/docs/blob/master/docs/serving/samples/hello-world/helloworld-python/app.py

您可以在cloudevents规范-https://github.com/cloudevents/spec/blob/master/http-webhook.md#21-delivery-request中看到

传递请求的HTTP方法必须为POST。

您必须使用POST方法来触发您的服务。

如果要修复它,您有两个简单的选择:

  1. 您可以将服务的图像更改为event_displaygcr.io/knative-releases/github.com/knative/eventing-sources/cmd/event_display

  2. 您可以更改应用程序的代码,并将L7@app.route('/')更改为@app.route('/', methods=['GET', 'POST'])

© www.soinside.com 2019 - 2024. All rights reserved.