diff --git a/.github/workflows/argo_events_test.yaml b/.github/workflows/argo_events_test.yaml new file mode 100644 index 0000000..640d743 --- /dev/null +++ b/.github/workflows/argo_events_test.yaml @@ -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/setup-kind@v0.5.0 + 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 diff --git a/.github/workflows/argo_workflow_test.yaml b/.github/workflows/argo_workflows_test.yaml similarity index 88% rename from .github/workflows/argo_workflow_test.yaml rename to .github/workflows/argo_workflows_test.yaml index d2564a2..e8fd747 100644 --- a/.github/workflows/argo_workflow_test.yaml +++ b/.github/workflows/argo_workflows_test.yaml @@ -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: @@ -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: | diff --git a/argo/events/README.md b/argo/events/README.md new file mode 100644 index 0000000..16dcd7f --- /dev/null +++ b/argo/events/README.md @@ -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` diff --git a/argo/workflow/README.md b/argo/workflows/README.md similarity index 100% rename from argo/workflow/README.md rename to argo/workflows/README.md diff --git a/argo/workflow/cron-workflow/cron.yaml b/argo/workflows/cron-workflow/cron.yaml similarity index 100% rename from argo/workflow/cron-workflow/cron.yaml rename to argo/workflows/cron-workflow/cron.yaml diff --git a/argo/workflow/workflow-template/00-templates.yaml b/argo/workflows/workflow-template/00-templates.yaml similarity index 100% rename from argo/workflow/workflow-template/00-templates.yaml rename to argo/workflows/workflow-template/00-templates.yaml diff --git a/argo/workflow/workflow-template/01-hello-world.yaml b/argo/workflows/workflow-template/01-hello-world.yaml similarity index 100% rename from argo/workflow/workflow-template/01-hello-world.yaml rename to argo/workflows/workflow-template/01-hello-world.yaml diff --git a/argo/workflow/workflow/hello-world.yaml b/argo/workflows/workflow/hello-world.yaml similarity index 100% rename from argo/workflow/workflow/hello-world.yaml rename to argo/workflows/workflow/hello-world.yaml