This topic describes how to use a Distributed Cloud Container Platform for Kubernetes (ACK One) workflow cluster to build an image continuous integration (CI) pipeline.
Prerequisites
A workflow cluster is created. The kubeconfig file of the cluster is obtained from the ACK One console and used to connect to the workflow cluster through kubectl. For more information, see Connect to a cluster by using kubectl.
A Resource Access Management (RAM) user is authorized to manage the ACK One workflow cluster.
A Container Registry Enterprise Edition instance is created.
Limits
A CI pipeline built by using this method cannot trigger image builds based on code commits.
Benefits of ACK One workflow clusters
Build an image CI pipeline
The ACK One workflow cluster uses the BuildKit tool to build and push images. In this example, BuildKit is deployed by using the moby/buildkit:v0.12.1-rootless image, which can be downloaded from Docker Hub (https://hub.docker.com/r/moby/buildkit).
Step 1: Create a Secret in the workflow cluster to store the username and password for logging on to the Container Registry Enterprise Edition instance.
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 workflow cluster to store the credentials, which can be used by BuildKit to access the Container Registry Enterprise Edition instance.
Replace
${workflow_kubeconfig}and$username:$passwordin the following code block with the actual values.# repositoryDomain: For example, you can set the value to demo-test-registry.cn-hangzhou.cr.aliyuncs.com. kubectl --kubeconfig ${workflow_kubeconfig} create secret generic docker-config --from-literal="config.json={\"auths\": {\"$repositoryDomain\": {\"auth\": \"$(echo -n $username:$password|base64)\"}}}"
Step 2: Create a WorkflowTemplate in the workflow cluster
You can use a WorkflowTemplate to configure code cloning from a Git repository, image building, and image pushing.
Code cloning from Git repository: In this example, a public Git repository is used. If you want to use a private Git repository, specify a token for logging on to the private repository. Example:
git clone https://[username]:[token]@gitlab.com/demo3624733/echo-server.git.Image building and pushing: In this example, the BuildKit tool is used to build and push images.
The following section describes how to create a WorkflowTemplate that does not use shared storage and a WorkflowTemplate that uses File Storage NAS (NAS).
Create a WorkflowTemplate that does not use shared storage
This method allows you to build a CI pipeline through simple steps. The following WorkflowTemplate configures an init container to clone code to an emptyDir volume and build images in a temporary directory.
Create a file named worktemplate-1.yaml based on the following YAML template.
Specify a repository, a branch, and an image in the parameters section. Replace the username and token in the following template with the actual ones that are used.
Run the following command to create a WorkflowTemplate in the workflow cluster:
kubectl --kubeconfig ${ackone_argo_kubeconfig} apply -f worktemplate-1.yaml
Create a WorkflowTemplate that uses NAS
This method uses NAS to share data between the pod created to clone code from a Git repository and the pod created to build images. For more information about how to provision NAS volumes in a workflow cluster, see Use volumes.
Create a file named worktemplate-2.yaml based on the following YAML template.
Specify a repository, a branch, and an image in the parameters section. Replace the username and token in the following template with the actual ones that are used.
Run the following command to create a WorkflowTemplate in the workflow cluster:
kubectl --kubeconfig ${ackone_argo_kubeconfig} apply -f worktemplate-2.yaml
Step 3: Create a workflow
Create a file named workflow.yaml based on the following YAML template:
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: annotations: workflows.argoproj.io/pod-name-format: v1 generateName: echo-server- spec: workflowTemplateRef: name: echo-serverRun the following command to create a workflow in the workflow cluster:
kubectl --kubeconfig ${ackone_argo_kubeconfig} create -f workflow.yaml
Step 4: View the workflow in the ACK One console
After you enable Internet access, you can access the Argo console from the Distributed Cloud Container Platform for Kubernetes (ACK One) console.
Log on to the ACK One console. In the left-side navigation pane, click Workflow Cluster.
On the Basic Information tab, click Workflow Console (Argo) in the Common Operations section.
On the left side of the Workflow console, set NAMESPACE to default to view the workflow you created.