argocdapp Plugin

This plugin creates an Argo CD Application custom resource.

Notes:

  • Argo CD itself must have been already installed before the usage of this plugin. To install Argo CD, use the helm-installer plugin. Or you can use both plugins(argocd+argocdapp) at the same time. See GitOps Toolchain for more info.
  • Currently, only the Helm chart is supported when creating the Argo CD application.

Usage

The following content is an example of the “tool file”.

For more information on the main config, the tool file and the var file of DevStream, see Core Concepts Overview and DevStream Configuration.

YAML

  1. tools:
  2. # name of the tool
  3. - name: argocdapp
  4. # id of the tool instance
  5. instanceID: default
  6. # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
  7. dependsOn: [ "argocd.ARGOCD_INSTANCE_NAME" ]
  8. # options for the plugin
  9. options:
  10. # information on the ArgoCD Application
  11. app:
  12. # name of the ArgoCD Application
  13. name: hello
  14. # where the ArgoCD Application custom resource will be created
  15. namespace: argocd
  16. # destination of the ArgoCD Application
  17. destination:
  18. # on which server to deploy
  19. server: https://kubernetes.default.svc
  20. # in which namespace to deploy
  21. namespace: default
  22. # source of the application
  23. source:
  24. # which values file to use in the Helm chart
  25. valuefile: values.yaml
  26. # path of the Helm chart
  27. path: charts/go-hello-http
  28. # Helm chart repo URL, this is only an example, do not use this
  29. repoURL: YOUR_CHART_REPO_URL
  30. # Helm chart repo branch
  31. repoBranch: YOUR_CHART_REPO_BRANCH
  32. # if repo doesn't contain path, use imageRepo to create a helm config
  33. imageRepo:
  34. # imageRepo address
  35. url: IMAGE_REPO_ADDRESS
  36. user: IMAGE_REPO_OWNER
  37. # config inital image tag
  38. initalTag: IMAGE_REPO_TAG

Automatically Create Helm Configuration

This plugin can push helm configuration automatically when your source.path helm config does not exist so that you can use this plugin with helm configured already. For example:

YAML

  1. ---
  2. tools:
  3. - name: go-webapp-argocd-deploy
  4. plugin: argocdapp
  5. dependsOn: ["repo-scaffolding.golang-github"]
  6. options:
  7. app:
  8. name: hello
  9. namespace: argocd
  10. destination:
  11. server: https://kubernetes.default.svc
  12. namespace: default
  13. source:
  14. valuefile: values.yaml
  15. path: charts/go-hello-http
  16. repoURL: https://github.com/devstream-io/testrepo.git
  17. imageRepo:
  18. url: http://test.barbor.com/library
  19. user: test_owner
  20. tag: "1.0.0"

This config will push the default helm config](https://github.com/devstream-io/dtm-pipeline-templates/tree/main/argocdapp/helm)\ to repo testrepo, and the generated config will use the image http://test.barbor.com/library/test_owner/hello:1.0.0 as the initial image for Helm.

Use Together with the repo-scaffolding Plugin

This plugin can be used together with the repo-scaffolding plugin (see document here.)

For example, you can first use repo-scaffolding to bootstrap a Golang repo, then use this plugin to set up basic GitHub Actions CI workflows. In this scenario:

  • This plugin can specify repo-scaffolding as a dependency, so that the dependency is first satisfied before executing this plugin.
  • This plugin can refer to repo-scaffolding‘s output to reduce copy/paste human error.

See the example below:

YAML

  1. ---
  2. tools:
  3. - name: repo-scaffolding
  4. instanceID: golang-github
  5. options:
  6. destinationRepo:
  7. owner: [[ githubUsername ]]
  8. org: ""
  9. name: [[ repoName ]]
  10. branch: [[ defaultBranch ]]
  11. scmType: github
  12. vars:
  13. imageRepo: "[[ dockerhubUsername ]]/[[ repoName ]]"
  14. sourceRepo:
  15. org: devstream-io
  16. name: dtm-scaffolding-golang
  17. scmType: github
  18. - name: go-webapp-argocd-deploy
  19. plugin: argocdapp
  20. dependsOn: ["repo-scaffolding.golang-github"]
  21. options:
  22. app:
  23. name: hello
  24. namespace: argocd
  25. destination:
  26. server: https://kubernetes.default.svc
  27. namespace: default
  28. source:
  29. valuefile: values.yaml
  30. path: charts/go-hello-http
  31. repoURL: ${{repo-scaffolding.golang-github.outputs.repoURL}}

In the example above:

  • We put repo-scaffolding.golang-github as dependency by using the dependsOn keyword.
  • We used repo-scaffolding.golang-github‘s output as input for the github-actions plugin.

Pay attention to the ${{ xxx }} part in the example. ${{ TOOL_NAME.PLUGIN.outputs.var}} is the syntax for using an output.