Build an efficient, low-cost, event-driven CI pipeline with EventBridge and Argo Workflows on ACK One to simplify and accelerate application delivery. This topic explains how to set up the automated CI pipeline workflow.EventBridge and Argo Workflows on ACK One.
Prerequisites
-
EventBridge is activated and the required permissions are granted.
-
A workflow cluster is created.
-
A file system is created.
-
A Container Registry Enterprise Edition instance is created.
-
The AliyunAdcpFullAccess policy is attached to a RAM user.
How it works
An event-driven CI pipeline has two parts:
-
A Git event trigger: Committing code to a Git repository triggers an event.
-
A CI system: Runs pre-build tests, builds a Docker image, and pushes it to an image repository.
After the image is built, use a Continuous Deployment (CD) system, such as ACK One GitOps, to synchronize the new image tag to the Kubernetes cluster.
This solution uses EventBridge, which offers advantages in availability, usability, security, and scalability. The CI layer uses Argo Workflows (CNCF graduated). The ACK One workflow cluster provides fully managed Argo Workflows with enhanced stability, observability, and O&M capabilities, helping you run larger-scale CI pipelines with faster execution and lower cost.workflow cluster provides fully managed Argo Workflows with enhanced stability and observability.
-
A user commits code to a Git repository.
-
Based on configured rules, EventBridge captures the Git event and delivers it to the ACK One workflow cluster, triggering the CI workflow.
-
The CI workflow in the ACK One workflow cluster builds a Docker image and pushes it to an image repository. Use GitOps to synchronize the image to an ACK cluster.
Step 1: Prepare the CI environment
-
Create an ACR EE access credential and mount a File Storage NAS volume. Complete Step 1 and Step 2 in Build a CI pipeline for a Go project in a workflow cluster.
NoteUse the same namespace as your Workflow resource.
-
This example uses the echo-server project. Fork it to your GitHub account and modify the WorkflowTemplate as described in Clone a private Git repository in a CI pipeline.
Step 2: Create an event-driven CI pipeline
-
Integrate EventBridge with GitHub. See GitHub integration.
-
(Optional) Configure an event rule. This example uses the following configuration. See Manage event rules.
-
Event pattern: This pattern triggers the pipeline only for pushes to the
release-v1branch.{ "source": [ "github.event" ], "data": { "body": { "ref": [ "refs/heads/release-v1" ] } } } -
Configure an event target.
-
Service Type: Select Container Service for Kubernetes.
-
Kubernetes Cluster File: Enter the kubeconfig for your ACK One workflow cluster.
-
YAML Configuration: Select Template for this example.
-
Variable: Add
workflowNameand set it to the event ID.{ "workflowName": "$.id" } -
Template: Enter the Workflow CI custom resource (CR). Replace the values in the following example with your own.
ImportantExplicitly set
nameandnamespace. Do not usegenerateName. Declare the namespace even if it isdefault.apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: name: ci-go-v1-eb-${workflowName} namespace: default labels: workflows.argoproj.io/workflow-template: ackone-ci spec: arguments: parameters: - name: repo_url value: https://github.com/ivan-cai/echo-server.git - name: repo_name value: echo-server - name: target_branch value: release-v1 - name: container_image value: "YOUR-IMAGE-REGISTRY-ADDRESS" # Replace the value with the address of your image repository. - name: container_tag value: "v1.0.0" - name: dockerfile value: ./Dockerfile - name: enable_suffix_commitid value: "true" - name: enable_test value: "true" workflowTemplateRef: name: ci-go-v1 clusterScope: true -
Network Access: Select Internet for this example.
-
-
-
After you apply this configuration, any commit to the
release-v1branch triggers the pipeline. Verify the process:-
View the event trace.
Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
-
Click the target event bus. In the left-side navigation pane, click Event Tracking.
-
On the event tracing page, view the event trace.
The event trace shows: In Event Receiving, Event Type is
eventbridge:Events:HTTPEvent, Bus Name is ci-test, and source is github.event. In Event Delivering, rule ttt delivered the event to the target (59 ms, 200 response code, Success).
-
View the execution topology of the new workflow.
Check the workflow topology in the ACK One workflow cluster. See Enable Argo Server to access a workflow cluster.
Workflow
ci-go-v1-eb-3999580c-1ee4-4e10-a75b-af6e8eddccderuns three sequential steps: git-checkout-pr, run-test, and build-push-image. git-checkout-pr and run-test completed, and build-push-image is running.
-