Argo Workflows provides intuitive tools to define workflows in YAML, allowing you to quickly set up and configure a CI pipeline. You can run jobs in parallel within your cluster, dynamically scale computing resources as needed, and improve the overall efficiency of your CI pipeline.
How it works
When Argo Workflows builds a CI pipeline, it primarily uses BuildKit to build and push container images and BuildKit Cache to accelerate image building. Using NAS to store the Go mod cache accelerates the go test and go build processes, which in turn significantly speeds up the CI pipeline workflow.
Predefined workflow template
You can use the predefined template directly or customize it to create your own CI workflow template. This example shows how to create a CI workflow template (ClusterWorkflowTemplate) named ci-go-v1 that uses BuildKit Cache and NAS to store the Go mod cache, accelerating the CI pipeline.
Procedure
This topic uses a public Git repository to demonstrate how to build a CI pipeline. If you use a private Git repository in your workflow's CI pipeline, you must first clone the private repository. For more information, see Clone a private Git repository in a CI pipeline.
The Secret that stores the access credentials for the container image and the mounted NAS volume must be in the same namespace as the workflow you submit.
Step 1: Create ACR EE access credentials
BuildKit primarily uses access credentials for Container Registry Enterprise Edition to push images.
-
Configure access credentials for Container Registry Enterprise Edition. For more information, see Configure access credentials.
-
Run the following command to create a Secret in the cluster. This Secret stores the password for Container Registry Enterprise Edition and is used by BuildKit.
NoteReplace
$repositoryDomainwith the address of your Container Registry image repository.Replace
$usernamewith the username for your Container Registry image repository.Replace
$passwordwith the password for your Container Registry image 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 NAS volume
After mounting a NAS volume, you can share data, such as cloned repository information, between different jobs in the workflow. The volume is also used to store the Go mod cache, which accelerates the go test and go build processes in the CI pipeline.
For more information, 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 ci-go-v1 predefined template.
-
On the template details page, click + SUBMIT in the upper-left corner. In the panel, enter the required parameters and then click + SUBMIT at the bottom.
For more information about the parameters, see the Template parameter descriptions section earlier in this topic. Set the parameters to your actual values.
After the workflow is submitted, you can view its status on the Workflows page:
The workflow runs the git-checkout-pr, run-test, and build-push-image steps in sequence as a DAG. When all nodes turn green, the workflow has completed successfully.
Argo CLI
-
Create a file named
workflow.yamlwith the following content. Modify the parameter values based on your requirements. For more information, see the Template parameter descriptions section.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).