You can use EventBridge and Argo Workflows to build an efficient, fast, and cost-effective automated CI pipeline. This event-driven approach simplifies and accelerates application delivery.
Prerequisites
-
You have activated ACK One.
-
You have activated ECI.
-
You have activated EventBridge and granted the required permissions.
-
You have created a workflow cluster.
-
You have created a file system.
-
You have created a Container Registry Enterprise Edition instance.
-
The AliyunAdcpFullAccess policy is attached to a RAM user. For more information, see Grant permissions to a RAM user.
How it works
An automated, event-driven CI pipeline consists of two parts:
-
A Git event trigger: Committing code to a Git repository triggers a corresponding event.
-
A CI system: The system runs pre-build tests, builds a Docker image, and pushes the image to an image repository.
After the image is built, you can use a Continuous Deployment (CD) system, such as ACK One GitOps, to synchronize the new image tag to the Kubernetes cluster.
This event-driven solution uses EventBridge, which offers advantages in availability, usability, security, and scalability. The CI part is built on Argo Workflows, a graduated project from the Cloud Native Computing Foundation (CNCF). The ACK One workflow cluster provides a fully managed Argo Workflows service, enhancing stability and observability. This helps you build larger, faster, and more cost-effective CI pipelines.
-
A user commits code to a Git repository.
-
Based on the configured rules, EventBridge captures the Git event and delivers it to the ACK One workflow cluster, which triggers the CI workflow.
-
The CI workflow in the ACK One workflow cluster builds a Docker image and pushes it to an image repository. You can then use GitOps to automatically synchronize the image changes to an ACK cluster.
Step 1: Prepare the CI environment
-
Create an access credential for ACR EE and mount a File Storage NAS volume. For more information, see Step 1 and Step 2 in Build a CI pipeline for a Go project in a workflow cluster.
NoteEnsure that the namespace is the same as the one used for your Workflow resource.
-
This example uses the echo-server project for the application code. Fork this project to your own 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. For more information, see GitHub integration.
-
(Optional) Configure an event rule. This example uses the following configuration. For more information about how to configure event rules, see Manage event rules.
-
Event pattern: The following pattern triggers the pipeline only for changes pushed 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). The following example is for reference. Configure the CR with your information.
ImportantIn the resource configuration, you must explicitly set
nameandnamespace. Do not usegenerateName. If the resource belongs to thedefaultnamespace, you must still declare it.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 of the GitHub repository triggers the automated pipeline. You can verify the process in the following ways:-
View the event trace.
Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
-
Click the name of the target event bus. In the left-side navigation pane, click Event Tracking.
-
On the event tracing page, view the trace of the event.
The event trace details show the following information: In the Event Receiving section, Event Type is
eventbridge:Events:HTTPEvent, Bus Name is ci-test, and event source is github.event. In the Event Delivering section, the rule ttt successfully delivered the event to the target endpoint. This single delivery took 59 ms, returned a 200 response code, and had a status of Success.
-
View the execution topology of the new workflow.
View the execution topology of the new workflow in the ACK One workflow cluster. For more information, see Enable Argo Server to access a workflow cluster.
The workflow is named
ci-go-v1-eb-3999580c-1ee4-4e10-a75b-af6e8eddccde. Its execution topology is a directed acyclic graph (DAG) of three sequential steps: git-checkout-pr, run-test, and build-push-image. The git-checkout-pr and run-test steps have completed successfully, and the build-push-image step is running.
-