Argo Workflows provides easy-to-use interfaces and tools. You can use YAML files to define workflows and quickly configure a Continuous Integration (CI) pipeline. Argo Workflows allows you to simultaneously run jobs in the cluster and dynamically scale the required computing resources. This improves the efficiency of the CI pipeline.
Feature introduction
To create CI pipelines by using Argo Workflows, use BuildKit to build and push container images and then use BuildKit Cache to accelerate image building. Using File Storage NAS (NAS) to store the Go mod cache can accelerate the Go Test
and Go Build
steps. This greatly reduces the required time to create CI pipelines.
Introduction to a predefined ClusterWorkflowTemplate
You can directly use the predefined template or create a custom template based on the predefined template. In this example, a ClusterWorkflowTemplate named ci-go-v1
is created. The template uses BuildKit Cache and NAS to store the Go mod cache to greatly accelerates CI pipeline creation.
Procedure
A public Git repository is used as an example to demonstrate how to create a CI pipeline. If you use a private Git repository, you need to first clone the private repository in the CI pipeline. For more information, see Clone a private Git repository in a CI pipeline.
The Secret that stores the credentials for accessing the container image and the NAS volume must belong to the namespace of the pipeline to be submitted.
Step 1: Create credentials to access the Container Registry Enterprise Edition instance
The credentials are used to pull images from BuildKit.
Configure access credentials for the Container Registry Enterprise Edition instance. For more information, see Configure access credentials for a Container Registry Enterprise Edition instance.
Run the following command to create a Secret in the cluster to store the credentials. The credentials are used by BuildKit.
Note$repositoryDomain
: the domain name of the Container Registry image repository.$username
: the username of the Container Registry image repository.$password
: the password of the 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 you mount a NAS volume, data such as the code repository information for Clone can be shared between various jobs of the workflow. NAS volumes can also be used to store Go mod cache and accelerate the go test
and go build
steps in CI pipeline.
For more information about how to mount NAS volumes, see Use volumes.
Step 3: Launch a pipeline based on the template
Use the console
Log on to the Argo console. In the left-side navigation pane, click Cluster Workflow Templates and click the predefined ClusterWorkflowTemplate named ci-go-v1.
On the template details page, click + SUBMIT in the upper-right corner. In the panel that appears, configure the parameters and click + SUBMIT.
Refer to Template parameters and configure the parameters based on your business requirements.
After you complete the configuration, you can view the status of the pipeline on the Workflows details page.
Use the Argo CLI
Create a file named
workflow.yaml
and copy the following content to the file. Refer to Template parameters and configure the parameters.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 a pipeline:
argo submit workflow.yaml
Contact us
If you have suggestions or questions about this product, join the DingTalk group 35688562 to contact us.