首先 argo event source 是需要额外安装的,和argoworkflow并不一起安装
参考 https://argoproj.github.io/argo-events/installation/
在没有安装的情况下会得到
Not Found: the server could not find the requested resource (get eventsources.argoproj.io)
官方文档中提供了两种安装方式
这里为了跟 workflow 的 UI 集成,所以我选择使用 Cluster-wide Installation 安装到argo namespace下
这里是官网的写法
Namespace Installation
kubectl create namespace argo-events
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/namespace-install.yaml
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml
Cluster-wide Installation
kubectl create namespace argo-events
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install-validating-webhook.yaml
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml
这里是我本地的写法
Cluster-wide Installation
kubectl create namespace argo-events
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install-validating-webhook.yaml
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml
可以看到 eventbus 的 命名空间是不一样的
Argo 的事件源 EventSource 可以是 webhook、s3、github、sqs 等 中间会经过 Eventbus (类似kafka的高性能分布式消息中间件),Eventbus 通过 sensor 来触发 trigger
具体有多少种 event sources 呢?
参考 https://github.com/argoproj/argo-events/tree/stable/examples/event-sources
这里将尝试 万能接口 webhook
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: webhook
namespace: argo
spec:
service:
ports:
- port: 12000
targetPort: 12000
webhook:
example:
endpoint: /deploy
method: POST
port: "12000"
url: ""
进行一下测试
kubectl -n argo get pod -l eventsource-name=webhook -o name
kubectl -n argo port-forward $(kubectl -n argo get pod -l eventsource-name=webhook -o name) 12000:12000
curl -d '{"message":"hello argo"}' -H "Content-Type: application/json" -X POST http://localhost:12000/deploy