Skip to content

feat(argo/events): add simple webhook event pratice file #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/argo_events_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# verify with local kind k8s cluster.
name: Argo events E2E test

on:
workflow_dispatch:
pull_request:
branches: [main]
paths:
- "argo/events/**"
- ".github/workflows/argo_events_*"

jobs:
kubernetes:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Kubernetes
uses: engineerd/[email protected]
with:
# renovate: datasource=go depName=sigs.k8s.io/kind
version: v0.11.0
- name: Install Argo Workflow in Kubernetes cluster
run: |
kubectl create namespace argo
kubectl -n argo apply -f https://raw.githubusercontent.com/argoproj/argo-workflows/master/manifests/install.yaml

# wait all be ready
kubectl -n argo wait deploy --all --for condition=Available --timeout 5m
- name: Install Argo Events in Kubernetes cluster
run: |
kubectl create namespace argo-events
kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/master/manifests/install.yaml
kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml

# sensor rbac
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/master/examples/rbac/sensor-rbac.yaml
# workflow rbac
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/master/examples/rbac/workflow-rbac.yaml

# webhook event source
kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/event-sources/webhook.yaml
# webhook sensor
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/sensors/webhook.yaml

# wait all be ready
kubectl -n argo wait deploy --all --for condition=Available --timeout 5m
- name: Trigger webhook event using k8s job.
run: |
kubectl -n default create job sendwebhook --image=curlimages/curl -- curl \
-X POST \
-d '{"message":"this is my first webhook"}' \
-H "Content-Type: application/json" \
http://webhook-eventsource-svc.argo-events:12000/example
kubectl -n default wait job/sendwebhook --for=condition=completed --timeout=1m
- name: Verify event trigger feature
run: kubectl -n argo-events wait workflows --all --for=condition=Completed --timeout=1m
- name: Debug failure
if: failure()
run: |
kubectl -n argo get all
kubectl -n argo describe all
kubectl -n argo-events get all
kubectl -n argo-events describe all
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# verify with local kind k8s cluster.
name: Argo workflow E2E test
name: Argo workflows E2E test

on:
workflow_dispatch:
pull_request:
branches: [main]
paths:
- "argo/workflow/**"
- ".github/workflows/argo_workflow_*"
- "argo/workflows/**"
- ".github/workflows/argo_workflows_*"

jobs:
kubernetes:
Expand All @@ -32,7 +32,8 @@ jobs:
# wait all be ready
kubectl -n argo wait deploy --all --for condition=Available --timeout 5m
- name: Create ${{ matrix.feature }} feature data
run: kubectl -n argo create -f argo/workflow/${{ matrix.feature }}
working-directory: argo/workflows
run: kubectl -n argo create -f ${{ matrix.feature }}
- name: Waitting for verify cron workflows condition.
if: matrix.feature == 'cron-workflow'
run: |
Expand Down
71 changes: 71 additions & 0 deletions argo/events/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Argo events
===

accroding to:

- https://argoproj.github.io/argo-events/quick_start/


## Summary

[Architecture](https://argoproj.github.io/argo-events/concepts/architecture/)

![Architecture](https://argoproj.github.io/argo-events/assets/argo-events-architecture.png)

## Install

1. setup workflows
- setup workflows namespace:
> `kubectl create namespace argo`
- setup workflows components:
> `kubectl -n argo apply -f https://raw.githubusercontent.com/argoproj/argo-workflows/master/manifests/install.yaml`
2. setup events
- create events namespace
> `kubectl create namespace argo-events`
- create events CRD and role bindings,configmaps, etc...
> `kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/master/manifests/install.yaml`
- setup events components components - event bus:
> `kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/eventbus/native.yaml`
- setup event source components, such as webhook:
> `kubectl -n argo-events apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/event-sources/webhook.yaml`
- setup event sensor components:
1. create service account with role binding:
```bash
# sensor rbac
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/master/examples/rbac/sensor-rbac.yaml
# workflow rbac
kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/master/examples/rbac/workflow-rbac.yaml
```
2. create sensor, such as webhook:
> `kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/sensors/webhook.yaml`

## Test

flow is:

```
\ --->
http request
\
webhook event source pod
\
event bus
\
webhook sensor
\
k8s
\
create a argo workflow resource
```

1. trigger a webhook request:
```bash
kubectl -n default create job sendwebhook --image=curlimages/curl -- curl \
-X POST \
-d '{"message":"this is my first webhook"}' \
-H "Content-Type: application/json" \
http://webhook-eventsource-svc.argo-events:12000/example
kubectl -n default wait job/sendwebhook --for=condition=completed --timeout=1m
```
2. wait the workflow
> `kubectl -n argo-events wait workflows --all --for=condition=Completed --timeout=1m`
File renamed without changes.