What is the best way to trigger an argo workflow from an API request?
The API request is handled by a web server, how does the server submits the workflow to the argo server? Using the CLI? using a rest request? What is the best/recommended approach here?
There's no one "right way." But here are some of the options, so you can pick the one that makes the most sense for your application:
Use the Argo API
with an SDK (Java, Go, Python)
If your API is written in Java, Go, or Python, and if your interactions with Argo are more complex than simply submitting a Workflow (for example, if you're also listing Workflows and would like a nice representation of those objects), an Argo Workflows SDK might be a good choice. In my experience the SDKs have quirks and bugs, so I'd only dive in if you need a more full-featured client.
directly with some HTTP client
If your use case is very simple (like submitting a small Workflow with a WorkflowTemplate reference), I would recommend using a direct HTTP call to the Argo or Kubernetes API.
Use a webhook
The webhook endpoint is technically part of the API, but it's a bit different. The API is basically a specialized version of the Kubernetes API, tailored to the Argo CRDs. The events
API endpoint provides some additional features specific to kicking off workflows.
Use the CLI
You'd have to fork the CLI process from your server code, so this probably isn't the "cleanest" approach.
Use Argo Events
Argo Events is a separate but closely-related project. It can accept a variety of inputs (webhooks, pub/sub messages, etc) and then trigger a Workflow.
Argo Events could make sense if, for example, you want an external record of all the workflows submitted. Pub/sub would give you that record.
Use the Kubernetes API or CLI
Workflows are just Kubernetes resources, so you can just submit them via Kubernetes mechanisms if you like. If your language has a robust Kubernetes SDK, that's a solid choice.
As I'm sure you can tell, it really depends on the application. Let me know if any of these needs clarification.