Argo(events) 使用传感器触发现有的 ClusterWorkflowTemplate
Argo(events) Trigger an existing ClusterWorkflowTemplate using Sensor
我正在尝试从 argo/argo-events 中的 post 请求触发预先存在的 ClusterWorkflowTemplate
。
我一直在遵循示例 here,但我不想在传感器中定义工作流程 - 我想将其分开。
我无法让传感器导入并触发工作流,这是什么问题?
# kubectl apply -n argo-test -f templates/whalesay/workflow-template.yml
apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
name: workflow-template-submittable
spec:
entrypoint: whalesay-template
arguments:
parameters:
- name: message
value: hello world
templates:
- name: whalesay-template
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
# kubectl apply -n argo-events templates/whalesay/event-source.yml
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: webhook
spec:
service:
ports:
- port: 12000
targetPort: 12000
webhook:
# event-source can run multiple HTTP servers. Simply define a unique port to start a new HTTP server
example:
# port to run HTTP server on
port: "12000"
# endpoint to listen to
endpoint: /example
# HTTP request method to allow. In this case, only POST requests are accepted
method: POST
# kubectl apply -n argo-events -f templates/whalesay/sensor.yml
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: workflow
namespace: argo-events
finalizers:
- sensor-controller
spec:
template:
serviceAccountName: operate-workflow-sa
dependencies:
- name: http-post-trigger
eventSourceName: webhook
eventName: example
triggers:
- template:
name: workflow-trigger-1
argoWorkflow:
group: argoproj.io
version: v1alpha1
kind: Workflow
operation: submit
metadata:
generateName: cluster-workflow-template-hello-world-
spec:
entrypoint: whalesay-template
workflowTemplateRef:
name: cluster-workflow-template-submittable
clusterScope: true
# to launch
curl -d '{"message":"this is my first webhook"}' -H "Content-Type: application/json" -X POST http://argo-events-51-210-211-4.nip.io/example
# error
{
"level": "error",
"ts": 1627655074.716865,
"logger": "argo-events.sensor-controller",
"caller": "sensor/controller.go:69",
"msg": "reconcile error",
"namespace": "argo-events",
"sensor": "workflow",
"error": "temp ││ late workflow-trigger-1 is invalid: argoWorkflow trigger does not contain an absolute action",
}
参考文献:
我必须:
- 确保我的服务帐户
operate-workflow-sa
具有集群权限
- 更正我的
sensor.yml
语法 spec
集群权限:
# kubectl apply -f ./k8s/workflow-service-account.yml
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: argo-events
name: operate-workflow-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: operate-workflow-role
# namespace: argo-events
rules:
- apiGroups:
- argoproj.io
verbs:
- "*"
resources:
- workflows
- clusterworkflowtemplates
- workflowtemplates
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: operate-workflow-role-binding
namespace: argo-events
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: operate-workflow-role
subjects:
- kind: ServiceAccount
name: operate-workflow-sa
namespace: argo-events
sensor.yml(注意也为工作流程添加了 serviceAccountName
):
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: workflow
namespace: argo-events
finalizers:
- sensor-controller
spec:
template:
serviceAccountName: operate-workflow-sa
dependencies:
- name: http-post-trigger
eventSourceName: webhook
eventName: example
triggers:
# https://github.com/argoproj/argo-events/blob/master/api/sensor.md#triggertemplate
- template:
name: workflow-trigger-1
argoWorkflow:
# https://github.com/argoproj/argo-events/blob/master/api/sensor.md#argoproj.io/v1alpha1.ArgoWorkflowTrigger
group: argoproj.io
version: v1alpha1
resource: Workflow
operation: submit
metadata:
generateName: cluster-workflow-template-hello-world-
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: special-trigger
spec:
serviceAccountName: operate-workflow-sa
entrypoint: whalesay-template
workflowTemplateRef:
name: whalesay-template
clusterScope: true
我正在尝试从 argo/argo-events 中的 post 请求触发预先存在的 ClusterWorkflowTemplate
。
我一直在遵循示例 here,但我不想在传感器中定义工作流程 - 我想将其分开。
我无法让传感器导入并触发工作流,这是什么问题?
# kubectl apply -n argo-test -f templates/whalesay/workflow-template.yml
apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
name: workflow-template-submittable
spec:
entrypoint: whalesay-template
arguments:
parameters:
- name: message
value: hello world
templates:
- name: whalesay-template
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
# kubectl apply -n argo-events templates/whalesay/event-source.yml
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: webhook
spec:
service:
ports:
- port: 12000
targetPort: 12000
webhook:
# event-source can run multiple HTTP servers. Simply define a unique port to start a new HTTP server
example:
# port to run HTTP server on
port: "12000"
# endpoint to listen to
endpoint: /example
# HTTP request method to allow. In this case, only POST requests are accepted
method: POST
# kubectl apply -n argo-events -f templates/whalesay/sensor.yml
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: workflow
namespace: argo-events
finalizers:
- sensor-controller
spec:
template:
serviceAccountName: operate-workflow-sa
dependencies:
- name: http-post-trigger
eventSourceName: webhook
eventName: example
triggers:
- template:
name: workflow-trigger-1
argoWorkflow:
group: argoproj.io
version: v1alpha1
kind: Workflow
operation: submit
metadata:
generateName: cluster-workflow-template-hello-world-
spec:
entrypoint: whalesay-template
workflowTemplateRef:
name: cluster-workflow-template-submittable
clusterScope: true
# to launch
curl -d '{"message":"this is my first webhook"}' -H "Content-Type: application/json" -X POST http://argo-events-51-210-211-4.nip.io/example
# error
{
"level": "error",
"ts": 1627655074.716865,
"logger": "argo-events.sensor-controller",
"caller": "sensor/controller.go:69",
"msg": "reconcile error",
"namespace": "argo-events",
"sensor": "workflow",
"error": "temp ││ late workflow-trigger-1 is invalid: argoWorkflow trigger does not contain an absolute action",
}
参考文献:
我必须:
- 确保我的服务帐户
operate-workflow-sa
具有集群权限 - 更正我的
sensor.yml
语法 spec
集群权限:
# kubectl apply -f ./k8s/workflow-service-account.yml
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: argo-events
name: operate-workflow-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: operate-workflow-role
# namespace: argo-events
rules:
- apiGroups:
- argoproj.io
verbs:
- "*"
resources:
- workflows
- clusterworkflowtemplates
- workflowtemplates
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: operate-workflow-role-binding
namespace: argo-events
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: operate-workflow-role
subjects:
- kind: ServiceAccount
name: operate-workflow-sa
namespace: argo-events
sensor.yml(注意也为工作流程添加了 serviceAccountName
):
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: workflow
namespace: argo-events
finalizers:
- sensor-controller
spec:
template:
serviceAccountName: operate-workflow-sa
dependencies:
- name: http-post-trigger
eventSourceName: webhook
eventName: example
triggers:
# https://github.com/argoproj/argo-events/blob/master/api/sensor.md#triggertemplate
- template:
name: workflow-trigger-1
argoWorkflow:
# https://github.com/argoproj/argo-events/blob/master/api/sensor.md#argoproj.io/v1alpha1.ArgoWorkflowTrigger
group: argoproj.io
version: v1alpha1
resource: Workflow
operation: submit
metadata:
generateName: cluster-workflow-template-hello-world-
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: special-trigger
spec:
serviceAccountName: operate-workflow-sa
entrypoint: whalesay-template
workflowTemplateRef:
name: whalesay-template
clusterScope: true