From 9ecff31ebb270ee8fe62247fa40f7d27aa5082fe Mon Sep 17 00:00:00 2001 From: Edward Cheng Date: Wed, 28 Aug 2024 09:44:01 +1000 Subject: [PATCH] add sensor and workflow --- .../argo-events/base/examples/ingress.yaml | 21 +++++++++ .../argo-events/base/examples/sensor.yaml | 33 ++++++++++++++ .../argo-events/base/examples/webhook.yaml | 44 +++++++++++++++++++ .../argo-events/base/examples/workflow.yaml | 29 ++++++++++++ .../argo-events/base/kustomization.yaml | 6 ++- 5 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 infrastructures/argo-events/base/examples/ingress.yaml create mode 100644 infrastructures/argo-events/base/examples/sensor.yaml create mode 100644 infrastructures/argo-events/base/examples/webhook.yaml create mode 100644 infrastructures/argo-events/base/examples/workflow.yaml diff --git a/infrastructures/argo-events/base/examples/ingress.yaml b/infrastructures/argo-events/base/examples/ingress.yaml new file mode 100644 index 0000000..0d177f2 --- /dev/null +++ b/infrastructures/argo-events/base/examples/ingress.yaml @@ -0,0 +1,21 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: event-example-ingress + namespace: argo-events + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/use-regex: "true" +spec: + ingressClassName: nginx + rules: + - host: "event-example.cluster.edward.sydney" + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: webhook-eventsource-svc + port: + number: 12000 \ No newline at end of file diff --git a/infrastructures/argo-events/base/examples/sensor.yaml b/infrastructures/argo-events/base/examples/sensor.yaml new file mode 100644 index 0000000..5c4615b --- /dev/null +++ b/infrastructures/argo-events/base/examples/sensor.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: operate-workflow-sa +--- +# Similarly you can use a ClusterRole and ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: operate-workflow-role +rules: + - apiGroups: + - argoproj.io + verbs: + - "*" + resources: + - workflows + - workflowtemplates + - cronworkflows + - clusterworkflowtemplates +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: operate-workflow-role-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: operate-workflow-role +subjects: + - kind: ServiceAccount + name: operate-workflow-sa \ No newline at end of file diff --git a/infrastructures/argo-events/base/examples/webhook.yaml b/infrastructures/argo-events/base/examples/webhook.yaml new file mode 100644 index 0000000..fc76706 --- /dev/null +++ b/infrastructures/argo-events/base/examples/webhook.yaml @@ -0,0 +1,44 @@ +--- +apiVersion: argoproj.io/v1alpha1 +kind: Sensor +metadata: + name: webhook +spec: + template: + serviceAccountName: operate-workflow-sa + dependencies: + - name: test-dep + eventSourceName: webhook + eventName: example + triggers: + - template: + name: webhook-workflow-trigger + k8s: + operation: create + source: + resource: + apiVersion: argoproj.io/v1alpha1 + kind: Workflow + metadata: + generateName: webhook- + spec: + entrypoint: whalesay + arguments: + parameters: + - name: message + # the value will get overridden by event payload from test-dep + value: hello world + templates: + - name: whalesay + inputs: + parameters: + - name: message + container: + image: docker/whalesay:latest + command: [cowsay] + args: ["{{inputs.parameters.message}}"] + parameters: + - src: + dependencyName: test-dep + dataKey: body + dest: spec.arguments.parameters.0.value \ No newline at end of file diff --git a/infrastructures/argo-events/base/examples/workflow.yaml b/infrastructures/argo-events/base/examples/workflow.yaml new file mode 100644 index 0000000..b1f09a9 --- /dev/null +++ b/infrastructures/argo-events/base/examples/workflow.yaml @@ -0,0 +1,29 @@ +# This file enables a Workflow Pod (running Emissary executor) to be able to read and patch WorkflowTaskResults, +# which get shared with the Workflow Controller. The Controller uses the results to update Workflow status. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + annotations: + workflows.argoproj.io/description: | + Recomended minimum permissions for the `emissary` executor. + name: executor +rules: + - apiGroups: + - argoproj.io + resources: + - workflowtaskresults + verbs: + - create + - patch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: executor-default +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: executor +subjects: + - kind: ServiceAccount + name: default \ No newline at end of file diff --git a/infrastructures/argo-events/base/kustomization.yaml b/infrastructures/argo-events/base/kustomization.yaml index eda4bd4..9f28872 100644 --- a/infrastructures/argo-events/base/kustomization.yaml +++ b/infrastructures/argo-events/base/kustomization.yaml @@ -9,4 +9,8 @@ resources: - ./deployment.yaml - ./service.yaml - ./examples/eventbus.yaml - - ./examples/event-source.yaml \ No newline at end of file + - ./examples/event-source.yaml + - ./examples/ingress.yaml + - ./examples/sensor.yaml + - ./examples/workflow.yaml + - ./examples/webhook.yaml \ No newline at end of file