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:- Modify Resource (Classic)
- Create/Patch Resources (v2.8+)
Returns the modified source resource. This was the only action type until v2.8 and is still supported.
Basic Configuration
Define actions in theargocd-cm ConfigMap using the format:
resource.customizations.actions.<apiGroup>_<kind>
Simple Action Example
Discovery Script
Thediscovery.lua script determines which actions are available and whether they’re enabled:
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:Creating New Resources
Creating Child Resources
SetownerReference 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
RBAC for Actions
Control access to actions using RBAC:Best Practices
Validate Input
Validate Input
Always validate user input and resource state:
Provide Feedback
Provide Feedback
Return meaningful messages on errors:
Test Thoroughly
Test Thoroughly
Create comprehensive tests covering:
- Normal operation
- Edge cases
- Error conditions
- Various resource states
Use Semantic Names
Use Semantic Names
Choose clear, action-oriented names:
- ✅
restart,scale,create-backup - ❌
do-thing,action1,fix
Security Considerations
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