A workflow cluster provides fully managed Argo Workflows built on the open-source Argo Workflows project. It is highly elastic, scales automatically, and requires no operations or maintenance, letting you build simpler, cost-effective, and efficient CI pipelines. This topic describes how to build a CI pipeline for a Golang project using a workflow cluster.
Solution overview
When building a CI pipeline with a workflow cluster, you mainly use BuildKit to build and push container images and BuildKit Cache to accelerate image builds. Storing the Go mod cache on NAS accelerates the go test and go build commands, significantly speeding up the overall CI pipeline.
Preset workflow template
A workflow cluster includes a preset CI workflow template (ClusterWorkflowTemplate) named ci-go-v1. This template uses BuildKit Cache and stores the Go mod cache on NAS to significantly accelerate the CI pipeline.
You can use the preset template directly or customize it to create your own CI workflow template.
The preset CI workflow template includes the following steps:
Git clone & checkout
Clones a Git repository and checks out the target branch.
Retrieves the commit ID and appends it as a suffix to the image tag during the build.
Run go test
Runs all test cases in the Git repository (Go project) by default.
You can use the workflow parameter
enable_testto control whether to run this step.The Go mod cache is stored in the
/pkg/moddirectory on NAS to accelerate both thego testcommand and the subsequentgo buildcommand.
Build & push image
Uses BuildKit to build and push the container image, and uses a registry-type cache from BuildKit Cache to accelerate image builds.
By default, the image tag uses the
{container_tag}-{commit_id}format. You can control whether to append the commit ID using a parameter when you submit the workflow.When the new image is pushed, an image with the
latesttag is also pushed, overwriting the existing one.
Prerequisites
Create a Container Registry Enterprise Edition instance (ACR EE).
If you use a private Git repository, you must configure the workflow to clone it.
Step 1: Create a Container Registry access credential
Obtain the kubeconfig file for the cluster and use kubectl to connect to the cluster.
Configure the access credential for the Container Registry Enterprise Edition instance. If you use a VPC domain name for access, ensure that the cluster and the Container Registry repository are in the same VPC. If you use a public domain name, configure public access control.
Replace
USER_NAME:PASSWORDin the following command with your Container Registry Enterprise Edition instance's access credential. Then, run the command to create a Secret in the workflow cluster for BuildKit to use.The Secret and the mounted NAS volume must be in the same namespace as the workflow you submit.
kubectl create secret generic docker-config --from-literal="config.json={\"auths\": {\"$repositoryDomain\": {\"auth\": \"$(echo -n USER_NAME:PASSWORD|base64)\"}}}"
Step 2: Mount a NAS volume
Use a NAS volume to share data between workflow tasks, such as cloned repository information, and to store the Go mod cache, accelerating the go test and go build commands.
Log on to the NAS console.
In the left-side navigation pane, choose .
In the upper-left corner of the page, select the resource group and region where the target file system resides.

On the File System List page, find the target file system and click Manage in the Actions column.
On the file system details page, click the Mount Targets tab. In the Mount Target section, view and record the NAS mount point.
Save the following sample code as pv-nas.yaml. Replace MOUNT_POINT with your NAS mount point. Then, run the command
kubectl apply -f pv-nas.yamlto create the volume.apiVersion: v1 kind: PersistentVolume metadata: name: pv-nas labels: alicloud-pvname: pv-nas spec: capacity: storage: 100Gi accessModes: - ReadWriteMany csi: driver: nasplugin.csi.alibabacloud.com volumeHandle: pv-nas # Must be the same as the PV name. volumeAttributes: server: MOUNT_POINT path: "/" mountOptions: - nolock,tcp,noresvport - vers=3 --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: pvc-nas spec: accessModes: - ReadWriteMany resources: requests: storage: 100Gi selector: matchLabels: alicloud-pvname: pv-nas
Step 3: Start a workflow
Console
Log on to the Argo Workflow Clusters console.
On the Cluster Information page, click the Basic Information tab. In the Common Operations section, click Workflow Console (Argo).
In the left-side navigation pane of the Argo UI, click Cluster Workflow Templates, and then click the name of the preset template, ci-go-v1.

In the upper-left corner of the template details page, click + SUBMIT. In the panel that appears, enter the required parameters, and then click + SUBMIT at the bottom of the panel.
For information about the parameters, see the parameter description. Set the parameters to your specific values.

After submission, you can view the workflow status on the Workflows page:

Argo CLI
Update the parameter values to match your configuration, based on the parameter description. Save the following sample code as
workflow.yaml. Then, run the commandargo submit workflow.yamlto submit the workflow.apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: ci-go-v1- 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: 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