Skip to content

GitOps Toolchain

If you are interested in watching a video demo, see the youtube video below:

https://www.youtube.com/watch?v=q7TK3vFr1kg

For Chinese readers, watch this one instead:

https://www.bilibili.com/video/BV1W3411P7oW/

Plugins needed

  1. repo-scaffolding
  2. jira-github
  3. githubactions-golang
  4. argocd
  5. argocdapp

The dependencies of these plugins are(a -> b means for a depends on b):

  • jira-github -> repo-scaffolding
  • githubactions-golang -> repo-scaffolding
  • argocdapp -> argocd, githubactions-golang and repo-scaffolding

Note: These dependencies are optional; you can use dependency to make sure a certain tool is installed before another. We should use dependency according to the actual usage situation.

1 Download DevStream (dtm)

Download the appropriate dtm version for your platform from DevStream Releases.

Remember to rename the binary file to dtm so that it's easier to use. For example: mv dtm-darwin-arm64 dtm.

Once downloaded, you can run the binary from anywhere. Ideally, you want to put it in a place that is in your PATH (e.g., /usr/local/bin).

2 Prepare the Config File

Download the gitops.yaml to your working directory:

Bash
curl -o gitops.yaml https://raw.githubusercontent.com/devstream-io/devstream/main/examples/gitops.yaml

Then modify the gitops.yaml file accordingly.

For me I can set these variables like:

Variable Example Note
defaultBranch main The branch name you want to use
githubUsername daniel-hutao It should be case-sensitive here; strictly use your GitHub username
repoName go-webapp As long as it doesn't exist in your GitHub account and the name is legal
dockerhubUsername exploitht It should be case-sensitive here; strictly use your DockerHub username
jiraID merico This is a domain name prefix like merico in https://merico.atlassian.net
jiraProjectKey DT A descriptive prefix for your project’s issue keys to recognize work from this project
jiraUserEmail tao.hu@merico.dev The email you use to log in to Jira
argocdNameSpace argocd The namespace used by ArgoCD
argocdDeployTimeout 10m How long does ArgoCD deployment timeout

These plugins require some environment variables to work, so let's set them:

Bash
export GITHUB_TOKEN="YOUR_GITHUB_TOKEN_HERE"
export JIRA_API_TOKEN="YOUR_JIRA_API_TOKEN_HERE"
export DOCKERHUB_TOKEN="YOUR_DOCKERHUB_TOKEN_HERE"

If you don't know how to create these three tokens, check out:

3 Initialize

Run:

Bash
dtm init -f gitops.yaml

4 Apply

Run:

Bash
dtm apply -f gitops.yaml

and confirm to continue, then you should see similar output to:

Text Only
...
2022-03-11 13:36:11 ✔ [SUCCESS]  All plugins applied successfully.
2022-03-11 13:36:11 ✔ [SUCCESS]  Apply finished.

5 Check the Results

Let's continue to look at the results of the apply command.

5.1 Repository Scaffolding

  • The repository scaffolding we got looks like this:

5.2 Jira-Github Integration

  • How do Jira and Github integrate? Let's create a new issue:

  • The issue will be renamed automatically like this:

  • We can find this auto-synced Story in Jira:

  • If we continue to leave a comment on this issue:

  • The comment will also be automatically synced to Jira:

5.3 GitHub Actions CI for Golang

  • What does CI do here?

  • The CI processes also build an image, and this image is automatically pushed to DockerHub:

5.4 ArgoCD Deployment

  • Of course, the ArgoCD must have been installed as expected.

5.5 ArgoCD Application Deployment

  • Our code has just been built into an image, at this time the image is automatically deployed to our k8s as a Pod:

6 Clean Up

Run:

Bash
dtm destroy -f gitops.yaml

and you should see similar output:

Text Only
2022-03-11 13:39:11 ✔ [SUCCESS]  All plugins destroyed successfully.
2022-03-11 13:39:11 ✔ [SUCCESS]  Destroy finished.