Skip to content

crenshaw-dev/argocd-executor-plugin

 
 

Repository files navigation

Argo CD Executor Plugin

codecov

An Executor Plugin for Argo Workflows that lets you interact with Argo CD servers. All you need is an Argo CD API token.

Example

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: argocd-example-
spec:
  entrypoint: main
  templates:
  - name: main
    steps:
    - - name: sync
        template: sync
        arguments:
          parameters:
            - name: apps
              value: |
                - name: guestbook-frontend
                - name: guestbook-backend
    - - name: diff
        template: diff
  - name: sync
    inputs:
      parameters:
        - name: apps
    plugin:
      argocd:
        app:
          sync:
            apps: "{{inputs.parameters.apps}}"
  - name: diff
    plugin:
      argocd:
        app:
          diff:
            app:
              name: guestbook-frontend

Getting Started

Step 1: Get an Argo CD token

The plugin requires a secret named argocd-token with a key called token containing the Argo CD token. See the Argo CD documentation for information about generating tokens.

apiVersion: v1
kind: Secret
metadata:
  name: argocd-token
stringData:
  token: <token>

After defining the secret, apply it to your cluster:

kubectl apply -f argocd-token.yaml

Step 2: Install the plugin

kubectl apply -n argo -f https://raw.githubusercontent.com/crenshaw-dev/argocd-executor-plugin/main/manifests/argocd-executor-plugin-configmap.yaml

Note: You will have to run the workflow using a service account with appropriate permissions. See examples/rbac.yaml for an example.

Step 3: Set your ARGOCD_SERVER environment variable

By default, the plugin uses argocd-server.argocd.svc.cluster.local for ARGOCD_SERVER. If you're using a different server, you can set the ARGOCD_SERVER environment variable in the plugin's configmap.

Step 4: Run a workflow

argo submit examples/argocd.yaml --serviceaccount my-service-account --watch

Examples

The actions field of the plugin config accepts a nested list of actions. Parent lists are executed sequentially, and child lists are executed in parallel. This allows you to run multiple actions in parallel, and multiple groups of actions in sequence.

Setting sync options

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: argocd-options-example-
spec:
  entrypoint: main
  templates:
  - name: main
    plugin:
      argocd:
        app:
          sync:
            apps: |
              - name: guestbook-backend
            options: |
              - ServerSideApply=true
              - Validate=true

Setting a timeout

Each sync action may be configured with a timeout. The default is no timeout.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: argocd-timeout-example-
spec:
  entrypoint: main
  templates:
  - name: main
    plugin:
      argocd:
        app:
          sync:
            apps: |
              - name: guestbook-backend
            options: |
              - ServerSideApply=true
              - Validate=true
        timeout: 30s

Specifying the Application's namespace

Starting in Argo CD v2.5, Applications may be installed outside the argocd namespace (or whichever namespace Argo CD installed in). To specify the namespace, use the namespace field.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: argocd-namespace-example-
spec:
  entrypoint: main
  templates:
  - name: main
    plugin:
      argocd:
        app:
          sync:
            apps: |
              - name: guestbook-backend
                namespace: my-apps-namespace

Contributing

Head to the scripts directory to find out how to get the project up and running on your local machine for development and testing purposes.

About

An Argo Workflows executor plugin that can interact with an Argo CD server.

Resources

License

Stars

Watchers

Forks

Languages

  • Go 83.4%
  • Shell 12.4%
  • Makefile 2.9%
  • Dockerfile 1.3%