我正在尝试通过 K8s 负载均衡器将 POST 请求路由到 Argo Events 中的 Webhook。我找不到任何关于此的明确文档。我能够创建 Webhook,并且在转发 webhook-eventsource-svc 时可以成功与其通信。负载均衡器构建良好,并显示我分配的外部 IP。但是,当我尝试 POST 到负载均衡器时,我只是收到连接超时错误。我希望我只是配置了这些清单错误。
这是这两项服务的清单。
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: webhook
namespace: argo-events
spec:
service:
ports:
- port: 12000
targetPort: 12000
webhook:
example:
endpoint: /deploy
method: POST
port: "12000"
---
apiVersion: v1
kind: Service
metadata:
name: webhook-loadbalancer
namespace: argo-events
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
service.beta.kubernetes.io/azure-load-balancer-internal-subnet: DevelopSubnet
spec:
type: LoadBalancer
loadBalancerIP: 1XX.X.X.XXX
ports:
- protocol: TCP
port: 90
targetPort: 12000
selector:
app: webhook-eventsource-svc
controller: eventsource-controller
这是我发送请求的方式:
curl -d '@params.json' -H "Content-Type: application/json" -X POST http://1XX.X.X.XXX:90/deploy
有什么建议吗?
我正在尝试在 AWS 中做类似的事情。我可以让示例 Webhook 与端口转发一起使用 (https://argoproj.github.io/argo-events/quick_start/),但它不适用于常规 K8s 对象。就我而言,一个 Ingress 和一个 Service 对象。我可以看到我的服务选择器正确选择了 webhook 传感器容器。 Argo Events 和 Argo Workflow 都在同一个 argo 命名空间中运行。配置完成后,从 Postman 对 Ingress 的访问将返回 404。令我困惑的是,传感器 Pod 公开的实际端口是示例中的 7777,而不是 12000。因此,我尝试了端口 12000 / TargetPort 12000 的服务或7777。无论哪种情况,POST 都会返回 404。
我可以指出的是,适用于您和我的情况的是(https://argoproj.github.io/argo-events/eventsources/services/)在第二段中它指出您必须删除服务字段从您的 EventSource 对象重构端口转发的示例。希望能帮助到你。我仍在努力让这项工作成功。
只是想分享一下如何公开 webhook 因此,当您想要公开 Webhook 时,取决于文档
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: webhook
spec:
# to expose this endpoint to public internet we need to remove this part
# service:
# ports:
# - port: 12000
# targetPort: 12000
webhook:
example:
port: "12000"
# now this is the endpoint you may want to expose with your ingress/virtualService/etc..
endpoint: /webhook
method: POST
下一部分是创建一个指向 webhook 的服务
apiVersion: v1
kind: Service
metadata:
name: webhook-eventsource
spec:
ports:
- port: 12000
protocol: TCP
name: tcp
targetPort: 12000
selector:
# pods created from `EventSource` will have the label of `eventsource-name=eventsourcename` by default so we use this selector to select it
eventsource-name: webhook
type: ClusterIP
最后但并非最不重要的一点是,您必须使用端点公开服务(我在此处的示例中使用 ISTIO 和虚拟服务)
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: https
namespace: istio-system
spec:
hosts:
- "*"
gateways:
- http-gateway
http:
# this URL matching should match the URL inside the following "EventSource.webhook.example"
# it is not intended to be used like "/webhook/webhook" the URL should directly match the one inside the object "webhook"
- match:
- uri:
prefix: /webhook
route:
- destination:
host: webhook-eventsource.argo-events.svc.cluster.local
port:
number: 12000
这里需要注意的是,
/webhook
中的两个EventSource
与您的ingress/virtualService
中的URL完全匹配