Argo Workflows provides easy-to-use interfaces and tools that let you define workflows in YAML to quickly configure a CI pipeline. You can run tasks in parallel within your cluster, dynamically scale computing resources as needed, and improve the efficiency of your CI pipeline.
How it works
When building a CI pipeline with Argo Workflows, you primarily use BuildKit to build and push container images and BuildKit Cache to accelerate the build process. By storing the Go mod cache on File Storage NAS, you can speed up the go test and go build processes, significantly accelerating the entire CI pipeline.
Predefined workflow template
You can use the predefined template directly or customize it to create your own. This example creates a CI workflow template (ClusterWorkflowTemplate) named ci-go-v1. This template uses BuildKit Cache and File Storage NAS to store the Go mod cache, accelerating the CI pipeline.
Procedure
This topic demonstrates how to build a CI pipeline with a public Git repository. If your CI pipeline uses a private Git repository, you must first clone the repository. For more information, see Clone a private Git repository in a CI pipeline.
The Secret for container image access credentials and the mounted File Storage NAS volume must be in the same namespace as the workflow.
Step 1: Create access credentials for ACR EE
BuildKit primarily uses ACR EE access credentials to push images.
-
Configure access credentials for Container Registry Enterprise Edition (ACR EE). For more information, see Configure access credentials.
-
Run the following command to create a Secret in the cluster. This Secret stores the ACR EE password used by BuildKit.
Note$repositoryDomain: Replace this with the address of your Container Registry repository.$username: Replace this with the username for your Container Registry repository.$password: Replace this with the password for your Container Registry repository.kubectl create secret -n argo generic docker-config --from-literal="config.json={\"auths\": {\"$repositoryDomain\": {\"auth\": \"$(echo -n $username:$password|base64)\"}}}"
Step 2: Mount a File Storage NAS volume
After you mount a File Storage NAS volume, you can share data, such as cloned repository information, between different tasks in a workflow. The volume also stores the Go mod cache, which accelerates the go test and go build processes in the CI pipeline.
For more information about how to mount a File Storage NAS volume, see Use volumes.
Step 3: Start a workflow from the template
Console
-
Log on to the Argo console. In the left-side navigation pane, click Cluster Workflow Templates, and then click the predefined template named ci-go-v1.
-
On the template details page, click + SUBMIT in the upper-left corner. In the panel that opens, enter the required parameters, and then click + SUBMIT at the bottom of the panel.
Refer to the template parameter descriptions to set the parameter values based on your actual configuration.
After the workflow starts, go to the Workflows details page to check its status:
A green check mark on each node in the workflow DAG (git-checkout-pr → run-test → build-push-image) indicates that the stage is complete.
Argo CLI
-
Create a
workflow.yamlfile with the following content. Modify the parameter values based on your requirements. For more information, see the template parameter descriptions.apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: ci-go-v1- labels: workflows.argoproj.io/workflow-template: ackone-ci namespace: argo 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: main - name: container_image value: "test-registry.cn-hongkong.cr.aliyuncs.com/acs/echo-server" - 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 -
Run the following command to submit the workflow.
argo submit workflow.yaml
Contact us
If you have any product suggestions or questions, you can contact us by joining the DingTalk group (ID: 35688562).