Skip to main content

The ArgoCD Grain

ArgoCD is a popular GitOps continuous delivery tool for Kubernetes. Integrating ArgoCD as a grain in Stack Automation enables a single pane of glass for life-cycle management of your Kubernetes applications. With the ArgoCD grain, you can automate deployment, monitor application health, and manage the full application lifecycle directly from your Stack Automation blueprints, alongside other grains such as Helm, Terraform, and Ansible.

Configuring a Deployment Engine

Before using the ArgoCD grain, you must configure a Deployment Engine in Stack Automation. This engine represents your ArgoCD server and is used to connect and manage applications.

The following fields are required:

  • Engine Name: A unique name for your ArgoCD engine in Stack Automation.
  • Engine Description: (Optional) A description for easy identification.
  • Server URL: The URL of your ArgoCD server (e.g., https://argocd.example.com).
  • Token: The authentication token for accessing the ArgoCD API.
  • Discovery Agent: The Stack Automation management server responsible for ongoing monitoring of tracked applications.
  • Polling Interval (seconds): How often Stack Automation polls ArgoCD for application status and health.

Obtaining the ArgoCD Token

To obtain a token for your ArgoCD server, use the argocd CLI:

argocd login <ARGOCD_SERVER> --username <USERNAME> --password <PASSWORD>
argocd account generate-token
  • Replace <ARGOCD_SERVER>, <USERNAME>, and <PASSWORD> with your actual server and credentials.
  • The output token can be used in the Stack Automation Deployment Engine configuration.

Use Cases

1. Helm-Driven ArgoCD Deployment and Tracking

The ArgoCD grain is often used in conjunction with the Helm grain. For example, you can use the Helm grain to deploy an application, and then use the ArgoCD grain to track and manage the application's lifecycle and health.

  • Use the Helm grain to create an application that triggers an ArgoCD deployment.
  • Use the ArgoCD grain to capture the deployed workloads and track application status and health.

2. Capture and Extend Workloads

  • Use the ArgoCD grain to capture existing app workloads.
  • Add more resources to the deployment by chaining additional grains or blueprints, such as ingress configuration, secrets injection, or monitoring.

Example Blueprint Sequence:

argo-app (ArgoCD grain) 
-> ingress configuration (Helm/other grain)
-> secrets injection (Terraform/Ansible grain)
-> monitoring (Helm/ArgoCD grain)

This approach allows you to build complex, multi-step deployments where ArgoCD manages the core application, and Stack Automation blueprints extend and enhance the deployment with additional resources and integrations.

Usage example

spec_version: 2

inputs:
agro-server:
type: string
default: argo-qualilabs
allowed-values:
- 'argo-qualilabs'
argo-application:
type: string
default: devops-torque-ui
agent:
type: agent

grains:
argo-app:
kind: argocd
spec:
deployment-engine: '{{ .inputs.agro-server }}'
agent:
name: '{{ .inputs.agent }}'
mode: data
application: '{{ .inputs.argo-application }}'
application-namespace: argocd

Grain Spec Reference

Below are the main fields available in the ArgoCD grain spec section:

agent

Please see the grain agent for more details.

deployment-engine

The name of the configured Deployment Engine in Stack Automation. This field links the grain to a specific ArgoCD server configuration (see Configuring a Deployment Engine).
Example:

deployment-engine: '{{ .inputs.agro-server }}'

mode

The mode in which the ArgoCD grain operates.

  • data (read-only): The grain will only read and track the application state, without making changes.

Example:

mode: data

application

The name of the ArgoCD application to be tracked or managed. This should match the application name as defined in ArgoCD.
Example:

application: '{{ .inputs.argo-application }}'

application-namespace

The namespace in which the ArgoCD application resource exists.

Note: This is the namespace of the ArgoCD Application CRD, not the target namespace of the deployed workloads.

Example:

application-namespace: argocd

For more details on Helm integration, see The Helm Grain.