Skip to main content

Overview

Argo CD allows operators to define custom actions that users can perform on specific resource types. Actions are implemented as Lua scripts and can modify resources or create new ones.
Built-in ActionsArgo CD includes built-in actions like restart for DaemonSet/Deployment/StatefulSet and retry for Argo Rollouts. You can extend these capabilities with custom actions.

Action Types

Argo CD supports two types of resource actions:
Returns the modified source resource. This was the only action type until v2.8 and is still supported.

Basic Configuration

Define actions in the argocd-cm ConfigMap using the format: resource.customizations.actions.<apiGroup>_<kind>

Simple Action Example

Discovery Script

The discovery.lua script determines which actions are available and whether they’re enabled:
Dynamic ActionsUse the resource’s current state to enable/disable actions dynamically. This provides better UX by only showing relevant actions.

Action Definitions

Each action must have a definition with the action logic:

Customizing Action Appearance

Add icons and display names to your actions:
Use FontAwesome free icons. The fa-fw class ensures fixed-width display.

Action Parameters

Define parameters that users can provide when executing actions:
Access parameters in the action script:

Creating New Resources

GitOps DepartureCreating resources via the UI departs from GitOps principles. Use this sparingly and only for resources not part of the desired state.

Creating Child Resources

Set ownerReference for Kubernetes garbage collection:

Creating Independent Resources

1

Add Tracking Label

Copy the Argo CD tracking label so the App recognizes the resource:
2

Prevent Auto-Prune

Set annotation to prevent deletion with auto-prune:
3

Keep App Synced (Optional)

Prevent out-of-sync status:

Complete Creation Example

Merging with Built-in Actions

By default, custom actions override built-in actions. To keep built-in actions:
Custom actions have precedence over built-in actions when names conflict.

Contributing Actions

Contribute actions to the Argo CD repository:

Test File Format

Run tests:

RBAC for Actions

Control access to actions using RBAC:
See the RBAC documentation for details.

Best Practices

Always validate user input and resource state:
Return meaningful messages on errors:
Create comprehensive tests covering:
  • Normal operation
  • Edge cases
  • Error conditions
  • Various resource states
Choose clear, action-oriented names:
  • restart, scale, create-backup
  • do-thing, action1, fix

Security Considerations

Resource PermissionsWhen creating resources:
  • New resources must be permitted at the AppProject level
  • Users need appropriate RBAC permissions
  • Consider the security implications of creating resources outside GitOps

Example: Scale Deployment

Next Steps

Custom Health Checks

Define custom health checks for resources

UI Extensions

Extend the Argo CD web interface

Built-in Actions

Browse built-in resource actions

RBAC

Configure action permissions