argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
15.11k stars 3.21k forks source link

docs: Add CI/CD example for building Argo Workflows using Argo Workflows - Fixes #8591 #13895

Open wesleyscholl opened 1 week ago

wesleyscholl commented 1 week ago

A detailed example for implementing CI/CD pipelines to build Argo Workflows using Argo Workflows

Fixes #8591

Motivation

This issue was more than 2 years old and I wanted to contribute to the project. I also work with Argo Workflows everyday and I'm CAPA certified (Certified Argo Project Associate).

Modifications

WorkflowTemplate example includes:

CI

Description Resource Status
Argo Workflows API endpoint, submits WorkflowTemplate WorkflowEventBinding :ballot_box_with_check:
Build the CLI WorkflowTemplate :ballot_box_with_check:
Build images using Buildkit - Push images to Docker Hub WorkflowTemplate :ballot_box_with_check:
Run unit tests and collect test report WorkflowTemplate :ballot_box_with_check:
Run coverage and collect report WorkflowTemplate :ballot_box_with_check:
Deploy to a cluster WorkflowTemplate :ballot_box_with_check:
Run basic E2E tests and collect report WorkflowTemplate :ballot_box_with_check:

Pipeline

Description Resource Status
Combine CI and CD jobs with an approval step WorkflowTemplate :ballot_box_with_check:

CD

Description Resource Status
Tag and push tag WorkflowTemplate :ballot_box_with_check:
Update deployment manifests using kustomize edit set image WorkflowTemplate :ballot_box_with_check:
Commit deployment manifests WorkflowTemplate :ballot_box_with_check:
Start Argo CD sync step WorkflowTemplate :ballot_box_with_check:

Documentation & Configuration

Description Resource Status
CI, CD, & Pipeline Documentation Comments :ballot_box_with_check:
Service Account for WorkflowEventBinding ServiceAccount :ballot_box_with_check:
$ARGO_TOKEN - Bearer Authorization for WorkflowEventBinding Secret :ballot_box_with_check:
Role to submit workflow templates for WorkflowEventBinding Role :ballot_box_with_check:
RoleBinding the Role to the ServiceAccount for WorkflowEventBinding RoleBinding :ballot_box_with_check:
Docker configuration - Hub credentials Secret :ballot_box_with_check:
GitHub PAT - GitHub credentials Secret :ballot_box_with_check:
ArgoCD server and credentials Secret :ballot_box_with_check:
ArgoCD network policy NetworkPolicy :ballot_box_with_check:

Verification

Thoroughly tested the workflow:

wesleyscholl commented 4 days ago

For review: @alexec @terrytangyuan @sarabala1979 @caelan-io

Thanks

mubarak-j commented 1 day ago

I'm not sure how this adds any complexity or burden when there are more than 50 examples in this repo. The lack of documentation/example for CI/CD use case, makes this a much-needed addition, as described in the linked issue.

Joibel commented 13 hours ago

I would like this to make it clear that it isn't a useful CI/CD for workflows, as it doesn't build everything and doesn't run all of the e2e tests. It doesn't build the controller.

It also feels like we should demonstrate a proper DAG, rather than running the whole thing in series. Build and test the components in parallel.

I'm also not sure that workflows is a good thing to demonstrate this on, as it's pretty peculiar and demonstrates bad practice - e.g. the argo-cli you build in the earlier test isn't the one under test in e2e.

@tico24 did a talk at argocon about doing the whole thing, including fixing some of this https://www.youtube.com/watch?v=q2jAPJHfubA

On the other hand, it would be good to have something in here. Perhaps explain the scope of what is going on and the caveats better in the example. This isn't like most of the other examples in there - the readme section of it is longer than most of the other actual examples in total, so I'm not sure all comparisons apply.

mubarak-j commented 7 hours ago

I agree it would be good to have something in here considering that the last Argo workflows survery had CI/CD was the top use case and yet this repo lack an example for that. Like other examples (which are not meant to be full-fledged solutions), this is a great starting point...

wesleyscholl commented 7 hours ago

@terrytangyuan

The example is a bit long, but it includes all the requirements from #8591. Would be it easier to maintain if it was split into separate CI and CD WorkflowTemplates? Then link them in the docs.

@Joibel

Thanks for reviewing, this is the first CI/CD pipeline I've ever built. I want to modify this example to make it fully functional. For instance, adding this line to build the controller:

make controller kit STATIC_FILES=false

The workflow can implement a DAG to run all of the e2e tests in parallel and use the argo-cli build in the e2e tests.

As for the scope and caveats, should more comments be added to the example to explain each step in the workflow?