- Using a scoped ServiceAccount with minimal RBAC permissions is more secure than relying on the default ServiceAccount.
- It prevents permission errors and enables the Sensor to create Workflows in a separate namespace.
argo-events) attempted to create a Workflow in the argo namespace using the default ServiceAccount and was forbidden.
Planned steps:
- Create a ServiceAccount in the Sensor’s namespace (
argo-events). - Create a Role and RoleBinding in the target namespace (
argo) to allow the ServiceAccount to create/read Workflows. - Update the Sensor to use the new ServiceAccount.
- Trigger the Sensor and confirm the Workflow is created.
Resources Overview
References:
1. Create the ServiceAccount
First, list existing ServiceAccounts in theargo-events namespace, then create a new one called workflow-trigger-sa:
2. Create Role and RoleBinding for Argo Workflows
Create a Role in theargo namespace that grants the minimum permissions the Sensor needs for Argo Workflows, and a RoleBinding that binds the workflow-trigger-sa ServiceAccount from the argo-events namespace to that Role.
Manifest to apply:
If you see an error like “unknown command ‘apply’ for ‘kubectl1’”, it likely indicates an alias or PATH issue (for example,
k pointing to an unexpected binary). Use the full kubectl binary or fix the alias so k maps to kubectl.3. Update the Sensor to Use the ServiceAccount
Edit your Sensor manifest to setspec.template.serviceAccountName to the ServiceAccount you created (workflow-trigger-sa). Below is a minimal Sensor snippet showing where to configure this:
workflow-trigger-sa when creating Workflows in the argo namespace.
4. Trigger the Sensor and Confirm Workflow Creation
Trigger the webhook event source (example using curl):success). Then check logs to confirm the event flow:
Example event source logs:
argo namespace:
workflow.argoproj.io/creator and evidence that the Workflow was submitted by the workflow-trigger-sa ServiceAccount.
Check the Workflow pod logs to confirm the job ran successfully (example cowsay output):
Summary / Event Flow
- The webhook EventSource receives the HTTP POST and publishes the event to the event bus.
- The Sensor subscribes to the event bus, evaluates dependencies, and triggers the Argo Workflow.
- The Sensor uses the configured
spec.template.serviceAccountName(workflow-trigger-sa) to submit the Workflow into theargonamespace. - The Role and RoleBinding in the
argonamespace grant the ServiceAccount the necessary permissions to create and read Argo Workflows.